Ch 7: Object Oriented Design Flashcards

1
Q

Important Concepts

A
  • Object Oriented Programming
  • Class Diagrams
  • Inheritance
  • OOP Design Steps
  • Design Patterns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Design Patterns?

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

Goal of good Object Oriented Design

A

To create elegant, maintainable code arranged into objects.
Design is NOT about regurgitating known Design Patterns.

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

Object Oriented Design Steps

A
  1. Handle Ambiguity
  2. Define Core objects
  3. Analyze Relationships
  4. Investigate Actions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Object Oriented Design Steps:
1. Handle Ambiguity

A

Questions/Problems are often vague(intentionally in interviews, less intentionally in real life)

Ask Clarifying questions:
* Use the “Six W’s”:
- WHO is going to use it
- WHAT
- WHY
- WHERE will it be used
- WHEN will it be used (time, frequency of use, etc)
- HOW are they going to use it

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

Object Oriented Design Steps:
2. Define Core Objects

A
  • Determine what the most fundamental objects should be, can be revised as the process goes on
  • Objects may represent real world counterparts(user, company, building, etc)
  • Objects may be abstract: (session, time block, requests, etc)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Object Oriented Design Steps:
3. Analyze Relationships

A
  • Consider the relationships between the objects created so far
  • Which are “members” of other objects
  • Which objects inherent from a parent object(or could)
  • Is the relationship many-to-one, many-to-many, one-to-one?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Object Oriented Design Steps:
4. Investigate Actions

A

Assess the Key Actions that objects take, and how they relate to other objects.
Likely to have forgotten some objects

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

Design Patterns:
Two Extremely Common Design Patterns in Interviews

A
  • Singleton
  • Factory Pattern

(Note: you should know many more design patterns than these)

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

Singleton Pattern:
Overview

A
  • Ensures that a class has only one instance
  • Ensures access to the instance through the application
  • Useful for “global” objects with exactly one instance
  • Many people dislike the Singleton design pattern
    • Sometimes called an “anti-pattern”
    • Can sometimes interfere with Unit Testing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Factory Design Pattern:
Overview

A
  • Offers an interface for creating an instance of a class
  • Subclasses decide WHICH class to instantiate
  • Factory method takes a parameter representing WHICH class to instantiate
    • Constructs and returns an instance of the specified class
  • Typically has a Creator class
    • Either abstract or concrete with an implementation of the Factory method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

OOP Design Principles:
10 Key Principles

A
  • DRY (Don’t Repeat Yourself)
  • Encapsulate What Changes
  • Open Closed Design Principle
  • Single Responsibility Principle(SRP)
  • Dependency Injection or Inversion Principle
  • Favor Composition over Inheritance
  • Liskov Substitution Principle (LSP)
  • Interface Segregation Principle (ISP)
  • Programming for Interface not Implementation
  • Delegation Principles

Page: https://hackernoon.com/10-oop-design-principles-every-programmer-should-know-f187436caf65

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