Tuesday, 22 February 2011

OO Revision - a blast from the past

I recently came across this object revision list, taken from Booch's Object Oriented Analysis and Design which I bought in 1995 and referencing OMT. It was written using my previous first language of C++, something I've not used in a good while. It was good to read through it after all these years, giving the critic of time, just to figure out what's changed over the years.


What do Objects do?

  • Objects manage complexity in software systems.
  • Objects allow re-usability.

 Abstraction

Objects are lumps of software in crisply defined packets that contain the traits of what they are. There are several types of abstractions. These are:

  • Entity Abstraction - the object is modelling something in the real world. This is the one that is most thought about in other techniques such as OMT.
  • Action Abstraction - the object provides a set of operations that perform the same kind of function.
  • Virtual Machine Abstraction - an object that groups together operations that are used by some superior level control, or that use a junior set of operations. An object that is a wrapper.
  • Coincidental Abstraction - A rag-bag of unrelated operations.

An object is a client if it uses another object. The other, used object, is a server.

An object has responsibilities - that is the behaviour for which it is accountable - which basically means it has to work - the methods it contains must do what the client object thinks they should do.

An operation is a member function is a method.

There are three types of method.

  • Operator overloads - that endorse the canonical form of an object allowing it to behave as a primitive data type (int, long, double etc).
  • Operations - methods that change the internal state of the object - get it to do something.
  • Selectors - methods that return some information about an object - without changing its internal state.
  • You communicate with an object by calling its methods. This is also known as sending it messages.

Encapsulation

This is the act of hiding an object’s implementation or data from the outside world. Objects have to parts.

  • The interface - a set of methods that allow the client to use the object. These are defined in the class (.h) file. The outside world uses an object via its interface.
  • The implementation - the actual internals of the object. All its data and how it works. This should never be seen be the outside world.

Modularity

Modularity is the packaging of abstractions in to discrete entities. It includes the concept of coupling. Objects should be loosely coupled - that is they should not depend upon the existence of other peer or higher level objects. Modularity allows re-use. A module can be compiled separately without the need for other modules.

Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.

Hierarchy

This is the ranking or ordering of abstractions. This covers inheritance. Inheritance can be defined using the words IS A. For example An office chair ISA chair. A dining chair ISA chair.

There are two types of inheritance - single and multiple inheritance.

Hierarchy also covers Aggregation. Aggregation is the clumping or collecting of objects together in one object. These maybe by value or be reference. In this case use the words HAS A. For example a chair HAS A leg. An office chair HAS A castor. Note: you can also use the words PART OF to describe aggregation.

Typing

Typing prevents the mixing of objects. For example you cannot say a chair equals a table. Typing is disallowing objects to be interchanged except in a few restricted ways.

Concurrency

Concurrency is abstractions acting at the same time. This may include separate processes or threads. (A process is the top-level thread of control for some program). Concurrency distinguishes an active object from an inactive one.

Persistence

The saving of objects state over time. This is usually to disk.

State

Objects have some kind of state. The state encompasses all of the object’s static properties (i.e. its class information) plus the current (usually dynamic) values of each property.

Behaviour

An object’s behaviour is how it acts and reacts in terms of its state changes and message passing.

Links

A link - from OMT - is a connection between two objects. An object may play one of three roles in a link.

  • Actor - an object that can act upon other objects but is never operated upon by other objects.
  • Server - an object that never operated upon other objects. Other objects can only operate upon it.
  • Agent - an object that is a mixture of the above. Other objects can operate upon it and It can operate upon other objects.

Scope

This is where an object lives. Global scope is bad don’t have loads of globals.

No comments: