Object Oriented Programming – Objects and Classes

Object Oriented Programming(OOP) is a paradigm used to develop software.  It is a modeling technique that is not bound to a particular programming language.  For example, C++, Java, C# support the concept of OOP.  Where as the C Language is better suited to procedure-oriented programming techniques.

Objects and Classes

OOP takes the approach to model software similar to objects in real life. Objects form this base entity which has both state and behavior.  For example a person, or a house, or a chair all represent an object.  With the OOP paradigm we can translate objects into code.   Lets take the example of a Person as an Object.  A Person will have certain attributes such as a name, hair color,  height  which form the state of the Person.  In code these would be variables or fields.  Taking the example further a Person could be singing or running, which would be examples of certain behaviors.  In code these would be methods or functions that operate on the object and its data.

A class in an instance of an object.  So for example, “Chris Brown” is an instance of a Person.  A better way to understand this is that an object is the blueprint and the class in a specific object created from that blueprint.

Good Design

A class should not be thought of simply as a collection of methods and data bound together.  Rather a class should be designed to be simple and convey a single very clear purpose.  Many poorly designed classes become bolstered with far too many methods make the object hard to maintain and understand.  If you find your object interface has become very large it would be a good idea to re-factor your interface.  In the past where I worked some of our best programmers attempted to keep the object interface small enough to fit on a single screen.  Don’t just just change your font to size 6, or increase you display resolution.  That’s cheating.

A well designed object/class is the basis of good design and will help to reduce bugs not to mention help greatly in finding bugs.

Advertisements
This entry was posted in Development. Bookmark the permalink.

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