Archive for Coding

Understanding ‘Abstraction’

In the beginning there was Abstraction. And the abstraction was God (of OO). And God of abstraction said let there be Classes and there were Objects

– Book of Genesis – OO Bible

Abstraction is very important concept in OO. Understanding Abstraction is crucial in becoming a successful OO designer. Abstraction cannot be understood by reading books (which deal with it in Abstract terms turning it into a sort of mystery). Like Morpheus said to Neo in Matrix, You need to experience it yourself.

Roughly stated, Abstraction is the process of discovering classes, their responsibilties [the services they provide, the functions they implement] and how these classes interact [co-ordination] with others to complete the big picture [implement the system].

Continuing with our 'File System' example [easy to understand], it's easier to find Files, without using 'Search', if the directories are given meaningful names. Files an directories [ class/functions] are easier to find if the names are short and easier to remember.

It's easier deduce what files 'My Photos' directory contains, than the one named 'RoboXYZ12T45G'.File system [programming language] will not prevent a file 'hardrock.mp3' from being created under 'My Photos'. It's the users [programmer] resposibility to organize files [functions] under the right directory [class] based on purpose [responsibilty] of that directory [class]. To summarize, meaningful and easy to remember names ought to be given based on the purpose served.

Read the rest of this entry »

Leave a Comment

Coding Forward

Every programmer is aware of the language war that has been brewing of-late; unless he/she has been living in a swamp far away from civilization. Java's overwhelming dominance over other programming languages is under serious threat; and even the most vocal Java advocates understand it though reluctant to admit in public.

First salvo was fired by Microsoft with the introduction of C# , .NET SDK and by allowing scripting languages as first-class citizens under .NET runtime, a privilige long denied to them under JVM thanks to SUN's limiting NBH (Not built here) vision. C# not only emulated Java's most successful features, but also came up with several handy features like Autoboxing/Unboxing, Explicit interface implementation, properties, variable arguments, friendly-for-loop and so on. SUN, which had been reluctant to add these much demanded features (by programmers), was finally forced to add these features with Java 5. The hurried introduction of 'genericity' before it's C# advent is a sign that Sun takes the threat seriously.

On the other hand, dynamic languages have grown in popularity, thanks to the success of PHP and newer OO languages like Ruby and Python. Though more focussed on Web development, the collective mindshare developed is significant, and considering most apps developed these days are indeed web apps, they indeed pose a serious threat to Java's dominance over server-based programming.

Read the rest of this entry »

Leave a Comment

Handling ‘deprecation’

A post by Bill Venners, comparing the way Python and Java handle deprecation, caught my attention while surfing java.net . While Java prefers the Warn-and-forget way, Python takes the other extreme of removing old features altogether. Bill discusses the pros and cons of each method i.e – lean and clean libraries vs. backward compatibility.

Personally, I would prefer Java followed the Python way; allowing older features to co-exist through minor revisions ( like 2.x versions) and remove them with the next major revision (like 3.0). IMO deciding to take the leap (migrate) to next major version of a library, framework or platform is a non-trivial decision, considering the large number of feature changes involved. And that's what major revisions are for!

Read the rest of this entry »

Leave a Comment

OOPS is Procedural too!

All the OOPS vs. Procedural programming might mislead you to believe that OOP is totally unrelated to POP. That's not entirely true.

The confusion is further confounded by OOAD books that teach in abstract as in 'In procedural programming functions call functions. In OOP Objects pass messages to other objects'. What  this really means is Objects call functions defined within their own class or in other classes! Read the rest of this entry »

Leave a Comment

Object Oriented Madness -II

My last post dealt with reasons why OOPS is misunderstood by a number of programmers. Having dealt with the cause, lets cover the effects.

Myth I : OOP is all about re-usability.

Fact : You don't need OOP to write Re-usable code. Good coding practices result in re-usability (OOP or not). OOP is all about managing complexity.

Read the rest of this entry »

Comments (3)

Object Oriented Madness – I

Most of the popular computer languages these days like Java, C#, C++, Ruby etc. are Object-Oriented. That means you can code a system in terms of Classes and Objects. Classes serve as the blue-prints that define what an object of that class knows, what services it provides and how those services are implemented. Objects are instances of a class that actually do (most of) the real work.

Actually Object-Orientation is a very simple programming paradigm, once you come to grasp it. So it should be really simple to learn and master OOP. However, in reality, things are not that peachy. Unfortunately, most of the widely available so-called 'Object Oriented Analysis And Design' (OOAD) are either utterly useless in understanding it, or make it appear like complicated rocket science through liberal zargon-dropping. Read the rest of this entry »

Comments (3)