Singletons are most useful for a not having to create

This preview shows page 4 - 6 out of 7 pages.

MT2 Practice.pdf

12 .   Singletons are most useful for :
a . Not having to create many instances of the same class ,
e. g. instance of a null object .
b . Keeping a class ’s API cleaner .
c . Keeping track of global state .
d . Decreasing global variables clutter , because we can use singletons to replacing any global variables
e. g. $variable we would have created .
13 .   Where is the best place to store a runtime feature flag on / off value .
Get answer to your question and much more
14 .   With continuous integration , what is the best way to hide a large incomplete feature from users ? This feature is being worked on by 10 engineers and will span multiple iterations . We do not want to leak the feature to user 's browsers until ready for launch .
Get answer to your question and much more
15 .   Unit tests should :
Get answer to your question and much more
16 .   Select ALL that apply . Examples of a proxy object include :
a . A DirectionsService that serves cached offline results if the user has downloaded this city 's map area , else calls the Maps server .
b . A MailService that sends out the email if online , else queues the email for sending .
c. Movies . reviews , which returns an object that acts like a Collection of DB data objects , but does n't actually do the SQL query until you need to .
d . The subclass CanadianGoose , that subclasses Goose , and overrides the superclass ' draw method to output a different PNG image .
17 .   Which is FALSE about the observer pattern :
Get answer to your question and much more
18 .   The Demeter Principle states that :
Get answer to your question and much more
19 .   What is NOT a way you can improve response time .
Get answer to your question and much more
20 .   When doing a database query like @reviews = Review . where ( rating : 5 ) , which we later call @reviews . each do | review | ; review.moviegoers.first , we should :
a . Lazy load the moviegoers table data , deferring it until the result is needed , so initial latency is decreased .
b . Always eager load associated tables ,
e. g. . includes ( : moviegoers ) and .includes ( :movies ) , to decrease latency if the result is needed later . Including other tables at the time of the first SQL query does n't increase initial latency .
c . Combine subqueries into the initial query via eager loading if we ’ll need those subqueries eventually ,
e. g. add . includes ( : moviegoers ) in this case .
21 .   Select all that apply : Suppose we want to add a Theaters model to Rotten Potatoes , with the simplifying assumption that each Theater is showing only one movie at any given time , but a given Movie could be showing at many Theaters . Besides adding a theaters table to the database , which steps are necessary so that movie . theaters will return a list of all the theaters at which a movie is showing ?
Get answer to your question and much more
22 .   Assuming that a Movie has many Reviews , a Review belongs to a single Movie , and movie ID 5 exists , what table ( s ) will be updated as a result of the following code ? ( HINT : recall that build is like new in that it creates and populates a new instance of the owned object , but does not save anything to the database . ) m = Movie.find ( 5 ) m.reviews.build(:potatoes => 5 ) m.save !
Get answer to your question and much more
12. Singletons are most useful for:a.Not having to create many instances of the same class, e.g. instance of a null object.b.Keeping a class’s API cleaner.c.Keeping track of global state.d.Decreasing global variables clutter, because we can use singletons to replacing anyglobal variables e.g. $variablewe would have created.
13. Where is the best place to store a runtime feature flag on/off value.
14. With continuous integration, what is the best way to hide a large incomplete feature fromusers? This feature is being worked on by 10 engineers and will span multiple iterations. Wedo not want to leak the feature to user's browsers until ready for launch.
15. Unit tests should:
16. Select ALL that apply. Examples of a proxy object include:a.A DirectionsServicethat serves cached offline results if the user has downloadedthis city's map area, else calls the Maps server.b.A MailServicethat sends out the email if online, else queues the email for sending.c.Movies.reviews, which returns an object that acts like a Collection of DB dataobjects, but doesn't actually do the SQL query until you need to.d.The subclass CanadianGoose, that subclasses Goose, and overrides the superclass'drawmethod to output a different PNG image.
17. Which is FALSE about the observer pattern:
18. The Demeter Principle states that:

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture