SE Quiz 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

True or False: every HTML element must have an ID

False: the ID is optional, though must be unique if provided.

What are a major similarity and a major difference between processes like Spiral and RUP versus Waterfall?

All rely on planning and documentation, but Spiral and RUP use iteration and prototypes to improve them over time versus a single long path to the product.

Why is movie.@year=1998 not a substitute for movie.year=1998?

The notation a.b always means "call method b on receiver a", but @year is the name of an instance variable, whereas year= is the name of the instance method.

In create_table 'movies' do |t|, how many arguments are we passing to create_table, and of what types?

Two arguments: the first is a string and the second is a block. We used poetry mode, allowing us to omit parentheses.

Of the 3 debugging methods described in section 4.5, which ones are appropriate for collection instrumentation or diagnostic information once your app is deployed and in production?

Only the logger method is appropriate, since the other two methods ("stopping the show" in a controller or inserting diagnostic information into views) would interfere with he usage of real customers if used on a production app.

Why is this.document, when it appears outside the scope of any function, equivalent to window.document?

Outside of any function, the value of this is the global object. When JavaScript runs in a Web browser, the global object is the window object.

In the ________ tier of the three-tier SaaS apps, scaling is more complicated that just adding computers.

Persistence tier

True or False: Supporting RESTful operations simplifies integrating a SaaS app with other services in a Service-Oriented Architecture

True

True or false: Cucumber matches scenario steps to step definitions using regexes and Capybara pretends to be a user that interacts with the SaaS application according to these scenarios

True

True or false: The cost of maintenance usually exceeds the cost of development

True

True or false: The purpose of the Lo-Fi UI and storyboards is to debug the UI before you program it.

True

True or false: User stories on 3x5 cards in BDD play the same role as design requirements in plan-and-document

True

True or false: Scrum is at its best when it is difficult to plan ahead

True. Scrum relies more on real-time feedback than on the traditional management approach of central planning with command and control

True or False: If you are using the Agile development process to develop SaaS apps, you could use Python and Django or languages based on the Microsoft CLR and ASP .NET instead of Ruby and Rails.

True: Programming frameworks for Agile and SaaS include Django and ASP .NET

Explain why calling $(selector) is equivalent to calling $(window.document).find(selector)

document is a property of the browser's built-in global object (window) that refers to the browser's representation of the root of the DOM. Wrapping the document element using $ gives it access to jQuery functions such as find, which locates all elements matching the selector that are in the subtree of its target; in this case, the target is the DOM root so it will find any matching elements in the entire document.

A single RSpec test case or example is introduced by the keyword _______. A group of related examples is introduced by the keyword _______, which can be nested to organize examples hierarchically.

it; describe

Write one line of Ruby that checks whether a string s is a palindrome, that is, it reads the same backwards as forwards.

s.downcase == s.downcase.reverse

Since RSpec matches tests to classes using convention over configuration, we would put the tests for app/models/movie.rb in the file _______.

spec/models/movie_spec.rb

Why does 5.superclass result in the "undefined method" error? (Hint: consider the difference between calling superclass on 5 itself vs. calling it on the object returned by 5.class)

superclass is a method defined on classes. The object 5 is not itself a class, so you can't call superclass on it.

Specify whether each of the following RSpec constructs is used to (a) create a seam, (b) determine the behavior of a seam, (c) neither: (1) assigns(); (2) should_receive; (3) stub; (4) and_return

(1) c, (2) a, (3) a, (4) b

Which of the following are examples of structured storage: (a) an Excel spreadsheet, (b) a plain text file containing the text of an email message, (c) a text file consisting of names, with exactly one name per line?

(a) and (c) are structured, since an app reading those files can make assumptions about how to interpret the content based on structure alone. (b) is unstructured.

Which of the following Ruby expressions are equal to each other: (a) :foo (b) %q{foo} (c) %Q{foo} (d) 'foo'.to_sym (e) :foo.to_s

(a) and (d) are equal to each other; (b), (c), and (e) are equal to each other

Which tier(s) in the three-tier architecture are involved in handling each of the following: (a) models, (b) controllers, (c) views?

(a) models: logic and persistence tiers; (b) controllers: logic and presentation tiers; (c) views: logic and presentation tiers.

What is captured by $1 when the string 25 to 1 is matched against each of the following reqexps: (a) /(\d+)$/ (b) /^\d+([^0-9]+)/

(a) the string "1" (b) the string " to" (Including the spaces before and after)

Do Rails models acquire the methods where and find via (a) inheritance or (b) mix-in?

(a) they inherit from ActiveRecord::Base

Which statement is correct and why: (a) include 'enumerable' (b) include Enumerable

(b) is correct, since include expects the name of a module, which (like a class name) is a constant rather than a string

Which is not a goal of method-level refactoring: (a) reducing code complexity, (b) eliminating code smells, (c) eliminating bugs, (d) improving testability?

(c). While debugging is important, the goal of refactoring is to preserve the code's current behavior while changing its structure.

State whether each of the following is a goal of unit and functional testing, a goal of characterization testing, or both: -Improve coverage -Test boundary conditions and corner cases -Document intent and behavior of app code -Prevent regressions (reintroduction of earlier bugs)

(i) and (iii) are goals of unit, functional, and characterization testing. (ii) and (iv) are goals of unit and functional testing, but non-goals of characterization testing.

Match the plan-and-document maintenance terms (numbered) to the agile terms (lettered): 1. Change request 2. Change request cost estimate 3. Change request triage 4. Release A. Iteration B. Icebox, Active columns in Pivotal Tracker C. Points D. User Story

1, D; 2, C; 3, B; 4, A

Which of the examples of Google SaaS apps -- Search, Maps, News, Gmail, Calendar, YouTube, and Documents -- is the best match to each of the six arguments given in this section for SaaS, reproduced below.

1. No user installation: Documents 2. Can't lose data: Gmail, Calendar 3. Users cooperating: Documents 4. Large/changing datasets: Search, Maps, News, and YouTube 5. Software centralized in single environment: Search 6. No field upgrades when improve app: Documents

Given that submitting the form shown in Figure 4.11 will create a new movie, why is the view called new.html.haml rather than create.html.haml?

A RESTful route and its view should name the resource being requested. In this case, the resource requested when the user loads this form is the form itself, that is, the ability to create a new movie; hence new is an appropriate name for this resource, The resource requested when the user submits the form, named by the route specified for form submission on line 3 of the figure, is the actual creation of the new movie.

What is the primary difference between a client and a server in SaaS?

A SaaS client is optimized for allowing the user to interact with information, whereas a SaaS server is optimized for serving many clients simultaneously.

True or false: You need to implement all the code being tested before Cucumber will say that the test passes

False. A sad path can pass without having the code written needed to make a happy path pass

True or false: even after the user closes a window in her Web browser, the JavaScript code associated with that window can still access and traverse the HTML document the window had been displaying.

False. Each new HTML document gets its own global object and DOM, which are destroyed when the document's window is closed.

True or false: As practitioners of Agile Development, Pivotal Labs does not use contracts.

False. Pivotal certainly offers customers a contract that they sign, but it is primarily a promise to pay Pivotal for its best effort over to make the customer happy for a limited range of time.

True or false: Explicit requirements are usually defined with imperative scenarios and implicit requirements are usually defined with declarative scenarios.

False. These are two independent classifications; both requirements can use either type of scenarios.

True or false: One reason legacy code is long lasting is because it typically has good comments.

False. We wish it were true. Comments are often missing or inconsistent with the code, which is on reason it is called legacy code rather than beautiful code.

True or false: When you don't know how to approach a given user story, just give it 3 points.

False: A user story should not be so complex that you don't have an approach to implementing it. If they are, you should go back to your stakeholders to refactor the user story into a set of simpler tasks that you do know how to approach

True or False: A big difference between Spiral and Agile development is building prototypes and interacting with customers during the process.

False: Both build working but incomplete prototypes that the customer helps evaluate. The difference is that customers are involved every two weeks in Agile versus up to two years in with Spiral.

True or False: If an app has a RESTful API, it just be performing CRUD operations.

False: The REST principle can be applied to any kind of operation, as long as the app represents its entities as resources and specifies what operations are allowed on each type of resource.

True or False: Internal data centers could get the same cost savings as Warehouse Scale Computers if they embraced SOA and purchased the same type of hardware.

False: While imitating best practices of WSC could lower costs, the major cost advantage of WSCs comes from the economies of scale, which today means 100,000 servers, thereby dwarfing most internal datacenters.

True or false: Refactoring and reengineering are synonyms

False: While related terms, reengineering often relies on automatic tools and occurs as software ages and maintainability becomes more difficult, yet refactoring is a continuous process of code improvement that happens during both development and maintenance.

True or false: If you log in to RottenPotatoes using your Twitter ID, RottenPotatoes becomes capable of tweeting using your Twitter ID

False: authentication is separate from permissions. Most third-party authentication providers, including Twitter, allow the requesting app to ask for permission to do specific things, and leave it up to the user to decide whether to allow it.

True or false: When comparing two teams, the one with the higher velocity is more productive

False: since each team assigns points to user stories, you cannot use velocity to compare different teams. However, you could look over time for a given team to see if there were iterations that were significantly less or more productivity

True or false: in order to use the TMDb API from another language such as Java, we would need a Java library equivalent to themoviedb gem

False: the API consists of a set of HTTP requests and JSON responses, so as long as we can transmit and receive bytes over TCP/IP and have the ability to parse strings (the JSON responses), we can use the APIs without a special library.

Why can't we write validate released_1930_or_later, that is, why must the argument to validate be either a symbol or a string?

If the argument is just the "bare" name of the method, Ruby will try to evaluate it at the moment it executes validate, which isn't what we want -- we want released_1930_or_later to be called at the time any validation is to occur.

In Figure 4.6, why is there no end corresponding to the do in line 12?

Unlike Ruby itself, Haml relies on indentation to indicate nesting, so the end is supplied by Haml when executing the Ruby code in the do.

Why can't you just use print or puts to display messages to help debug your SaaS app?

Unlike command-line apps, SaaS apps aren't attached to a terminal window, so there's no obvious place for the output of a print statement to go.

When is it correct to write Fixnum num = 3 to initialize the variable num: (a) on its first use; (b) on any use, as long as its the same class Fixnum each time; (c) never

Never; variable declarations aren't used in Ruby

Why must we provide values for a review's movie_id and moviegoer_id to the new and create actions in ReviewsController, but not to the edit and update actions?

Once the review is created, the stored values of its movie_id and moviegoer_id fields tell us the associated movie and moviegoer.

While all of the following help with verification, which form of testing is most likely to help with validation: Unit, Module, Integration, or Acceptance?

Validation is concerned with doing what the customer really wants versus whether code met the specification, so acceptance testing is most likely to point out the difference between doing the thing right and doing the right thing.

What are some reasons it is important to get the app running in development even if you don't plan to make any code changes right away?

A few reasons include: 1. For SaaS, the existing tests may need access to a test database, which may not be accessible in production. 2. Part of your exploration might involve the use of an interactive debugger or other tools that could slow down execution, which would be disruptive on the live site. 3. For part of your exploration you might want to modify data in the database, which you can't do with live customer data

The Microsoft Zune music player had an infamous bug that caused all Zunes to "lock up" on December 31, 2008. Later analysis showed that the bug would be triggered on the last day of any leap year. What kinds of tests -- black-box vs. glass-box, mutation, or fuzz -- would have been likely to catch this bug?

A glass-box test for the special code paths used for leap years would have been effective. Fuzz testing might have been effective: since the bug occurs roughly once in every 1460 days, a few thousand fuzz tests would likely have found it.

Jasmine-jQuery also supports toContain and toContainText to check if a string of text or HTML occurs within an element. In line 7 of Figure, 6.21, why would it be incorrect to subsititute .not.toContain('<div id="movieInfo"> </div>') for toBeHidden()?

A hidden element is not visible, but it still contains the text or HTML associated with the element. Hence toContain-style matchers can be used to test the content of an element but not its visibility. In addition, there are many ways for an element to be hidden -- its CSS could include display:none, it could have zero width and height, or its ancestor could be hidden -- and the toBeHidden() matcher checks all of these.

Give an example of a dynamic language feature in Ruby that could distort metrics such as cyclomatic complexity or ABC score.

Any metaprogramming mechanism could do this. A trivial example is s="if (d>=366)[...}"; eval s, since the evaluation of the string would cause a conditional to be executed even though there's no conditional in the code itself, which contains only an assignment to a variable and a call to the eval method. A subtler example is a method such as before_filter, which essentially adds a new method to a list of methods to be called before a controller action.

Why does the form in new.html.haml submit to the create method rather than the new method?

As we saw in chapter 2, creating a new record requires two interactions. The first one, new, loads the form. The second one, create, submits the form and causes the actual creation of the new record.

Why didn't the Rails designers choose to trigger validation when you first instantiate one using Movie#new, rather than waiting until you try to persist the object?

As you're filling in the attributes of the new object, it might be in a temporarily invalid state, so triggering validation at that time might make it difficult to manipulate the object. Persisting the object tells Rails "I believe this object is ready to be saved."

In Ruby, when a method call takes no arguments, the empty parentheses following the method call are optional. Why wouldn't this work in JavaScript?

Because JavaScript functions are first-class objects, a function name without parentheses would be an expression whose value is in the function itself, rather than a call to a function.

Explain why cloud computing might have had a lesser impact on SaaS if most SaaS apps didn't follow the shared-nothing architecture.

Cloud computing allows easily adding and removing computers while paying only for what you use, but it is the shared-nothing architecture that makes it straightforward to "absorb" the new computers into a running app and "release" them when no longer needed.

What is the difference between Co code coverage and code-to-test ration?

Co coverage is a dynamic measurement of what fraction of all statements are executed by a test suite. Code-to-test ratio is a static measurement comparing the total number of lines of code to the total number of lines of tests.

Why is it usually preferable to use before(:each) rather than before(:all)?

Code in a before(:each) block is run before each spec in that block, setting up identical preconditions for all those specs and thereby keeping them Independent.

Which mechanism is the weakest argument for productivity benefits of compilers for high-level programming languages: Clarity via conciseness, Synthesis, Reuse, or Automation and Tools?

Compilers make high-level programming languages practical, enabling programmers to improve productivity via writing the more concise code in HLL. Compilers do synthesize lower-level code based on the HLL input. Compilers are definitely tools. While you can argue that HLL makes reuse easier, reuse is the weakest of the four for explaining the benefits of compilers.

Why does high test coverage not necessarily imply a well-tested application?

Coverage says nothing about the quality of the tests. However, low coverage certainly implies a poorly-tested application

Why is it usually a bad idea to make extensive use of mock or stub in Cucumber scenarios such as those described in Chapter 7?

Cucumber is a tool for full-system testing and acceptance testing. Such testing is specifically intended to exercise the entire system, rather than "faking" certain parts of it as we have done using seams in this chapter.

True or false: one early advantage of JavaScript for form validation (preventing a user from submitting a form with invalid data) was the ability to remove validation code from the server and movie it to the client instead.

False; there is no guarantee the submission actually came from that page (anyone with a command line tool can construct an HTTP request), and even if it dad, the user might be working with a legacy browser. As we point out repeatedly in SaaS, the server cannot trust anyone and must always validate its inputs.

FIRST

Fast, Independent, Repeatable, Self-checking, Timely

Which SOFA guideline -- be Short, do One thing, have Few arguments, stick to a single level of Abstraction -- do you think is most important from a unit-testability point of view?

Few arguments implies fewer ways that code paths in the method can depend on the arguments, making testing more tractable. Short methods are certainly easier to test but this property usually follows when the other three are observed.

Describe in English the steps required to determine all the moviegoers who have reviewed a movie with some given id (primary key)

Find all the reviews whose movie_id field contains the id of the movie of interest. For each review, find the moviegoer whose id matches the reviews moviegoer_id field.

Why must every controller action either render a view or perform a redirect?

HTTP is a request-reply protocol, so every action must generate a reply. One kind of reply is a view (Web page) but another kind is a redirect, which instructs the browser to issue a new request to a different URI.

Suppose a test suite contains a test that adds a model object to a table and then expects to find a certain number of model objects in the table as a result. Explain how the use of fixtures may affect the Independence of the tests in this suite, and how the use of Factories can remedy this problem.

If the fixtures file is ever changed so that the number of items initially populating that table changes, this test may suddenly start failing because its assumptions about the initial state of the table no longer hold. In contrast, a factory can be used to quickly create only those objects needed for each test or example group on demand, so no test needs to depend on any global "initial state" of the database.

Why are where and find class methods rather than instance methods?

Instance methods operate on one instance of the class, but until we look up one or more objects, we have no instance to operate on.

In Figure 5.15, are the association accessors and setters (such as m.reviews and r.movie) instance methods or class methods?

Instance methods, since a collection of reviews is associated with a particular movie, not with movies in general.

Name three plan-and-document techniques that help with requirements elicitation.

Interviewing, Scenarios, and Use Cases

Why should method_missing always call super if it can't handle the missing method call itself?

It's possible that one of your ancestor classes intends to handle the call, but you must explicitly "pass the method call up the chain" with super to give the ancestor classes a chance to do so.

Like RSpec, Jasmine supports andReturn() for returning a canned value from a stub. In figure 6.21, why did we have to write andCallFake to pass ajaxArgs to a function as the result of stubbing ajax, rather than simply writing andReturn(ajaxArgs)?

Remember that AJAX calls are asynchronous. It's not the case that the $.ajax call returns data from the server: normally, it returns immediately, and sometime later, your callback is called with the data from the server. andCallFake simulates this behavior.

Why does it make no sense to have both a render and a redirect (or two renders, or two redirects) along the same code path in a controller action?

Render and redirect are two different ways to reply to a request. Each request needs exactly one reply.

Another take on Service Oriented Architecture (SOA) is that it is just a common sense approach to improving programmer productivity. Which productivity mechanism does SOA best exemplify: Clarity via conciseness, Synthesis, Reuse, or Automation and Tools?

Reuse. The purpose of making internal APIs visible is so that programmers can stand on the shoulders of others.

Briefly describe how RottenPotatoes could let you log in with your Twitter ID without you having to reveal your Twitter password to RottenPotatoes.

RottenPotatoes redirects you to a page hosted by Twitter where you log in as usual. The redirect includes a URL to which Twitter posts back a message confirming that you've authenticated yourself and specifying what actions RottenPotatoes may take on your behalf as a Twitter user.

SOFA

Short, One thing, Few arguments, single level of Abstraction

In Figure 4.7, why don't the helper methods for the New action (new_movie_path) and Create action (movies_path) take an argument, as the Show or Update helpers do?

Show and Update operate on existing movies, so they take an argument to identify which movie to operate on. New and Create by definition operate on not-yet-existing movies.

In Figure 5.14(a), why did we add foreign keys (references) only to the reviews table and not to the moviegoers or movies tables?

Since we need to associate many reviews with a single movie or moviegoer, the foreign keys must be part of the model on the "owned" side of the association, in this case Reviews.

SMART

Specific, Measurable, Achievable, Relevant, and Timeboxed

In Figure 4.7, why doesn't the helper method for the Index action take an argument?

The Index action just shows a list of all the movies, so no argument is needed to distinguish which movie to operate on.

Recall the generic Rails welcome page you saw when you first created the app. In the development.logfile, what is happening when the line Started GET "assets/rails.png" is printed (Hint: recall the steps needed to render a page containing embedded assets)

The browser is requesting the embedded image of the Rails logo for the welcome page.

What happens if we visit the URI http://google.com:3000 and why?

The connection will eventually "time out" unable to contact a server, because Google (like almost all Web sites) listens on TCP port 80 (the default) rather than 3000.

In Figure 3.6, is Time.now a class method or an instance method?

The fact that its receiver is a class name (Time) tells us, it's a class method.

In figure 4.11, what would be the effect of changing :method=>:post to :method=>:get and why?

The form submission would result in listing all movies rather than creating a new movie. The reason is that a route requires both a URI and a method.

Suppose you mix Enumerable into a class Foo that does not provide the each method. What error will be raised when you call Foo.new.map { |elt| puts elt }?

The map method in Enumerable will attempt to call each on its receiver, but since the new Foo object doesn't define each, Ruby will raise an Undefined Method error.

Name two likely violations of FIRST that arise when unit tests actually call an external service as part of testing.

The test may no longer be Fast, since it takes so much longer to call an external service than to compute locally. The test may no longer be Repeatable, since circumstances beyond our control could affect its outcome, such as the temporary unavailability of the external service.

Given the following HTML markup: 1 <p class="x" id="i">I hate <span>Mondays</span></p> 2 <p>but <span class="y">Tuesdays</span> are OK.</p> Write down a CSS selector that will select only the word Mondays for styling.

Three possibilities, from most specific to least specific, are: #i span, p.x span, and .x span. Other selectors are possible but redundant or over-constrained; for example, p#i span and p#i.x span are redundant with respect to this HTML snippet since at most one element can have the ID i. Why are span and p span not valid answers? Both of those selectors also match Tuesdays, which is a span inside a p.

Compare and contrast integration strategies including top-down, bottom-up and sandwich integration.

Top-down needs stubs to perform the tests, but it lets stakeholders get a feeling for how the app works. Bottom-up does not need stubs, but needs potentially everything written before stakeholders see it work. Sandwich integrations works from both ends to try to get both benefits.

What are the differences between the phases of these Plan-and-Document processes: Waterfall, Spiral, RUP

Waterfall phases separate planning (requirements and architectural design) from implementation. Testing the product before release is next, followed by a separate operations phase. The Spiral phases are aimed at an iteration: set the goals for an iteration; explore alternatives; develop and verify the prototype for this iteration; and plan the next iteration. RUP phases are tied closer to business objectives: inception makes business case and sets schedule and budget; elaboration works with customers to build an initial prototype; construction builds and tests the first version; and transition deploys the product.

What is the most common way to associate a CSS stylesheet with an HTML or HTML document?

Within the HEAD element of the HTML or HTML document, include a LINK element with at least the following three attributes: REL="STYLESHEET", TYPE="text/css", and HREF="uri", where uri is the full or partial URI of the stylesheet. That is, the stylesheet must be accessible as a resource named by a URI.

In the method_missing example above, why are $ and ^ necessary in the regular expression match in line 4? (Hint: consider what happens if you omit one of them and call 5.milliseconds or 5.secondary)

Without ^ to constrain the match to the beginning of the string, a call like 5.millisecond would match, which will cause an error when method_missing tries to redispatch the call as 5.milliseconds. Without $ to constrain the match to the end of the string, a call like 5. secondary would match, which will cause an error when method_missing tries to redispatch the call as 5.secondarys

Suppose method foo takes two hash arguments. Explain why we can't use poetry mode to write foo :a => 1, :b => 2

Without curly braces, there's no way to tell whether this call is trying to pass a hash with two keys or two hashes of one key each. Therefore poetry mode can only be used when there's a single hash argument and it's the last argument.

Why do many software engineers believe that when modifying legacy code, good test coverage is more important than detailed design documents or well-structured code?

Without tests, you cannot be confident that your changes to the legacy code preserve its existing behaviors

Cucumber colors steps green that pass the test. What is the difference between steps colored yellow and red?

Yellow steps have not yet been implemented while red steps have been implemented but fail the test.

What happens if we try to access RottenPotatoes at say http://localhost:3300 (instead of :3000) and why?

You get a "connection refused" since nothing is listening on port 3300

What are the two steps you must take to have your app use a particular Ruby gem?

You must add a line to your Gemfile to add a gem and re-run bundle install.

What is the explicit-send equivalent of each of the following expressions: a<b, a==b, x[0], x[0]='foo'

a.send(:<,b), a.send(:==,b), x.send(:[],0), x.send(:[]=,0,'foo')


संबंधित स्टडी सेट्स

★ Peds HESI Practice Questions ★

View Set

Evaluating Expressions with Exponents: Assignment

View Set

Skin Cancer Med Surg Success & Test Bank

View Set

History Chapter 20-23 Study Guide

View Set

Evolve Pediatric/maternatiy quiz 3

View Set

Motivation - cognitive evaluation theory

View Set