Data Structures & Algorithms: Chapter 1: Overview
Data Structures & Algorithms: Chapter 1: Overview
Algorithms
Chapter 1: Overview
Not all data storage structures are used to store real-world data.
Typically, real-world data is accessed more or less directly by a
program’s user.
Some data storage structures, however, are not meant to be
accessed by the user, but by the program itself.
A programmer uses such structures as tools to facilitate some other
operation.
7 Real-World Modeling
Object
The idea of objects arose in the programming community as a
solution to the problems with procedural languages.
An object contains both methods and variables.
Classes
A class is a specification—a blueprint—for one or more objects.
Constructors
a constructor, which is a special method that’s called
automatically whenever a new object is created.
A constructor always has exactly the same name as the class
12 Object-Oriented Programming
Inheritance
Inheritance is the creation of one class, called the extended or derived class,
from another class called the base class.
The extended class has all the features of the base class, plus some additional
features.
For example, a secretary class might be derived from a more general employee
class and include a field called typingSpeed that the employee class lacked.
Polymorphism
Polymorphism involves treating objects of different classes in the same way. For
polymorphism to work, these different classes must be derived from the same
base class.
For example, a call to display() for a secretary object would invoke a display
method in the secretary class, while the exact same call for a manager object
would invoke a different display method in the manager class.
13 Software Engineering