Object oriented programming

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/27

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

28 Terms

1
New cards

Object-Oriented Programming

paradigm based on objects

Objects contain:

  1. data (attributes, properties) and code (methods, functions)

  2. Objects are instances of classes, which determine their types

2
New cards

Object-Oriented Design

process of using objects and object- oriented programming when designing a software solution

3
New cards

Object Calling and Answering

Objects don’t accept arbitrary calls

Acceptable calls are defined by methods

4
New cards

Object Interface

set of method signatures for that object

5
New cards

Information hiding

An object can hide its state (attributes), restricting access through an interface

6
New cards

Client and server objects

Objects send messages by calling methods

7
New cards

what are messages and client objects

  1. The method call is the message

  2. Object calling the method is the client object

8
New cards

what is an interface

An interface is a set of functional properties (services) that a software object provides or requires.

9
New cards

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

10
New cards

Modular programming

software

design technique that emphasizes separating the functionality of a program into independent, interchangeable modules

11
New cards

Modules vs Objects

  1. Modules are loose groupings of subprograms and data

  2. Objects encapsulate data

12
New cards

UML

standardized visual language used in software engineering to represent different aspects of a system's structure and behaviour

13
New cards

Types of UML diagrams

  1. Class diagrams: Represent the structure of a system by showing classes, their attributes, methods, and relationships.

  2. Use Case Diagrams

  3. Sequence Diagrams

  4. Activity Diagrams

  5. State Machine Diagrams

  6. Component Diagrams

  7. Deployment Diagrams

  8. Package Diagrams: Organize and structure the elements of a system into logical groupings.

14
New cards

UML object relationship:Association

Association: one object accesses the other in some way

<p><strong>Association</strong>: one object accesses the other in some way</p>
15
New cards

UML object relationship:Inheritance

object inherits the properties of another object through class extension

→“is a” relationship

<p>object inherits the properties of another object through class extension</p><p>→“is a” relationship</p>
16
New cards

UML object relationship:Composition

object references another object as an instance variable.

→”has a” relationship

<p>object references another object as an instance variable.</p><p>→”has a” relationship</p>
17
New cards

UML object relationship:Aggregation

Aggregation implies the child class can exist without the parent

Composition implies the child class cannot exist without the parent

<p>Aggregation implies the child class can exist without the parent</p><p>Composition implies the child class cannot exist without the parent</p>
18
New cards

Object relationships

Both inheritance and composition extend the base functionality provided by another object

however:

  1. Inheritance: Change in the “base” class propagates to the derived class and its client classes

  2. Composition: More adaptive to change, because change in the “base” class is easily “contained” and hidden from the clients of the front-end class

<p>Both inheritance and composition extend the base functionality provided by another object</p><p>however: </p><ol><li><p>Inheritance: Change in the “base” class propagates to the derived class and its client classes</p></li><li><p><strong>Composition</strong>: More adaptive to change, because change in the “base” class is easily “contained” and hidden from the clients of the front-end class</p></li></ol>
19
New cards

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

20
New cards

Types of Polymorphism

  1. Compile-time Polymorphism (Static Binding or Early Binding)

  2. Runtime Polymorphism (Dynamic Binding or Late Binding)

21
New cards

Compile-time Polymorphism

  1. Decision on which method to call is made at compile time

  2. Method & operator overloading

22
New cards

Runtime Polymorphism

  1. decision about which method to call is made at runtime based on the type of the object

  2. It is achieved through method overriding and interface implementation.

  3. involves redefining a method in a subclass that is already defined in its superclass.

23
New cards

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.

24
New cards

Subtyping

type of polymorphism where code written for a supertype will work on a subtype

<p>type of polymorphism where code written for a <strong>supertype </strong>will work on a <strong>subtype</strong></p>
25
New cards

Ad-hoc polymorphism

refers to a single name or symbol having multiple implementations depending on the arguments

<p>refers to a single name or symbol having multiple implementations depending on the arguments</p>
26
New cards

Polymorphism Pros

  1. Allows programmers to reuse code

  2. Helps cut down on the size of code

  3. Can improve the modularity of code

27
New cards

Polymorphism con

  1. Can be very complex

  2. Can make code harder to read (not sure which implementation will be called)

  3. Dynamic dispatch can be slower (run-time)

28
New cards

Object oriented vs Process-oriented

  1. Process-Oriented is more intuitive because it is person-centric (x happens then y)

  2. Object-oriented may be more confusing because of labour-division

    Object-Oriented is organisation-centric, designed to scale to large problems