1/27
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Object-Oriented Programming
paradigm based on objects
Objects contain:
data (attributes, properties) and code (methods, functions)
Objects are instances of classes, which determine their types
Object-Oriented Design
process of using objects and object- oriented programming when designing a software solution
Object Calling and Answering
Objects don’t accept arbitrary calls
Acceptable calls are defined by methods
Object Interface
set of method signatures for that object
Information hiding
An object can hide its state (attributes), restricting access through an interface
Client and server objects
Objects send messages by calling methods
what are messages and client objects
The method call is the message
Object calling the method is the client object
what is an interface
An interface is a set of functional properties (services) that a software object provides or requires.
On demand design
we “pull” interfaces and their implementations into existence from the needs of the client, rather than “pushing” out the features that we think a class should provide
Modular programming
software
design technique that emphasizes separating the functionality of a program into independent, interchangeable modules
Modules vs Objects
Modules are loose groupings of subprograms and data
Objects encapsulate data
UML
standardized visual language used in software engineering to represent different aspects of a system's structure and behaviour
Types of UML diagrams
Class diagrams: Represent the structure of a system by showing classes, their attributes, methods, and relationships.
Use Case Diagrams
Sequence Diagrams
Activity Diagrams
State Machine Diagrams
Component Diagrams
Deployment Diagrams
Package Diagrams: Organize and structure the elements of a system into logical groupings.
UML object relationship:Association
Association: one object accesses the other in some way
UML object relationship:Inheritance
object inherits the properties of another object through class extension
→“is a” relationship
UML object relationship:Composition
object references another object as an instance variable.
→”has a” relationship
UML object relationship:Aggregation
Aggregation implies the child class can exist without the parent
Composition implies the child class cannot exist without the parent
Object relationships
Both inheritance and composition extend the base functionality provided by another object
however:
Inheritance: Change in the “base” class propagates to the derived class and its client classes
Composition: More adaptive to change, because change in the “base” class is easily “contained” and hidden from the clients of the front-end class
Polymorphism
Polymorphism is the provision of a single interface to entities of different types. In essence, it is the ability to take on many forms
e.g Ducktyping
Types of Polymorphism
Compile-time Polymorphism (Static Binding or Early Binding)
Runtime Polymorphism (Dynamic Binding or Late Binding)
Compile-time Polymorphism
Decision on which method to call is made at compile time
Method & operator overloading
Runtime Polymorphism
decision about which method to call is made at runtime based on the type of the object
It is achieved through method overriding and interface implementation.
involves redefining a method in a subclass that is already defined in its superclass.
Ducktyping
an object’s type/class is less important than the methods it defines
→focus is on the object's behaviour rather than its actual type or class.
Subtyping
type of polymorphism where code written for a supertype will work on a subtype
Ad-hoc polymorphism
refers to a single name or symbol having multiple implementations depending on the arguments
Polymorphism Pros
Allows programmers to reuse code
Helps cut down on the size of code
Can improve the modularity of code
Polymorphism con
Can be very complex
Can make code harder to read (not sure which implementation will be called)
Dynamic dispatch can be slower (run-time)
Object oriented vs Process-oriented
Process-Oriented is more intuitive because it is person-centric (x happens then y)
Object-oriented may be more confusing because of labour-division
Object-Oriented is organisation-centric, designed to scale to large problems