Week 5 Flashcards

1
Q

What is object orientated programming

A

It is a programming paradigm based on concept of objects which are instances of classes

Objects contain:
data - attributes / properties
code - methods / functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Object-Orientated design

A

process of designing a software solution using OOP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are method signatures

A

Each method has signature : name, parameters, return type and access level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are key ideas related to object calling and answering

A

objects interact by calling methods, but not just any, only predefined methods

They don’t accept arbitrary calls
Methods define acceptable calls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an object interface

A

This is the set of method signatures available for the object

example arrays have .index or .get or whatever but you don’t actually know wtf happens behind the interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

explain information hiding or encapsulation regarding Object interfaces

A

Involves hiding their internal attributes and only allowing access through interface methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

client and server objects

A

client = object requesting something
server = the object fulfilling it by like doing the function

scenario based obvs

when object calls a method on another object its like sending a message “ hey poes do this”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Modules vs objects

A

modularity is more for just organising code by grouping functionality together

objects is similar but encapsulates data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are UMLs

A
  • Unified Modelling Language

Standardised visual language which represents different aspects of a systems structure and behaviour

similar to ERDs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Key components of a UML

A

Class diagrams

Use case diagrams

Sequence diagrams

Activity diagrams

State machine diagrams

Component Diagrams

Deployment diagrams

Package diagrams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

UML classes has 3 compartments

A

Class Name
Attributes
Operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

symbols with operations in UML classes

A

+ public - Accessible from anywhere (any class can use it).

  • private - Only accessible within the class itself (not from other classes).

protected # - Accessible from the same class and subclasses (but not outside them).

~ package - Accessible only within the same package/module (used in Java, not in Python).

/ derived - Represents a calculated (not stored) attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

class diagrams

A

shows classes, attributes and relationships

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

use case diagrams

A

different users

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

sequence diagrams

A

how objects interact over time
e.g. log into ATMs, requests verification, bank responds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Activity diagrams

A

shows flow of activities in a system

like online order has
Add to cart
Payment info
Confirm order

17
Q

State machine diagrams

A

show how objects move between states

robot go red to green to yellow

18
Q

Component diagrams

A

shows software components and their dependencies

web app with its databases, UI and APIs

19
Q

Deployment diagrams

A

how software is deployed

20
Q

Package diagrams

A

groups classes into packages for better organisation

a large e commerce might have separate packages for User management or payments or order processing etc

21
Q

UML notation for classes relationships

A

Association : solid line >
Inheritance : solid line open triangle
implementation : dotted line open triangle
dependency: dotted line >
aggregation : solid line open diamond
Composition : solid line solid diamond

22
Q

what is association

A

when object accesses another in some way

owner feeds dog

bidirectional - solid line no arrow
unidirectional - solid line with one arrow
prohibited association - solid lines with two arrows facing each other

23
Q

Inheritance

A

object inherits properties of another

“is a “ relationship

24
Q

composition

A

object references another object
“has a” relationship

25
Q

aggregation

A

similar to composition

composition is more child cannot exist without the parent

aggregation is child can exist without parent

26
Q

inheritance vs composition in making changes

A

when you inherit you take all properties so changes in parent affect all children

with composition a class contains an instance of another class so changes in one don’t affect the other

car has engine .

27
Q

What is polymorphism

A

its a concept in OOP allowing objects of different types or classes to be treated under a common superclass

We can write code to work with objects of different classes in a uniform way even if they may behave differently

28
Q

Compile time polymorphism

A

s when compiler decides which method to use
aka Static or early binding

Done by method loading - methods with same names but different parameters

or even done by operator overloading -operators like + * - can be overloaded to work with custom types exampling adding two fags to make a bigger fag.

29
Q

Runtime polymorphism

A

Decision about which method to call is determined during execution of the program

done by:

Method overriding: child redefines a method that is defined by its parent

interface implementation - different classes implement the same interface but with their own implementation
dog bark and cat moos

30
Q

Duck Typing?

A

form of polymorphism

This is where an objects type or class is not as important as the methods it has

so if the objects have methods that are expected, it is treated as the type expected even if it doesn’t explicitly inherit from that type.

Imagine you have different animals, like a Duck, a Dog, and a Cat. You don’t care what type of animal they are, as long as they can walk and quack ( make sounds).

So, if you see an animal that walks and quacks, you treat it like a Duck, even if it’s actually a Dog or a Cat. The important thing is what it can do (walk and quack), not what type of animal it is.

31
Q

Subtyping polymorphism

A

child inherits from parent

so a child object can be used wherever a parent it used as it has the same attributes.

31
Q

Ad-hoc polymorphism

A

This is method or operator overloading such as compile time poly.

32
Q

poly pros and cons

A

PROS:
code reusability - generic code can work with different object types
modularity - able to extend functionality without changing existing code
flexibility - can interact with different types without knowing the exact types

CONS:
complexity
readability
performance - dynamic dispatch is slower

33
Q

Why we use object orientated (pros)

A

Modularity and reusability make development:
- Easier
- Faster
- More productive
- Cheaper
- easier to maintain

  • However, can be complicated to design and explain
34
Q

How do design OO systems well

A

Agility (like the scrum process)
Traceability
Testability - TDD
Measurability - stats, reports performance
Security