









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to inheritance and polymorphism in object-oriented programming. It explains how objects are grouped into categories and hierarchies, and how inheritance allows new classes to be created by specifying the differences between the new class and a pre-existing more general class. Polymorphism is discussed as the capability of objects to respond differently to the same method call based on their specific class. The document also touches upon the concepts of aggregation, behavior, messages, and the relationship between object-oriented programming and abstract data types.
Typology: Essays (high school)
Uploaded on 03/03/2022
8 documents
1 / 15
This page cannot be seen from the preview
Don't miss anything!










We live in a world that can be considered to be comprised of countless objects, but how do we think about objects? Do we treat each one on an individual basis? No, we tend to group objects into categories and in turn these form a hierarchy. For example consider a book. Lots of objects can be grouped together and called book objects. Computer books, school books etc are all different types of books which can all be described as books. A book is also part of a more general group called publications, in addition to books, publications include scientific journals, newspapers, comics, magazines etc. Books have certain attributes or properties that are shared by all books: They have a cover, chapters, no advertising, and so on. They also have attributes shared by publications in general: a title, a date of publication, a publisher, etc. They have attributes that are shared by all physical objects: a location, size, shape, and weight. This idea of shared attributes is very important in OOP. OOP models the concept of shared attributes using inheritance
Object hierarchies arrange objects in such a way that general objects are at the top and specialised objects are at the bottom. Considering objects in this way it is soon noticed that objects share properties and methods. Inheritance supports this hierarchical-shared view by allowing new classes (of objects) to be created simply by specifying the differences between the new class and a pre-existing more general class. In object-speak the new specialised class, termed the descendant class, is said to be inherited from the pre-existing more general class termed the ancestor class. In simple terms inheritance means that descendant classes automatically get the properties and methods of the ancestor class. The primary advantage of inheritance is that we can reuse the properties and methods of pre-existing classes. Reuse is an important concept in software engineering because tried and tested ancestor classes provide a solid foundation for future projects which can proceed rapidly and with confidence. Another powerful advantage of inheritance is that modifications applied to methods in ancestor classes are automatically applied to all inheriting classes. This greatly simplifies software maintenance.
◼ Inheritance specifies an “is-a-kind-of” relationship ◼ Multiple classes share the same attributes and operations, allowing efficient code reuse ◼ Examples: ⚫ A customer “is a kind of” person ⚫ An employee “is a kind of” person Customer Employee Person Base Class Derived Classes
The surgeon would begin to make an incision. The hair stylist would begin to cut someone’s hair. The actor would abruptly stop acting out the current scene, awaiting directorial guidance.
13 A car has wheels.
14
So, C++ is more powerful but also more difficult to handle than Java/C#.
OBJECT-ORIENTED PROGRAMMING Each object is responsible to initialize and destroy itself correctly. Consequently, there is no longer the need to explicitly call a creation or termination procedure. KAY’S DESCRIPTION OF OOP Everything is an object Objects perform computation by making requests of each other through the passing of messages Every object has it's own memory, which consists of other objects. Every object is an instance of a class. A class groups similar objects. The class is the repository for behavior associated with an object Classes are organized into singly-rooted tree structure, called an inheritance hierarchy.
ADT AND OBJECT-ORIENTATION
ADT AND OBJECT-ORIENTATION(2) ADTs define functionality by putting main emphasis on the involved data, their structure, operations as well as axioms and preconditions. Object-oriented programming is ``programming with ADTs'': combining functionality of different ADTs to solve a problem. Therefore instances (objects) of ADTs (classes) are dynamically created, destroyed and used.
PROGRAMMING IN THE SMALL AND PROGRAMMING IN THE LARGE Programming in the Small: One programmer, understands everything from top to bottom. Major problem is the development of algorithms. Programming in the Large: System is developed by large team of programmers Major problems are management of details and communication between programmers and between their respective software subsystems. OBJECTS AND LARGE SOFTWARE SYSTEMS(2)
▪ Makes systems more intuitively understandable ▪ Unifies design and programming method ▪ Initial program thoughts are informal objects-and-interactions descriptions, even when using a non-OO language. ▪ Divides code into logical chunks individuals of a team can be experts in, and outsiders can understand via interfaces ▪ Allows "off the shelf" code libraries to be reused ▪ Supports code evolution: internals can always be re-written as long as interface stays the same