© James E. McDonough 2017

James E. McDonough, Object-Oriented Design with ABAP, 10.1007/978-1-4842-2838-8_28

28. Solidifying Robust Design Habits

James E. McDonough

(1)Pennington, New Jersey, USA

Much has been learned over the years about what constitutes good object-oriented design, some of which has been gained at the expense of object-oriented pioneers, who, through trial and error, have discovered cases of poor design and have shared their knowledge with those of us who otherwise would find out the hard way why some designs are not viable.

The Gang of Four offer these nuggets of wisdom:

  1. Program to an interface, not an implementation.1

  2. Favor composition over class inheritance.2

  3. Encapsulate the concept that varies.3

The first of these statements is exemplified by, among others, the Strategy design pattern; the second by, among others, the Decorator design pattern; and the third by, among others, the Adapter, State, and Template Method design patterns.

Robert C. Martin , one of the foremost authorities on the subject of object-oriented design and affectionately known within the software industry as Uncle Bob , compiled the following five principles of class design as part of his Principles of Object-Oriented Design:4

Single Responsibility Principle

  • A class should have only a single responsibility (i.e. only one potential change in the software’s specification should be able to affect the specification of the class).

Open Closed Principle

  • Software entities should be open for extension, but closed for modification.

Liskov Substitution Principle

  • Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

Interface Segregation Principle

  • Many client-specific interfaces are better than one general-purpose interface.

Dependency Inversion Principle

  • Depend upon abstractions. Do not depend upon concretions.

The first letter of the first word of each principle produces the acronym SOLID. These principles advise object-oriented designers of software design considerations found to be beneficial toward simplifying subsequent maintenance. In the preceding chapters, we encountered both the Single Responsibility Principle (in Chapter 3’s “Considerations for Using Encapsulation Effectively” section) and the Open/Closed Principle (in Chapter 26’s “Sorry, We’re Closed” section) and the beneficial effect each one contributes to maintenance cycles.

Although each of these principles had their origin in previous papers, articles, books, and blogs published by him in the late 1990s, Martin compiled them all into a document written in 2000 with the title “Design Principles and Design Patterns.”5 These principles and the concepts they embody have subsequently been embraced by many in the software industry as an essential foundation for designing maintainable software and promoting excellence in programming.

Indeed, Martin , one of the original signatories of the Agile Manifesto and a guiding force in the software industry for nearly 50 years, in recent years has authored books and given lectures on the topic of clean code, dedicated to the prospect of leaving code in a state that easily can be understood and maintained by the next programmer. His books Clean Code 6 and The Clean Coder 7 address the ways in which programmers can improve their craftsmanship in pursuit of this goal.

Footnotes

1 GoF, p. 18.

2 GoF, p. 20.

3 GoF, p. 29.

6 Robert C. Martin , Clean Code : A Handbook of Agile Software Craftsmanship, Pearson Education, 2008.

7 Robert C. Martin, The Clean Coder: A Code of Conduct for Professional Programmers, Prentice Hall, 2011.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset