Sunday, February 1, 2009

Why do we need Abstraction

Welcome back to Java Code Online. Abstraction is one of the basic and most important Principle of OOPS and of Java itself. I have discussed Abstraction in my earlier post, and I have made this clear that how Abstraction is important for OOPS to function properly.

In this article I will discuss, the basic advantage that a programmer gets by using Abstraction while coding in Java. Abstraction in itself has many advantage. They are:-

1. Abstraction make your code readable. Since the code is structured and is Object Oriented, you define a hierarchy. So your code becomes more readable for the viewer and is better t understand.

2. Abstraction makes your code small. Since you abstract out the common things from a class, you need not write that same code again and again. So it implies less coding for applications when you extend your code.

3. By using Abstraction, it becomes much more easier to maintain the code then otherwise. In Java or any other language which is based on OOPS, Abstraction helps to structure your code and hence it helps to make the code easy and easier to maintain. Whenever you need to change or modify something, you know where in the structure you need to make the change. Indeed a happy life for the developer.

4.Abstraction helps to generalize your code. Since you have already abstracted the common code, you may easily generalize your code by extending the Abstract class.

5. Abstraction matches with the practical world and is therefore easier to code and maintain. Abstraction is based on the Principle of OOPS and is thus Object oriented, it is built with the practical world in mind. Here whenever you start something, you always start with an Abstract idea and then you extend it. In Java coding also the same thing occurs. Abstraction is just the abstract of the main thing.

I hope the article helped you understand the requirement of Abstraction. If you liked the article then do leave a comment. For more info on Java, keep buzzing Java Code Online.

2 comments:

  1. I would like to exchange link with your blog.if you are ok to exchange link please post comment on my blog.

    Regards,
    Javapeople
    http://javapeople.blogspot.com/

    ReplyDelete
  2. nice explaination for why to use abstraction....

    ReplyDelete

Note: Only a member of this blog may post a comment.