Introduction to Object Oriented Programming

Why do we model?

In Object Oriented Programming we are trying to model either real world entities or processes and represent them in software. There are compelling reasons why we model:

Principles of Modeling

The model that we create is dependent on the problem that we are trying to solve and the entities in the scope of the problem.

Basic Principles of Object Orientation

Basic Concepts of Object Orientation

What is an Object?

An Object represents an entity either physical (box), conceptual (chemical process), or software (list).

An Object is a concept, an abstraction, a thing with sharp boundaries and meaning for an application. It has

An Object is represented as a rectangle with a underlined name in UML.

What is a Class?

A Class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semantics

A class is an abstraction. An object is an instance of a class.

Example of a Class

A class is represented by a compartmentalized rectangle in UML. It has three sections - Name, Attributes, and Operations. You can show as many or as few of the Attributes and Operations in the diagram. Most of the times for the sake of clarity the Attribute and Operation lists are suppressed.

You start from real world objects - abstract out what you do not care and go through the process of classification of what you care. A Class is the result of this classification. Classes are then used as templates within a software system to create software objects.

What is an Attribute?

An Attribute is a named property of a class. It has a type. It describes the range of values that that property may hold.

What is an Operation (Function)?

An Operation is a service that can be requested from any object of the Class to affect behavior. An Operation can either be a command or a question. A question should never change the state of the object only a command can. The outcome of the Operation depends on the current state of the object.

What is Polymorphism?

The Greek term polymorphous means "having many forms". Interfaces allow us to define polymorphism in a declarative way. Two elements (classes) are polymorphic with respect to a set of behaviors if they realize the same Interface. Interfaces allow us to build a "plug-and-play" architecture. Classes that realize the same Interface may be substituted for one another in the system, thereby changing the implementation without affecting the User.