Object Oriented Design

Good object oriented design creates a codebase that is easy to modify to meet future requirements that are inevitably in flux. Poorly organized code is intertwined and painful to change because when one portion of the code is updated, the others break. Programmers are not expected to predict future requirements and should focus on developing software that is flexible enough to meet requirements that are unknown at this time. The art of arranging code is part of software craftsmanship and is critical to develop applications that are a pleasure to work on, even as requirements change.

Objects communicate with other objects by sending messages and these dependencies need to be managed, so the objects do not become too intertwined. When objects are highly dependent on each other, the entire application behaves as one class and the benefits of separating distinct concepts into separate classes are lost. In this expression, ‘foo’.upcase(), the upcase() message is sent to the “foo” object, which invokes the upcase() method that is defined in the String class. ‘foo’ is the message receiver and the message sender needs to know that the receiver will understand the message and perform the expected behavior (in this case, capitalize every letter in the String). Good object oriented design is most concerned with managing dependencies between objects and making sure the objects do not become too intertwined with each other.

Good object oriented design creates flexible code that is easily adaptable to unknown future requirements and fits well with the agile development process of rapid iteration and prototyping. Object oriented design creates flexible software, so when customers request changes or features, the prototype can be easily modified to meet their requirements.

If software never changed design would not matter, but in reality, software is constantly changing and good software design is vital. Arranging code well is an art and one of the joys of the software craft.

* This post was inspired by Practice Object Oriented Design in Ruby by Sandi Metz.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s