Object-Oriented Principles Flashcards

1
Q

SOLID Principles?

A
Single-Responsibility Principle
Open Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Single-Responsibility Principle?

A

A class should have one, and only one reason to change

SoC principle that focuses on managing change by assigning cohesive responsibilities.

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

Open-Closed Principle

A

You should be able to extend the behaviour of a module without modifying it

A module is closed for modification but open to be extended.

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

How is Open-Closed Principle achieved?

A

Loose coupling
Abstraction
Polymorphism

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

Liskov Substitution Principle?

A

Subclasses should be substitutable for their base classes

Dictates the correct implementation of the IS-A relationship

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

Interface Segregation Principle?

A

Many client specific interfaces are better than one general purpose interface

Critical principle to follow in the design of interfaces who are much more focused than the classes that implement them

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

Dependency Inversion Principle?

A

Depend upon Abstractions. Do not depend upon concretions

Definition of use of abstraction to ensure loose coupling.
Enables dependency injections and associated frameworks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
S
O
L
I
D
A
High Cohesiveness
Code Reuse
Code Reuse
SoC
Loose Coupling
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

4 Essential elements in Design Pattern?

A

Pattern Name
Problem
Solution
Consequencies

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

What did GoF do?

A

GoF established a paradigm for cataloguing and reuse of design solutions

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

Pattern Catagorization?

A

Architecture Patterns
Design Patterns
Idioms

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

Architectural Patterns?

A

Expresses fundamental structural organizartion of software systems; predefined subsystems and their responsibilities and relationships
* Large Scale Patterns

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

Design Patterns?

A

Medium Scale Patterns

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

Idioms?

A

Programming language specific pattern that describes how to implement particular aspects of components, relationships or functionality

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

Pattern Classification By Purpose list

A

Creational Patterns
Structural Patterns
Behavioural Patterns

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

Creational Patterns?

A

Address the instantiation process as a separate concern
Make system independent
Emphasize object composition vs class inheritance to decrease coupling

17
Q

Structural Patterns?

A

Ways to compose classes and objects to from larger structure to realize new functionality that can be easily extended

18
Q

Behavioural Patterns?

A

Representing algorithms and assignment of responsibilities between objects and focus on patterns of communication between objects

19
Q

Pattern Classification by Scope?

A

Class Patterns

Object Patterns

20
Q

Class Patterns?

A

Focus on relationships between classes and subclasses.
Inheritance relationships are defined at compile-time
Focus on code reuse

21
Q

Object Patterns?

A

Focus relationships between objects, specifically composition and aggregation.
Relationships are dynamic
Focus on code reuse through flexibility

22
Q

Roles in Abstract Factory Pattern?

A

Abstract Factory
Concrete Factory
Abstract Product
Concrete Product

23
Q

Consequencies of Abstract Factory?

A

Isolates the client from specific concrete classes making clients dependent only on interfaces

24
Q

Roles in Factory Method Pattern?

A

Creator
ConcreteCreator
Product
ConcreteProduct

25
Q

What is Creator?

A

Declares the factory method which returns an abstract product or product interface

26
Q

ConcreteCreator?

A

Implement the factory method by creating a concrete product that is used by the creator or by one of its client

27
Q

Product?

A

Defines the interface of the products that are being created by the factory method

28
Q

ConcreteProduct?

A

Implement the product interface this representing a concrete product that will be used

29
Q

Singleton?

A

The singleton ensure that only one isntance of given class is being created and used in a system

30
Q

Consequences of Singleton?

A

Provides encapsulation and controller access to global variables
More flexible than using static classes which cannot be extended and are not polymorphic

31
Q

Caveats of Singleton?

A

Multiple singletons may have interdependencies that may be difficult to manage as the order of creation depends on the usage order

32
Q

Composite?

A

Composite objects into tree structures letting clients treat individual objects and compositions of objects uniformly

33
Q

Roles in the Composite Pattern?

A

Component
Leaf
Composite

34
Q

What is Decorator?

A

Attach additional responsibilities to an object dynamically