Moving from imperative programming to object orientation
By Rochester Oliveira
The best software developers know that even the most complex programming puzzles eventually get broken down into simple iterative statements and conditional pieces of logic that can be performed by any imperative programming language. But the beauty of a language like Java is that it is much more than simply an imperative programming model. Java is object oriented, and to make the most of the language, a software developer must move beyond the imperative programming paradigm and embrace object orientation. And to become an effective object-oriented application developer, one must understand the following triad of concepts that comprises the basic of all object orientation in Java.
Encapsulation is the main principle of object oriented programming. The Java classes programmers create should be though of as being a thin skin that defines the borders of an object. Encapsulating variables by only allowing them to be accessed through setters and getters, allows software developers to inhibit direct access to attributes and shield developers from using an object based on the implementation.
Inheritance allows code to be written in one place, but used by a variety of other classes with whom the parent class shares an is-a relationship. When used properly, code is consolidated in the parent class, allowing modifications in this one central place to immediately take impact and trickle down to all subclasses.
Polymorphism can be defined as the fact that in a hierarchy of classes, the subclasses will behave like their parents, unless the parent's behavior is directly overridden. Polymorphism creates a condition across an entire object oriented system where when a given component or class is needed, any child or subclass of that component will do, making programs highly pluggable and flexible.
Every programming language is built upon imperative programming basics, but to really excel at and master Java, developers need to be grounded in object oriented concepts, and the key to understanding object orientation is mastering the concepts of encapsulation, inheritance and polymorphism.
Do you find it a challenge mastering object orientation?Let us knowhow you mastered the concepts of inheritance, encapsulation and polymorphism.
06 Apr 2013
Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.