Summary of refactoring A refactoring is a particular transformation of a piece

Summary of refactoring a refactoring is a particular

This preview shows page 369 - 371 out of 517 pages.

Summary of refactoring: A refactoring is a particular transformation of a piece of code, including a name, description of when to use the refactoring and what it does, and detailed sequence of mechanical steps to apply the refactoring. Effective refactorings should improve software metrics, eliminate code smells, or both. Although most refactorings will inevitably cause some existing tests to fail (if not, the code in question is probably undertested), a key goal of the refactoring process is to minimize the amount of time until those tests are modified and once again passing green. Sometimes applying a refactoring may result in recursively having to apply simpler refactorings first, as Decompose Conditional may require applying Extract Method .
Image of page 369
ELABORATION: Refactoring and language choice Some refactorings compensate for programming language features that may encourage bad code. For example, one suggested refactoring for adding seams is Encapsulate Field , in which direct access to an object’s instance variables is replaced by calls to getter and setter methods. This makes sense in Java, but as we’ve seen, getter and setter methods provide the only access to a Ruby object’s instance variables from outside the object. (The refactoring still makes sense inside the object’s own methods, as the Elaboration at the end of Section 3.4 suggests.) Similarly, the Generalize Type refactoring suggests creating more general types to improve code sharing, but Ruby’s mixins and duck typing make such sharing easy. As we’ll see in Chapter 11 , it’s also the case that some design patterns are simply unnecessary in Ruby because the problem they solve doesn’t arise in dynamic languages. Self-Check 9.6.1. 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. 9.7 The Plan-And-Document Perspective One reason for the term lifecycle from Chapter 1 is that a software product enters a maintenance phase after development completes. Roughly two-thirds of the costs are in maintenance versus one-third in development. One reason that companies charge roughly 10% of the price of software for annual maintenance is to pay the team that does the maintenance. Organizations following Plan-And-Document processes typically have different teams for development and maintenance, with developers being redistributed onto new projects once the project is released. Thus, we now have a maintenance manager who takes over the roles of the project manager during development, and we have maintenance software engineers working on the team that make the changes to the code. Sadly, maintenance engineering has an unglamorous reputation, so it is typically performed by either the newest or least accomplished managers and engineers in an organization. Many organizations use different people for Quality Assessment to do the testing and for user documentation.
Image of page 370
Image of page 371

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors