Refactoring

Print the objectives

Take the exam   Take a beta test

This exam focuses on Refactoring. For successfully pass this exam the students must be able to:

  • identify why some code samples are suboptimal
  • improve some code samples
  • understand why refactoring is crucial in the development process
  • understand in which steps of the development process refactoring is applied
  • understand common code smells

The following readings are recommended for this exam:

  • Refactoring: Improving the Design of Existing Code by Martin Fowler et al.
  • Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
  • Effective Java: A Programming Language Guide by Joshua Bloch

Other useful resources in the net are:

Note: For the code samples the scope of API and frameworks that can be used in the questions is restricted to Java SE 6. Not covered are JUnit test anti-patterns and refactoring. This topic is covered by the JUnit Intermediate Exam.

  Released  Beta  Frozen  

Basics  3 questions

  • Explain why code should be refactored
  • Explain why readability of code is crucial
  • Discuss the scope of code to be refactored
  • Differentiate refactoring with agile development
  • Show the relation of refactoring and maintenance effort
  • Discuss the relations between refactoring and testing
  • Explain what an anti-pattern is
  • Define a code smell
Keywords: code smell, anti-pattern, agile development, test driven development, testing, clean code
11 1 1

General Issues  2 questions

  • Discuss the evil of duplicated code
  • Discuss the problem of dead code
  • Simplify conditional and other expressions
Keywords: duplicated code, dead code, magic numbers
7 0 1

Modules  4 questions

  • Discuss the appropriateness of dependencies between classes
  • Discuss the problem of divergent changes
  • Detect the possibility to refactor existing code to use polymorphismus
Keywords: feature envy, data clumps, primitive obsession, parallel inheritance hierarchy, message chains, middle man, refused bequest, incomplete library class, coupling, divergent changes, shotgun surgery, switch statements, speculative generality
12 1 1

Classes  2 questions

  • Examine the cohesion of a class
  • Identify classes having more than one responsibility
  • Examine the length of a class
Keywords: large class, lazy class, temporary fields, inappropriate intimacy, inappropriate static, value object
7 1 0

Methods  2 questions

  • Examine the levels of abstraction used inside a method
  • Examine the proper size and length of lines and methods
  • Classify the parameter list of a method
  • Examine the type of parameters
Keywords: long method, long parameter list, output arguments, flag arguments, level of abstraction
5 1 1

Naming and Comments  2 questions

  • Review proper naming for variables, fields, properties, function and classes
  • Examine the expressiveness of the name of an element compared to what the code really does
  • Distinguish between appropriate and inappropriate comments
Keywords: expressiveness, naming convention, inappropriate information, obsolete comment, redundant comment, poorly written comment, commented-out code
6 3 0

Exception Handling  2 questions

  • Identify awkward exception handling strategy
  • Explain why using flags to indicate an exceptional state is suboptimal
  • Detect the difficulties of using null in the scope of an exceptional program state
Keywords: flags, try-catch-ignore, null
6 0 0

Legacy Code  3 questions

  • Improve legacy code to use state of the art API (Java 1.6)
  • Identify obsolete patterns (Java 1.4 and previous)
  • Determine flawed and ineffective code caused by improper use of the API
Keywords: enum, static imports, for each, generics, boxing, unboxing, varargs

Note: Do not add any questions about Java 5 features without a clear relation how the problem has been solved with Java 1.4

10 0 0

Exam information

  • 25 minutes
  • 20 questions (75)
  • 80% required
  • +4 √
  • - 8  points
  • 15 day delay
  • status: released

Exam leader