0% found this document useful (0 votes)
25 views

Lecture 01 Oop210

This document is the outline and slides for Lecture 1 on the fundamentals of object-oriented programming (OOP) given by Ralph Tambala at MUST. The lecture covers an introduction to OOP and classes/objects, a review of structured programming, and the core concepts of OOP including abstraction, encapsulation, inheritance, and polymorphism. Additional resources on OOP are also provided.

Uploaded by

Kutemwa Mithi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Lecture 01 Oop210

This document is the outline and slides for Lecture 1 on the fundamentals of object-oriented programming (OOP) given by Ralph Tambala at MUST. The lecture covers an introduction to OOP and classes/objects, a review of structured programming, and the core concepts of OOP including abstraction, encapsulation, inheritance, and polymorphism. Additional resources on OOP are also provided.

Uploaded by

Kutemwa Mithi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Lecture 1 - Fundamentals of OOP

Ralph Tambala

MUST . CSIT

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 1 / 14


Outline

1 Introduction to Object Technology

2 Structured Programming Review

3 Core Concepts of OOP

4 Additional Resources

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 2 / 14


Introduction to Object Technology

Introduction to Object Technology

In COMP-122, you learnt how to code procedural/structured


programs using C++. This course builds upon those concepts with a
major focus on object-oriented programming.
Object-Oriented Programming (OOP) is a programming paradigm
that relies on the concept of classes and objects.
OOP enables the programmer to represent real-world scenarios using
objects.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 3 / 14


Introduction to Object Technology

Classes and Objects


A class is a blueprint for creating objects, providing initial values for
state (member variables or attributes), and implementations of
behavior (member functions or methods).
An object is an instance of a class.

Figure 1: An example of Car class and its objects

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 4 / 14


Introduction to Object Technology

Classes and Objects cont...

An object is any entity that has states and behaviours.


States represent the attributes or data of an object.
Methods represent the behaviours of objects.

Figure 2: Dodge Charger R/T - An example object of Car class

◦ Dodge attributes – color, transmission type, max speed


◦ Dodge methods – start, stop, accelerate, change transmission

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 5 / 14


Structured Programming Review

Structured Programming Review

Structured Programming divides a program into a set of functions or


modules. Each of these functions performs a subtask.
Structured programming makes extensive use of the structured
control flow constructs of selection (if/then/else) and repetition
(while and for), block structures, and subroutines.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 6 / 14


Structured Programming Review

Structured Programming Review cont...

Figure 3: Structured programming

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 7 / 14


Structured Programming Review

Structured vs Object-Oriented

Structured OOP
Top to bottom approach Object-focused design
Moderately complex problem Very complex problem
Less data security More security
Less flexible More flexible
Less usability More usability
Less abstraction More abstraction

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 8 / 14


Core Concepts of OOP

Core Concepts of OOP

Figure 4: Fundamentals
Ralph Tambala (MUST . CSIT) Lecture 1 - of object-oriented
Fundamentals of OOP programming 9 / 14
Core Concepts of OOP

Abstraction

Abstraction is a programming methodology in which details of the


programming codes are hidden away from the user, and only the
essential things are displayed to the user.
Abstraction is concerned with ideas rather than events. Abstraction
means using simple things to represent complexity.
For example, you can browse the Internet using the web browser
without seeing the background codes (you don’t need to know how it
works in order to use it). In OOP, abstraction means simple things
like objects, classes, and variables represent more complex underlying
code and data.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 10 / 14


Core Concepts of OOP

Encapsulation

Encapsulation is the practice of keeping fields within a class private,


then providing access to them via public methods.
With encapsulation we can reuse objects like code components or
variables without allowing open access to the data system-wide.
Encapsulation helps us save a lot of time.
Here is a basic example: We may write code that retrieves particular
data from a database. The code could be reused with other databases
or processes. Encapsulation allows us to do so while maintaining the
privacy of our original data. It also allows us to make changes to our
original code without breaking it for those who have already
implemented it.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 11 / 14


Core Concepts of OOP

Inheritance

Inheritance lets programmers create new classes that share some of


the attributes of existing classes.
This lets us build on previous work without reinventing the wheel.
It works by letting a new class adopt the properties of another.
We call the inheriting class a subclass or a child class. The original
class is referred to as the parent class.
For example, after defining a Person class with name and age
attribute, we may create another class Student that extends Person
class. This means that Student class can inherit some of the
properties (name or/and age) of Person class. But also, Student can
have additional attributes of its own such as registration number.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 12 / 14


Core Concepts of OOP

Polymorphism

Polymorphism lets programmers use the same word to mean different


things in different contexts. Polymorphism can be achieved through
method overloading and method overriding.
In method overriding, the child class can use the OOP polymorphism
concept to override a method of its parent class.
In method overloading, a single method may perform different
functions depending on the context in which it’s called.
For example, if we create a class called Horse by extending the
Animal class. That class might also implement the Professional
Racing class. The Horse class is “polymorphic,” since it inherits
attributes of both the Animal and Professional Racing class.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 13 / 14


Additional Resources

Additional Resources

1 Section 1.5-1.5.9 in Java How to Program, Early Objects by Harvey


M. Deitel and Paul J. Deitel
2 Here is a good article for reference: What Are the Four Basics of
Object-Oriented Programming?
3 DYK? Dodge Charger R/T is the name of car that Vin Diesel’s
character, Dom Toretto, drives the most in The Fast & Furious
franchise.

Ralph Tambala (MUST . CSIT) Lecture 1 - Fundamentals of OOP 14 / 14

You might also like