Transcript Notes on Sections 2.1-
Object-Oriented Languages
Computer Technology Series Gerb Objectives: Understand object-oriented languages and their history
Object-Oriented Languages
• Through the 1970s and 1980s, software engineers became concerned with reuse – Developing software is expensive – Reusing an existing piece of software was more expensive that starting from scratch • 3 computer scientists, Booch, Rumbaugh, and Jacobson championed Object-Oriented Languages as a way to improve reuse.
– A program no longer a set of instructions – Describes objects and what you can do to them
Object-Oriented Languages Cont’d
• • Today nearly all serious development is OO.
Three Features of OO Languages
– – –
Encapsulation
- Details of objects can be hidden from the users of the objects
Polymorphism
- The same operation can have different effects on different types of objects.
Inheritance
- An object can be created which has all the characteristics of an existing object to which new characteristics can be added.
Early Object-Oriented Languages • Smalltalk
– Earliest OO Language – Not a commercial Success
• C++
– Created in 1980s by AT&T employee Bjarne Stroustrup – An addition onto the C programming language – Became the most popular OO language
How Object-Oriented Languages Work
• Programmer defines
classes
– A type of object – Program creates
instances
, examples of that type of object • Each instance has information that makes it different from other instances – In C++ called members of the class – In Java called instance variables – In other OO languages, called attributes • Class provides methods that work with instance data – Observers give information about the instance. (AKA accessors) – Modifiers change instance data – In C++, methods are called member functions
How Object-Oriented Languages Work (cont’d)
• Classes can have private instance variables only usable within the class – Public instance variables visible to the rest of the program – This ability is called
encapsulation
• Can create a class which has all the methods and instance variables of the parent class – Called a subclass – Original class is called the superclass – We say the subclass
extends
the superclass – This process is called
inheritance
• Subclasses can have their own version of methods in the superclass – Called specializing these methods – Language knows to call the specialized version – Called
polymorphism