Monday, 2 March 2015
week 7
Revisit OOP
I have heard much discussion about what Objected oriented language is before I approached computer science, but I never truly understood it. Even until know, my understanding of this concept is still quite limited, but I will try my best to demonstrate my insight of this topic. In CSC108, we mainly studied programming with respect to logic. We would write functions which takes an input and produces an output. However, what we learn in CSC148 is much different. Instead of working with functions, we begin to focus solely on working with class. I believe dealing with class marks our first experience dealing with an Object. A class is an object because it has attributes such as type and data structure, as well as many methods to perform operations on it. These attributes define what the object is, and what the object can do. Think the class ball as an example. The ball may have certain attributes such as weight, perimeter and material. These will define the basic attributes of what the ball is. It may also have methods that defines how far the ball will move when certain force is exerted on it. The attributes define what the object is, and thus allow a new object to be created. Note that in many cases a sub-class may be required to implement the main attribute, or in another word, define the object. A sub-class may also inherit the existing methods of the main class, and perform operations to define a new object. For instance, a valid sub-class of the main class ball would be ‘football’ or ‘soccer ball’.
I believe OPP is basically programming by allowing the classes(objects)/modules to interact with one another. The advantage of OPP is that the programs are made up with many different modules. The modules are often very easy to modify in case there is a mistake or need for improvement. This feature also allows the modules to be replaced in times of need without jeopardizing the entire program.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment