Final Part A Flashcards

1
Q

First 6 components of well-documented design pattern

A
  • pattern name
  • intent
  • other names
  • motivation
  • applicability
  • structure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Second 7 components of well-documented design pattern

A
  • participants
  • collaboration
  • consequences
  • implementation
  • sample code
  • known uses
  • related patterns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

definition of design pattern

A

a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.

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

What are creational design patterns?

A

pattern that deal with object creation mechanisms

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

What are structural design patterns?

A

patterns that ease design by identifying ways to realize relationships among entities

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

What is a behavioral design patterns?

A

design patterns that identify common communication patterns among objects

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

what are data clumps

A

when different parts of the code contain identical groups of variables

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

what is primitive obsession

A

use of primitives instead of objects

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

bad smell: switch statements

A

overly complex switch statements

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

bad smell: temporary field

A

a field that gets its values only under circumstances and is otherwise empty

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

bad smell: refused bequest

A

a subclass only uses some of the methods from its parent

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

bad smell: alternative classes with different interfaces

A

two classes perform identical functions but have different method names

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

bad smell: divergent change

A

when you change a class you have to make changes to many unrelated methods

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

bad smell: shotgun surgery

A

making any modifications requires that you make many small changes to many different classes

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

bad smell: parallel inheritance hierarchies

A

whenever you create a subclass for a class, you find yourself needing to create a subclass for another class

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

bad smell: lazy class

A

doesn’t do enough to merit its existence

17
Q

bad smell: feature envy

A

a method access the data of another object more than its own data

18
Q

bad smell: inappropriate intimacy

A

one class uses internal fields and methods of another class

19
Q

bad smell: message chains

A

a() calls b() which calls c() which calls d()

20
Q

bad smell: middle man

A

the only action one performs is delegating work to another class

21
Q

definition of refactoring

A

a change to the system that leaves its behavior unchanged but enhances some non-functional quality

22
Q

7 reasons for refactor

A
  • prevent design decay
  • clean up messes in the code
  • simplify the code
  • increase readability and understandability
  • find bugs
  • reduce debugging time
  • build in learning we do about application
23
Q

How to refactor (5)

A
  • make sure tests fail in a deterministic way
  • find code smells
  • determine how to simply code
  • make simplifications
  • ensure tests fail in the same fashion
24
Q

Requirements for refactoring (4)

A
  • collective code ownership
  • coding standards
  • tests
  • continuous integration
25
Q

when to refactor (3)

A
  • all of the time
  • rule of 3 (if you have to touch a piece of code because of bug 3 or more times then it needs to be refactored)
  • anytime you touch the code and find a bad smell
26
Q

biggest problem with refactoring

A

refactoring presents a good chance of introducing a new bad smell

27
Q

why developers don’t refactor (4)

A
  • lack of understanding
  • short-term focus by management (always wants new functionality)
  • not gonna get paid for it
  • fear of breaking current program
28
Q

when to use containment vs. inheritance

A

if Liskov’s substitution principle can be applied favor inheritance, otherwise favor containment