Suppose Order belongs to Customer, and a view has @order.customer.name. Is this a Demeter violation?
A. Yes...but probably reasonable to just expose object graph in the view in this case
B. Yes...replace with Order#customer_name which delegates to Customer#name
C. Yes...you can make a case for either of the above
D. No...by using belongs_to we're already exposing info about the Customer anyway
查看答案
The use of FakeWeb to stub external SOA requests in testing is an example of which design pattern?- 未答复
A. Null object
B. Proxy
C. Adapter
D. Facade
n RSpec controller tests, it's common to stub ActiveRecord::Base.where, an inherited method. Which statements are true of such tests:a. The controller under test is tightly coupled to the modelb. In a static language, we'd have to use DI to achieve the same task in the testing framework.
A. only (a)
B. only (b)
C. both (a) and (b)
D. neither (a) nor (b)
Your users are sporadically complaining that your site is slow, yet New Relic reports low traffic levels and low CPU utilization. What is the likely cause?
A. Not enough Heroku “dynos”, so requests occasionally get “backed up”
B. Some queries are unusually slow because you’re sharing DB with other apps
C. Some views take unusually long to render in certain browsers (eg, due to JavaScript)
D. It could be any of these/Not enough information
(a) In duck-typed languages, LSP violations can occur even when inheritance is not used(b) In statically-typed languages, if the compiler reports no type errors/warnings, then there are no LSP violations
A. Only (a) is true
B. Only (b) is true
C. Both are true
D. Both are false