OOAD 101 Lesson 1: What is an object and what is object-oriented?

April 21st, 2006

Course Outline:

Required Reading : Design Patterns: Elements of Reusable Object-Oriented Software. This is often referred to as the Gang of Four book as it was written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. You may have other design patterns books, but IMO, this book is the most efficient at conveying the ideas. It is a must have for anyone serious about becoming a proficient object-oriented developer. You will use this book as a reference guide, and it will take years to master.


Lesson 1: What is an object and what is object-oriented?
Quite simply an object models data and behavior. For example, say I wanted to implement the card game, NetRunner. To represent a deck of cards, I could create a class called DeckOfCards. The data would be the individual cards in a deck. The behavior might be things like shuffle and drawCard.
A language is called object-oriented if it supports polymorphism and inheritance. If the language is only polymorphic or only supports inheritance, then it is considered object-based rather than object-oriented.

So what is polymorphism? What is inheritance? And why am I going over it? Glad you asked!

Polymorphism is the ability to process objects differently depending on their data type or class. For example, in NetRunner there is and operation card called “Accounts Receivable” and an ice card called “Liche”. Both are NetRunner corporation cards. You can “play” both cards from your hand. However the behavior of an ice card is very different from the behavior of an operation when it is played. When you play an operation, you execute the card function immediately, pay the cost, and put the card in the discard pile. When you play the ice, you place it face down in front of something called a data fort. The card game engine, however, only needs to know it has a “card” that you can “play”. But because the card game engine polymorphism, the “play” behavior can vary drastically based on the card being played.

Inheritance is the ability to derive one object type from another. The derived class gains all the behavior and data of the parent class. If the language is also polymorphic, the derived class can override the behavior of an “inherited” class.
For example, based on the above example, you might create a Card class. This card class may have some common methods for rendering and an unimplemented method called play. For each type of card (e.g. operation, ice), you could create a sub-class which inherits the render method, because all cards are rendered the same way, but provides its own implementation for play. BTW – I DO NOT recommend this design approach. In a latter post I will get into aggregate behavior via object-composition vs. inheritance. The example is for illustrative purposes only.

Ok, so now you know what an object is and you know what we mean by object-oriented. So what the hec is Object Oriented Analysis and Design (OOAD)? OOAD is a process of assigning data and behavior to a system of candidate objects.

This series of posts presents an approach to OOAD that I have developed over the course of my career. It is by no means the only way of doing OOAD, nor do I even claim it to be the best. What I can tell you is that it has worked and the results have been consistent.

Entry Filed under: Software Development

Trackbacks

3 Comments Add your own

  • 1. Sonjaya Tandon » OO&hellip  |  January 31st, 2007 at 9:50 am

    […] OOAD 101 Lesson 1: What is an object and what is object-oriented? […]

  • 2. Sonjaya Tandon » OO&hellip  |  January 31st, 2007 at 9:50 am

    […] OOAD 101 Lesson 1: What is an object and what is object-oriented? […]

  • 3. Sonjaya Tandon » OO&hellip  |  January 31st, 2007 at 9:51 am

    […] OOAD 101 Lesson 1: What is an object and what is object-oriented? […]

Leave a Comment

You must be logged in to post a comment.

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

April 2006
M T W T F S S
    May »
 12
3456789
10111213141516
17181920212223
24252627282930

Most Recent Posts