These notes accompany a sample Java project that illustrates a number of code smells. The initial version of the code is in package com.neopragma.legacy.round0.
Smell 1. Worthless class-level comment. (See notes)
Smell 2. Violation of Separation of Concerns: main method is baked directly into the entity class. Starting and stopping the application and handling input are different concerns than the single responsibility of the JobApplicant class. (See notes)
Smell 3: Violation of Separation of Concerns: Class JobApplicant contains code to access a web-based resource directly in method setZipCode. Network communication is not part of the single responsibility of the JobApplicant class. (See notes)
Smell 4: Violation of Single Responsibility Principle (SRP): Class JobApplicant apparently represents the domain concept "Job Applicant," but contains functionality to deal with names, addresses, and Social Security Numbers. (See notes)
Smell 5: Error codes from SSN validation routines are all hard-coded literals. This is refactored in the course of remediating Smell 4.
Smell 6: Poor code isolation: Checks for zipcode functionality are dependent on a web-based resource. (See notes)
Smell 7: Comments that do not describe the functionality accurately. The code does not check the content length, as the comments state. (See notes)
Smell 8: Useless code in method setZipCode to retrieve the content length. The variable len is never referenced. (See notes)
Smell 9: Integration tests posing as unit tests: Checks for zipcode functionality are dependent on a web-based resource. For that reason, these checks are not really "unit tests." Separate unit and integration checks and enable Maven to run them separately on demand. (See notes)
Smell 10: Violation of Separation of Concerns: Class JobApplicant contains code to handle persistence (the save method). Persistence is not part of the single responsibility of the JobApplicant class. (See notes)
Smell 11: Violation of Law of Demeter: Checked exceptions must be handled by client code. Client code has to know too much about the internal implementation details of the JobApplicant class. (See notes)
Smell 12: No API documentation (javadoc comments). (See notes)
Smell 13: Code contains magic numbers. (See notes)
Smell 14: Missing case: There is no check for the case when the supplied zipcode is not found in the lookup. (See notes)
Smell 15: Crufty, undocumented, and non-self-describing code in method setZipCode to interact with Apache HttpClient. (See notes)
Smell 16: Poor separation of concerns: Main class combines application management, persistence management, and user interaction. (See notes)
Smell 17: Repetitious code in methods setName and setSpanishName to avoid storing null values. (See notes)
Smell 18(a): Set the stage to split out English and Spanish name handling. (See notes)
Smell 18(b): Implementing internationalization support. (See notes)