Object Oriented Programming is a way of programming where you create a represtation of real world in the computer's memory by creating Objects and establishing relationships between them. To create Objects, you need to create Classes first.
Some of the definitions i came across are like:
Simple definition: Object-oriented programming (OOP) is programming using "objects" to develop computer programs.
Another definition: Object-oriented programming (OOP) is a method of programming based on well-defined and cooperating objects.
Yet another definition: Object-oriented programming (OOP) refers to a programming methodology based on objects, instead of just functions and procedures.
One more definition: Computer program as a combination of data structures (called objects)
In a program, you create an object for every thing in the real world and establish relationships between them. Hence you recreate the world in Computer's memory. How the relationship is established between objects is shown below using two diagrams. Lets say, you are creating a software for running a University. You will create an Object of University Class, Five Objects of Department Class if there are five departments in the University. 25 Objects of Professor Class if there are 25 professors in the University (Lets say 5 professors per department,) 20 Semester Objects if there are four semesters per department, 600 Student Objects if there are 30 students per semester.
After creating the Objects now we need to establish relation ships between them. How do we do that ? There are only two kinds of relations possible in Java. "Is A" and "Has A". Their meaning in Java is very literal. Like, An apple "Is A" fruit and An apple "Has A" seed (actually has lot of seeds). Also like, An Orange "Is A" fruit. The "Is A" relation is established between two classes by means of Inheritance (using extends keyword). The "Has A" relation is established between two classes by means of Association (using fields).
Note: Each Object has details about the thing in the real world. Like Professor Object will have details like, the professor's name, age, speciality, etc... and a Department Object will have details like name of the department, name of the department head, etc...
Now lets establish relationships between Objects. Following shows the application of "Has A" relation. So a University Object will contain five Objects of Department class. Each Department Object will contain five Objects of Professor Class and four Objects of Semester class. Each Object of Semester will contain 30 Objects of Student Class. Each of the above objects will also have other appropriate fields to store details like University Name, Department Name, Profesor's name, age, speicality, Student's name, age, semester number etc.... It feels like assembling of Objects. And, that's what it is.
Note: If anything is confusing in this article you can email info@ javasprint.com . This article will get updated. Learn and help learn.
Note: I did not talk much about the methods but never mind. Its more imporntant to get clear with how the data is structured. I would like to say one thing though. There will be appropriate method in every Class. Like say "setHeadOf Department (String newHead)" method in Department Class, or "incrementAge()" method in Person Class. You call methods of a Class on its Objects.
Object Oriented Programming (OOP) is programming an application program in an Object Oriented way. Here everything is an Object. A memory full of Objects with relationships between them. You think in terms of Objects, you design in terms of Objects, you program in terms of Objects. Is it possible to create the above program with out using Object Oriented Design and Programming ? Yes, its possible to create the above program WITHOUT using Object Oriented Design and Programming. But the problem is that such a program will be difficult to maintain after it has been released. Such a program will be difficult to enhance with new features in the future.
So, What if you have been working in COBOL for a lot of years ? Or What if you were a Manager for a lot of years and hence never tried to code your self. Or What if you enjoyed being a House Wife for so many years and since your kids have now grown up and left to be on their own, you want to learn Object Oriented Programming now. Object Oriented Programming is not rocket science, it is simply as described above.
We have a small 14 hour course, Which focusses only on the very core concepts of the Core Java including Object Oriented Programming (OOP). Its designed to make one very independent. You do hands on coding through out the course. A tutor is with you all the time. You get 100% attention as it is one on one. Write down a paragraph on how you feel about Java and how much you know about Java before you take up the java training course (if you take it up). Write down another paragraph after you finish the java training course. Then read what you wrote before taking the java training course. You will know.
Note: Interfaces are important as well. They give flexibility to your program. They too give "Is A" relationship. They allow multiple Inheritance in Java as otherwise you can only inherit from a single class.
Note: If anything is confusing in this article feel free to email me at info@ javasprint.com . This article will get updated. Learn and help learn.Author: Bharat Chhajer