Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views28 pages

2 - Intro To Object-Object Oriented Paradigm

The document provides an overview of programming paradigms, focusing on Object-Oriented Programming (OOP). It explains that OOP models real-world objects with attributes and methods, allowing for complex system simulations and interactions. Additionally, it distinguishes between programming paradigms and programming languages, highlighting the philosophical underpinnings of OOP and its complexity compared to procedural programming.

Uploaded by

raphaelvicuna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views28 pages

2 - Intro To Object-Object Oriented Paradigm

The document provides an overview of programming paradigms, focusing on Object-Oriented Programming (OOP). It explains that OOP models real-world objects with attributes and methods, allowing for complex system simulations and interactions. Additionally, it distinguishes between programming paradigms and programming languages, highlighting the philosophical underpinnings of OOP and its complexity compared to procedural programming.

Uploaded by

raphaelvicuna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

The Object-Oriented

Paradigm

CCPROG3 – AY2223T3 – ETighe


Outline
• Overview of Programming Paradigms
• Basic Concepts of OOP
Looking back…

• Let’s look back at what you’ve (hopefully) learned so far...

CCPROG1 CCPROG2 CCPROG3


Programming Basics and Logic Structured Data Object Orientation

■ Variables ■ Arrays ■ Objects


■ Functions ■ Strings ■ Classes
■ Conditionals ■ Structures ■ Relationships
■ Loops ■ Files

Slides c/o Ms. Candy Espulgar


So… what do we understand
when we hear the phrase
programming paradigm?
Programming Paradigm
• Is a fundamental style of programming
• Answers the question…
“How do I think about and solve a problem?”
• Programming paradigms are different from
programming languages

Anyone care to differentiate the two?


Programming Paradigm vs Programming Language
Programming Paradigm Programming Language
• Influences programming • Is influenced by a
languages programming paradigm
• Serves as the philosophy • Can be influenced by
behind a programming multiple paradigms
language • Need not apply all the
• Gives the rationale behind “philosophies” of the
the programming language paradigms that influences it
What are some examples of
programming paradigms?
Programming paradigms
• Some examples of programming paradigms include:
• Procedural Programming
• Functional Programming
• Object-Oriented Programming
• Logical Programming
Programming paradigms
• Some examples of programming paradigms include:
• Procedural Programming
• Functional Programming
• Object-Oriented Programming
• Logical Programming
What’s your understanding of
procedural programming?
Procedural Programming
int main() { int blah(int blah) { int main() { struct ba { Command or
code…; code…; code…; code…; instruction driven
code…; code…; code…; code…;
code…; code…; blah(1); }
code…; return blah; code…; Commands can be
code…; } code…; generalized to
code…; code…;
Organized code functions
code…;
Reusability / Modularity code…;
code…; blah(2);
code…; code…; Functions and
code…; code…; structures also
code…; code…;
code…; code…;
provide the idea of
code…; code…; abstraction
code…; code…;
code…; code…;
Data can more often
code…; return 0;
code…; } be accessed anywhere
code…; within the program
code…;
code…;
return 0;
}
What about object-oriented
programming?
Object-Oriented Programming
Main Code
Square square = new Square(5);
square.setSideLength(4)
What characteristics would a square square.getArea() // returns 16
typical have? What’s happening?
-sideLength public class Square {
-area private int sideLength;
I’m a square! What might you want a square to do?
private int area;

J +getSideLength() public Square(int sideLength) {


+setSideLength() this.sideLength = sideLength;
+getArea() this.area = sideLength * sideLength;
}

public int getSideLength() {


return this.SideLength;
}

// and so on…
}
Object-Oriented Programming
• Real-world objects are treated as entities that…
• can be composed of variables (attributes), and
• can perform some action (methods)
• Allows for objects to interact with each other within an
environment
• Highly encourages generalization and abstraction
Object-Oriented Programming
• Provides for more complex programming features
• Granting you greater control over…
• how data is stored or grouped,
• how processes are executed, and
• where each process originates from
• With more complexity comes more responsibilities
• Greater effort is expected from the programmer

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming
• Keep in mind, OOP isn’t entirely new – there are just
new ways to view creating solutions
• More complex programming concepts are built on top
of simpler programming concepts

PROCEDURES FUNCTIONS STRUCTURES OBJECTS

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming
• However, don’t be afraid!
• The added complexity allows for the simulation of more
complex systems
• Also allows for the solving large scale problems
through representations, behaviors, and relationships

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming
Modelling complex relationships become possible

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming
Modelling complex relationships become possible

SUN
If a Plant feeds on
my Sunlight, it will
grow()

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming
Modelling complex relationships become possible

SUN
If a Plant feeds on
my Sunlight, it will
grow()

PLANT
If I feed on
Sunlight, I will
grow()

Slides c/o Ms. Candy Espulgar


If we imagine a Plant
can feed on Sunlight
and grow

Then we could design an OO solution such that…

Plant plant = new Plant();


Sunlight sunlight = new Sunlight();
plant.feed(sunlight);
Where the method feed affects the Plant object in some manner

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming
• Classes
• Is a template or blueprint from which instances of objects
may be created (via a process called instantiation)
• Objects
• Each object is an instance of a class (i.e. distinct)
• Has its own copy of attributes (i.e. the actual values)
• Can act in the way the class was designed

Slides c/o Ms. Candy Espulgar


Object-Oriented Programming

INSTANTIATION

OWL CLASS OWL OBJECTS

We’ll discuss more on these concepts when


we officially tackle Classes and Objects

Slides c/o Ms. Candy Espulgar


Any questions so far?
In your own words, how
would you differentiate
procedural from OO
programming?
Summary
• A programming paradigm is a style or philosophy of
programming
• The Object-Oriented Paradigm…
• Encourages for the modeling of real-world objects
• Provides more complex programming features, which
entails that OO solutions can…
• Better model complex systems
• Be more complex to build
Summary
• Objects…
• have characteristics (attributes) and can perform actions
(methods)
• Are distinct from other objects and are based on classes,
which act like templates
-fin-

You might also like