Skip to content

The Three Fundamental Principles

December 15, 2010

These three fundamental principles of programming are: Encapsulation, Inheritance and Polymorphism

Let’s take them one by one.

Encapsulation.

  • is the ability of an object to be a container (or capsule) for related properties (ie. data variables) and methods (ie. functions)

A useful consequence of encapsulation is data hiding: which can be quickly described as the ability of objects to shield variables from external access (think about private properties available from external view thru their getters and setters).

Inheritance

  • is the capability of a class to use the properties and methods of another class while adding its own functionality (eg: extends word in Java)

Polymorphism

  • is the capability of an action or method to do different things based on the object that it is acting upon.

There are 3 types of polymorphism:

  1. Overloaded methods: methods with the same name signature but either a different number of parameters or different types in the parameter list
  2. Overridden methods: are methods that are redefined within an inherited subclass. They have the same name, return type, and arguments as the methods in its superclass.
  3. Dynamic (or late) method binding is the ability of a program to resolve references to subclass methods at runtime.

Bear in mind: You should not tell anybody you are a programmer if you do not know and use these principles.

Advertisements
Leave a Comment

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

%d bloggers like this: