Object orientated design Flashcards

1
Q

What is object orientated programming?

A

a method of implementation in which programs are designed as cooperative collections of objects

  • describing a system in terms of meaningful abstractions (classes), relationship and interactions between them
  • allows us to understand the requirements and design a solution on the conceptual level
  • allows us to design and build extensible solutions and build for change via encapsulation, inheritance and polymorphism
  • allows us to communicate ideas and concepts in a clear consistent way to all team members
  • works across all stages of the software development process from Analysis to Maintenance via Design and Implementation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are abstractions?

A

Generalisations that define certain key characteristics and behaviour

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

What are abstractions about?

A

dealing with ideas
generalisation
-to focus on what matters, on key characteristics and behaviour
-to see things even clearer
-to simplify and make complexity manageable

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

What is a class?

A

A class represents a key concept within the system and encapsulates data and behaviour

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

What are objects?

A

Instances of a class that contain data and behave according to the class definition

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

What is encapsulation?

A

Exposing WHAT an object does and not HOW it works- designer can later improve the object without changing how the user interacts with it
‘defining functionality necessary for the objects to be used and hiding the details of how this functionality is implemented’

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

Why do we use encapsulation?

A
  • hide (abstract away) implementation
  • reduce dependencies between different parts of the application
  • make changes more safely/grow software more easily
  • debug more easily
  • examine the system from different levels
  • make everything more manageable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do classes provide?

A

Abstractions (complimentary to encapsulation)

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

What are getters and setters?

A
Properties
Provide controlled access to internal data fields
If access to internal data fields of the class is not controlled we can't do any of the things that encapsulation allows
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is inheritance?

A
Subclass points with a white arrow to the superclass
Subclass is type of superclass eg triangle is a shape
Subclass extends the data and behaviour of superclass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is polymorphism?

A

Allows us to request the same action from objects yet execute it in different ways- useful for extensibility, can generalise operations on similar concepts yet support distinct data and behaviour where necessary

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

What is an abstract class?

A
A class that can't be instantiated- conceptual 
capture the higher level view of the system
Any class with an abstract method is declared an abstract class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an interface?

A
A purely abstract class that defines only behaviour (not data)
eg iSubmersible, dive
class will extend one superclass but will implement multiple interfaces
dotted line white arrow
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is UML?

A

A formal graphical language comprising a set of diagrams for describing software systems
Diagram made of structure diagrams (class, show relationships) and behaviour diagrams (sequence, how they interact)

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

What is the most common mode of UML?

A

“AsSketch”

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

what is 0 or more?

17
Q

What is the block structure in a class diagram?

A

class name, data/attributes, behaviour/operations

18
Q

What is an association?

A

A line between classes

19
Q

What are compositions and aggregations?

A

Composition- filled diamond
A<>-B B can’t exist without A, eg rooms in house

Aggregation- empty diamond
B is a part of A but can exist without it, eg members of society

20
Q

What are communication diagrams?

A

Another type of behaviour diagram which show the method flow between objects by numbering method calls
-good for few method calls between potentially many objects

21
Q

What is pattern structure?

A
  • Motivation- outline specific functionality that software should provide
  • Solution options- explore ways of providing this functionality and discuss their limitations
  • Optimal solution- present preferred solution based on a design pattern
  • Code example- an example of what the design solution looks like using any programming language
  • Design pattern- discuss the general principle underlying a good solution and its applicability to other situations, show the generic design pattern using UML
  • Disadvantages- discuss the shortcomings of the design pattern and why you might not want to use it for certain cases
22
Q

What is a composite pattern?

A

Want to operate on individual items and groups of those in a common way
Cons: can be too general, client code must be able to distinguish between composite objects and non-composite objects

23
Q

What is a decorator pattern?

A

Allows us to add functionality without changing the original class

  • If there are not too many kinds of added functionality and they appear fairly commonly, it may be more convenient to use solution 1 (add attribute in class)
  • Hard to resolve the identity of the objects we are dealing with since decorator is a distinct object from the component it decorates- in a running system this can result in long chains of small objects that point to each other, making the software hard to debug
24
Q

What is an observer?

A

Allows multiple objects to maintain a consistent view on the state of the object of interest
cons- could lead to large computational overhead if not safeguarded

25
Q

What is a memento pattern?

A

Allows us to track the state of the object externally, without knowing all details of that state
Encapsulate the change into an object of the dedicated class- ie the memento
Allows to capture and externalise object’s internal state without breaking encapsulation
Cons- shape’s state could include a lot of data, when managing multiple shapes need to maintain which memento is for which shape

26
Q

What is Model-View-Controller (MVC)?

A

The common pattern that separates the data, its presentation and the way it is manipulated by the user
• Model – an abstraction of the data that provides ways of accessing and manipulating it
• View – presents a specific purpose view onto the Model, captures User’s input and passes it on to the Controller
• Controller – interprets User’s input and invokes corresponding actions on the Model

27
Q

What’s the difference between passive and active mode?

A
PASSIVE: the Controller is the only class that affects the Model
ACTIVE: the Controller is NOT the only class that affects the Model- the model is a subject and maintains a list of observers, the view implements the observer interface
28
Q

What are the benefits of classes and objects?

A

Help managing complexity

  • allow us to describe complex systems through meaningful abstractions
  • support different level views of the system (eg conceptual- high level abstraction, and implementation- low level abstraction)
  • allow all project members to have shared understanding of the system