ifacethoughts

OOP, Syntax And Keywords

Some articles that I read about OOP give me a feeling that the dark side arguments are mostly based on the syntax and keywords of the programming languages. The pros and cons of various languages like C++, Java, Lisp creep in while discussing it. Because of this OOP comes out as a rigid set of todos, that in fact have been imposed because of the language.

I think it is worthwhile to look at OOP purely as a concept, an approach for not only coming up with the right solution, but also to understand the problem. Unfortunately (or maybe fortunately) OOP is not promoted by any single organization, so everyone is free to elaborate and apply it the way they want. However, I want to take an exception when the elaboration consists the programming language features. So, I present my understanding of OOP as a way of thinking.

  • It helps us identify not only what to do, but who does what. It not only identifies the functionalities, but also the entities which do it and converting them to responsibilities. Responsibilities have a tone of ownership as against supposed to do functions.
  • Encapsulation helps us in hiding unncessary information from others. Not doing this can lead to information overload for others and/or exposing something that is to be protected from others.
  • Abstraction can help in understanding a complex transaction or communication. It does not reduce the actual complexity, but lets us simplify by breaking things down.
  • Abstraction also helps us in separating the what from the how. A lot of times, the part that interacts with others is the what. In such cases others are not affected when the how changes. Abstraction lets us specify to others what to expect. Separating the what and the how can ease communication with others. This is what I have used to understand by what an interface means.
  • I consider Inheritance and Polymorphism to be more related to ease in maintenance of the software rather than ease in designing. Not to say that they are not important, but every programmer can have his own preference whether they are useful or not.
  • For me, the heart of OOP is the set of Class Design Principles. Note that by class I do not mean the keyword class, it is something that you use to represent the identity. Feel free to rename it as you want.

I do not think OOP requires specific keywords or syntax. It is more about designing than coding. I firmly believe that OOP can be followed in any programming language. I love the way Drupal employs it.

The above points can be applied in many scenarios that we identify with certain popular ideas today. Plugins, as a way of extending functionality, is popular, but should the plugin authors be limited to what they can access? What if Mozilla Firefox extension authors could modify the rendering engine which affected how a website was displayed! OOP can help us identify this better.

Inheritance and Polymorphism can be used effectively to ease maintenance of the code. However, they should be used for reusability of code. If they work against it then it is quite possible that they are not being applied correctly. Class design is something that an impact Inheritance design a lot. By experience, using less is more paradigm in class design has helped me in applying Inheritance better.

Having said this I also believe that it might not be suitable for all projects. Any selection that we do depends on a variety of factors involved and there is no one-size-fits-all solution. I use OOP to understand and model the problem. And I think that is its biggest benefit. This is not to say that this cannot be done in other programming methodologies, but OOP makes it easier.

To end, we can use OOP if we apply it conceptually rather than as a strict list of todos. And as a concept, it is not dependent on the implementation and hence the language. The real world is full of different beings and interaction between them. OOP makes it more obvious to identify both of them which helps us in automating the real world better.

Discussion [Participate or Link]

  1. Madhur Kapoor said:

    Well Said Abhijit
    OOP can very well be employed for designing a problem and once that is done , its coding become a lot simpler independent of the language you are using .

  2. Why OOP Can Help on iface thoughts said:

    [...] world as closely as possible. The tools of abstraction and encapsulation can be used to separate what from how, in fact focus on what before thinking about how. Interface can be effectively employed to build [...]

Say your thought!

Who are you?

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
Y!: anadgouda
GTalk: anadgouda@gmail.com
MSN: anadgouda@hotmail.com
Skype: anadgouda
My bookmarks

currentproject

Complete Wellbeing

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.

Twitter - #mumbai - The city has started working today. The fears are still there, but the spirit will help in fighting it.