Refactoring and Encapsulation - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Which statement best describes the goal of refactoring?
Please select the best answer.
  A. Separate the interface of an object from the implementation of the object.
  B. Describe patterns of object interaction at every level of abstraction.
  C. Identify opportunities to integrate business process reengineering with the development process.
  D. Identify the problems caused by a process and change the process to prevent the problems.
  The correct answer is D. Identify the problems caused by a process and change the process toA prevent the problems. A is incorrect because it describes encapsulation, not refactoring. B is incorrect because refactoring is all about problems caused by approaches to software development. Patterns are just one means of refactoring a process. C is incorrect because this is just one possible solution or part of a solution for addressing one type of problem in software development.

2. Where should you apply the principle of encapsulation?
Please select the best answer.
  A. At every level of abstraction, for example, objects, components, applications, job descriptions, departments, companies, and systems
  B. At every level of the software modeling process, for example, objects, classes, packages, components, nodes, and systems
  C. To objects and to actors because job descriptions should be defined by responsibility in the same way the objects are defined
  D. To objects and all the diagrams that illustrate how objects work; this ensures that the objects are defined and used consistently throughout the model
  The correct answer is A. Encapsulation should be applied at every level of abstraction, for example, objects, components, applications, job descriptions, departments, companies, and systems. B is incorrect because encapsulation is equally valuable for defining the user domain, that is, jobs, departments, companies, and so on. C is incorrect because encapsulation should applied to all levels of abstraction both in the software models and in the user domain. D is incorrect because encapsulation also applies to larger entities in the modeling diagrams such as packages, components, applications, and systems, as well as to responsibilities in the user domain.

3. How does encapsulation affect how you describe objects in your model?
Please select the best answer.
  A. The object implementation drives the design of the object so that the modeling process can take advantage of the features of the technology.
  B. The object implementation is defined separate from the object interface.
  C. The object interface is hidden within the definition of the object responsibilities.
  D. The object interface is defined after an implementation has been established in the project constraints.
  The correct answer is B. The object implementation is defined separate from the object interface. A is incorrect because encapsulation completely separates the implementation from the interface. C is incorrect because an object's interface has to be exposed or other objects cannot communicate with it. D is incorrect because the interface is independent from the implementation. In fact, the implementation may change several times and never affect the interface.

4. What is the benefit of encapsulation?
Please select the best answer.
  A. You can focus on object responsibilities and postpone implementation choices.
  B. Encapsulation improves cohesion and coupling.
  C. You can customize interfaces to exploit different implementations.
  D. Encapsulation limits the interface to the events documented in the sequence diagrams.
  The correct answer is A. Encapsulation separates the interface definition from the implementation so you can postpone the implementation choices until you are certain of the interface requirements.
B is incorrect because encapsulation by itself has no effect on cohesion or coupling. C is incorrect because the whole idea of encapsulation is that the implementation can vary but the interface remains the same. D is incorrect because the sequence diagram technique for finding interfaces is merely a suggested technique. Encapsulation does not tell you how to find the interfaces, only how to separate the interface requirements from the implementation.

5. Why have so many companies failed to reap the touted benefits of object-oriented modeling?
Please select the best answer.
  A. Object-oriented development is often too sophisticated for people who are used to procedural techniques such as structured analysis.
  B. The technologies available to support true object-oriented designs are not mature enough yet.
  C. Companies lack commitment to reuse and try to use procedural or data-driven processes.
  D. Legacy systems are typically procedural by design so they defy conversion to an object-oriented approach.
  The correct answer is C. Typically, companies fail to achieve better results from object-oriented technologies and methods because they lack the commitment to reuse and try to use procedural or data-driven processes. They are using old processes with new tools.