Intro to OOP Flashcards
First OOP Language, introduced
object-oriented programming concepts
such as object, class,
etc.
SIMULA (Simulation Language)
Creators: Ole-Johann Dahl and Kristen Nygaard
Fathers of Object Technology
led a team that developed
Smalltalk at Xerox PARC
- inspired by Simula,
- Coined the term “Object
Oriented Programming”
Alan Kay
implemented “C with Classes” aka C++ - Became the most widely used OOP language
Bjarne Stroustrup
developed Java (former name is Oak)
- Simplified C++
James Gosling
4 Approaches to Software Development
Top-Down Programming
Bottom-Up Programming
Modular Programming
Structured Programming
the programmer decides what major actions the program
must take
rather than worry about the details of how it is done, the
programmer defines a function that will handle that
later
Top-Down Programming
starts by defining a simple function that might be useful in
solving a more complex problem
Bottom-Up Programming
4 Main Python Coding Styles
Imperative
Functional
Object-oriented
Procedural
Like math: treats everything like a math equation
Make use of higher-order functions for data manipulation
Functional Style
focus is on how a program operates. Changes the state information as needed in order to achieve a goal
Imperative Style
What Coding style does this code snippet exemplify:
sum = 0
for x in my_list:
sum += x
print(sum)
Imperative Style
coding is all about increasing an application’s ability to reuse code and make it easier to understand
Object-Oriented Programming
What Coding style does this code snippet exemplify:
class ChangeList(object):
def __init__(self, any_list):
self.any_list = any_list
def do_add(self):
self.sum = sum(self.any_list)
create_sum = ChangeList(my_list)
create_sum.do_add()
print(create_sum.sum)
Object Oriented Programming
The __________________ relies on procedure calls to create modularized code. This approach simplifies your application code by breaking it into small pieces that a developer can view easily.
Procedural Style
POP vs OOP
Program Subparts: Functions
Procedural Oriented Programming
POP vs OOP
Program Subparts: Objects
OOP
POP vs OOP
Prioritizes functions as well as sequence
of actions to be done
POP
POP vs OOP
Prioritizes data
OOP
POP vs OOP
Top-down Approach
POP
POP vs OOP
Bottom Up Approach
OOP
POP vs OOP
No access modifiers
POP
POP vs OOP
Has access modifiers (ie. public, private, protected, default)
OOP
POP vs OOP
Data can move freely
from function to
function in the system
POP
POP vs OOP
Objects can move and communicate
with each other through member
functions
OOP
POP vs OOP
To add new data and function is not so
easy
POP
POP vs OOP
Can easily add new data and function
OOP
POP vs OOP
Most function uses Global data for sharing that can be
accessed freely from function to function in the system
POP
POP vs OOP
Data can not move
easily from function to
function,it can be kept
public or private so
we can control the
access of data
OOP
POP vs OOP
does not have any
proper way for hiding
data so it is less
secure
POP
POP vs OOP
provides Data Hiding
so provides more
security
OOP
POP vs OOP
Overloading is not
possible
POP
POP vs OOP
Overloading is
possible in the form of
Function Overloading
and Operator
Overloading
OOP
is a paradigm that uses classes and objects to create models based on the real-world environment.
Object-Oriented Programming (OOP)
Defines attributes (or properties) and behavior
and dictates the concept
Classes
Instances of Classes
Objects
A way for the programming language
to represent real-world objects as software
objects
Classes
is when we forget about details of how something works and just
concentrate on using it. Devil is in the details :>
Abstraction
Data hiding. A Class can have properties that cannot be accessed directly
Encapsulation
employs the use of Parent and Child classes (Super and Subclasses)
Inheritance
Use of a class exactly like its parent so there’s no confusion with mixing types. But each child class keeps its own methods as they are.
Polymorphism
Focuses on the essentials and ignores the irrelevant
Abstraction
Denotes the essential characteristics of an object that distinguish it from all other kinds of objects providing well-defined boundaries, relative to the perspective of the viewer
Abstraction