UPI Study › Courses › Software Engineering › Free lessons › Lesson 1.5 Free with a free account
Designing with Objects: The OOAD Approach
Software Engineering · Chapter 1: Foundations of Software Engineering and Process ModelsSection 1.5 · lesson 5 of 1037 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Software Engineering.
Lesson complete
Earn the 3 college credits for Software Engineering
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Proven Steps and Guidelines for Building Quality Software →← Analyzing Systems Within the Software Engineering WorkflowNext lesson: Proven Steps and Guidelines for Building Quality Software →
In this lesson
The OOAD approach: objects, classes, encapsulation, inheritance, and polymorphism.
- Explain why the object-oriented paradigm emerged
- Define an object, and how a class acts as its blueprint
- Describe encapsulation, and why protecting state matters
- Explain inheritance and polymorphism with concrete examples
Transcript
Everything said in the video, section by section (1,016 words). Read along, or search it.
Foundations of Software Engineering and Process Models
Designing with Objects
As software grew from hundreds of instructions to millions, one way of organizing it kept breaking down. This section introduces the approach that replaced it, object-oriented analysis and design, or O O A D. Its core ideas are objects, classes, encapsulation, inheritance, and polymorphism.
Why It Emerged
Code Here, Data There
Picture a payroll system built the traditional way. One giant list of steps reads an employee record, calculates pay, applies deductions, and prints a check, acting on data sitting somewhere else. Now add overtime rules, part-time employees, contractors, and bonuses. Every new rule means editing that same long sequence. This procedural style kept data structures and procedures apart, and at scale, two problems kept recurring. Bugs were hard to trace, because any procedure anywhere could modify shared data. Every one of them was a suspect. And reuse was hard, because behavior lived apart from its data, and had to be untangled before it could be used elsewhere. O O A D responded by organizing software around objects, self-contained units that bundle their own data with their own behavior, the way real things work. A car does not exist as a pile of parts beside a separate manual of driving instructions. The car and its behavior belong together.
Objects
State and Behavior, Together
An object combines two things. State is the data describing it at a given moment, also called attributes. A bank account holds an account number, and a current balance. Behavior is the actions it can perform, also called methods. The account can accept a deposit, allow a withdrawal, and report its balance. Anyone using the object works through its behavior. They do not need to know how it is implemented inside. This mirrors the real world. A thermostat has a target temperature, and a dial that raises or lowers it. You would never think of the dial as existing apart from the setting it controls. Software objects keep related data and logic together the same way.
Classes
One Blueprint, Many Objects
Every object is created from a class. A class defines what attributes and methods its objects will have, without itself being an object. A class is a blueprint. An object built from it is called an instance. A single car class might give every car a color, a speed, and a fuel level, with methods to accelerate, brake, and refuel. Three car objects created from it are three independent instances. Each holds its own values, while sharing the same methods. This is why the paradigm scales. Improve the accelerate method once, in the class, and every car object ever created gets the improvement.
Encapsulation
Protecting Internal State
Encapsulation means keeping an object's internal state hidden, and exposing only a controlled set of methods to view or change it. A bank account object does not let outside code overwrite its balance directly. Instead it offers deposit and withdraw methods, and each can enforce rules, such as refusing a withdrawal that would overdraw the account. Someone might say encapsulation just hides code for no reason. It does much more. If the balance is wrong, the search for the cause is narrowed to the account's own methods. Not every piece of code in the whole system that happens to touch account data.
Figure 1.5(b)
Inheritance and Polymorphism
Here is inheritance and polymorphism in one picture. At the top is the vehicle class, with a speed attribute and a move method. Car and boat each inherit from vehicle. The hollow triangle arrow means is a kind of. Both automatically receive the speed attribute, without redefining it. But each overrides move with its own behavior. A car drives, and a boat sails.
Inheritance
Building on an Existing Class
Inheritance lets a new class be defined in terms of an existing one. The existing class is the parent, or base, class. The new one is the child, or derived, class. The child automatically receives the parent's attributes and methods, rather than rewriting them from scratch. Inheritance captures real is-a relationships. A car is a vehicle, and a boat is a vehicle. The logic every vehicle shares lives once, in the vehicle class, instead of being duplicated in each.
Polymorphism
One Interface, Many Behaviors
Polymorphism means the same method name can trigger different behavior, depending on which object it is called on. Call move on a car object, and it drives. Call the very same move on a boat object, and it sails. The calling code does not need to check which type of vehicle it has. It simply calls move, and the right behavior runs. Together, inheritance and polymorphism let a system grow. Add an airplane class later, with its own move method, and code that already works with vehicles works with airplanes too, without being changed.
Table 1.5
The 5 Core Ideas at a Glance
Here are the five core ideas side by side. An object is data and behavior as one unit, like one specific car in a parking lot. A class is the blueprint an object is built from, like the manufacturer's design specification. Encapsulation hides internal state behind controlled methods, like a car's dashboard controls, rather than its wiring. Inheritance reuses an existing design. A convertible is a specific kind of car. And polymorphism is the same action behaving differently per object. Start works differently on a car and on a boat.
Key Terms
The Vocabulary of This Section
Let's lock in the key terms. An object is a self-contained unit that bundles its own state together with its own behavior. A class is a blueprint that defines an object's attributes and methods. An instance is one specific object created from it. Encapsulation hides an object's internal state, exposing only controlled methods. Inheritance lets a new class reuse the attributes and methods of an existing class. And polymorphism lets the same method name produce different behavior, depending on the object.
Key Takeaways
What to Carry Forward
To pull this together. O O A D emerged because keeping data apart from the procedures that act on it, became unmanageable as systems grew. An object bundles state and behavior, and a class is the blueprint from which many independent instances are made. Encapsulation hides state behind controlled methods, limiting where it can be changed. Inheritance reuses an existing class's design, and polymorphism lets one method name behave differently per object. Together, they let a system add new types, without changing the code that already works.
About Software Engineering at UPI Study
Software Engineering (Computer Science 301) is a self-paced online course of 103 video lessons in 15 chapters, from process models and agile to requirements, design, user interfaces, reliability, security and project management. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Why take it here
Why students take Software Engineering with UPI Study
Where the credit goes
Universities that work with NCCRS
Software Engineering carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Designing with Objects: The OOAD Approach
What is the difference between a class and an object?
What is encapsulation in object-oriented design?
What is the difference between inheritance and polymorphism?
Why was object-oriented analysis and design developed?
About the Software Engineering course
How many college credits is Software Engineering?
How much does Software Engineering cost and what is included?
Which universities accept UPI Study credits?
How long does Software Engineering take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Software Engineering.
103 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
3 credits · NCCRSEnroll →