30 May 2008

Studying Object Oriented Programming

by mo

I’m currently reading…

Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition)
by Craig Larman

Read more about this book...

(I’m actually reading the 2nd edition)

This is a good book. It started off really boring… really boring! I picked up this book as an introduction to object oriented programming, and it started off with a lot of talk on UML, documentation and the Rational Unified Process. But then I got to chapter 16… "GRASP: Designing Objects with Responsibilities".

Here’s an excerpt that I enjoyed!

“Perhaps the most common mistake when creating a domain model is to represent something as an attribute when it should have been a concept. A rule of thumb to help prevent this mistake is: If we do not think of some conceptual class X as a number or text in the real world, X is probably a conceptual class, not an attribute

Here’s a definition for a Domain Model…

The Domain Model provides a visual dictionary of the domain vocabulary and concepts from which to draw inspiration for the naming of some things in the software design.

Chapter 16 is great so far, it talks about how to decompose responsibilities for objects using an acronym (I’m not a fan of acronyms) called GRASP. GRASP stands for General Responsibility Assignment Software Patterns.

Craig goes on to talk about the five different patterns of GRASP. They are:

  • Information Expert: the class that has the information necessary to fulfill the responsibility.
  • Creator: a class that has the responsibility to create an instance of another class.
  • High Cohesion: increase the measure of how strongly related and focused the responsibilities of an element are.
  • Low Coupling: decrease the amount a class is connected to, has knowledge of, or relies on other elements.
  • Controller: a class with the responsibility of receiving or handling a system event message.