Its Sunday morning and the weather is really bad … so I went to InfoQ …
I found a presentation called The Principle of Agile Design by Bob Martin (“Uncle Bob” from Object Mentor and butUncleBob).
This is an excellent talk, really insightful but funny at the same time. I had to laugh out loud several times. Uncle Bob is is a amazing presenter, he manages to immediately get your attention, and makes sure that you stay tuned.
The talk is about agile design principles in OO-Programming.
The main point of the talk is the following: OO is about managing dependencies. Abstraction is a tool to manage dependencies.
In OO-Design high-level policy/components do not depend on low-level details/components. Abstraction of the low-level details removes the dependency from the high-level components. It is a characteristic of procedural programs that they do depend on low-level details.
Bob Martin explains these concepts with a very illustrative and funny example of a copy module, that copies chars from the keyboard to the printer. Later on the module has to be extended and begins to rot… Watch it, you will laugh…
Bob Martin then moves on to some class design principles every OO-designer should know about:
These are the SOLID-Principles:
- SRP: Single Responsibility Principle
- OCP: The Open/Close Principle
- LSP: Liskov Substitution Principle
- ISP: Interface Segregation Principle
- DIP: Dependency Inversion Principle
SRP: A class should have one, and only one, reason to change. If a class has many reason to change it becomes rigid, it becomes a dependency magnet. That means if you change any part of the system, you have to change the given class too. Strict Separation of Concerns and Decoupling helps to ensure the SRP. Technically this often means to split one class in several classes that have exactly one, well defined responsibility.
OCP: Modules should be open for extension, but closed for modification (Bertrand Meyer). Change should be applied with addition and not with modification.
Unfortunately the recording ends here suddenly, because the presentation shifted into “tutorial mode”, which could not be recorded anymore!?!
This is quite disappointment, but the talk is really worth to watch it anyway.
No comments:
Post a Comment