48
HFOOAD Chapter 7 Architecture

HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

HFOOAD Chapter 7 Architecture

Page 2: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Chaos

2

Page 3: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

3

If we just had a way to tie all of this information together we might be able to figure out what to do first.

You need an architecture!

Page 4: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Software architecture is…

a.  The structure of your application or system

b.  The most important (key) components of your system

c.  The relationships between the parts of your system

d.  The reason why you chose a particular component or representation of the relationships between your components

e.  The design patterns you apply

4

Your answer is?

Page 5: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Architecture is…

a.  The structure of your application or system b.  The most important (key) components of your system c.  The relationships between the parts of your system d.  The reason why you chose a particular component or

representation of the relationships between your components

e.  The design patterns you apply f.  All of the above!

5

Page 6: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

6

Software architecture is the organizational structure of a system, including its

decomposition into parts, their connectivity, interaction mechanisms, and the guiding

principles and decisions that you use in the design of a system.

Page 7: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

7

So now we need to document all of the details? This will take too long. Can we just start coding? A lot of people think that they

have to get all of the details. You just want to “flesh out” the big things.

Page 8: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

8

The architecture is the blueprints for your system

Page 9: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

What are software blueprints

‣  Requirements, especially use cases ‣  UML diagrams ‣  Class

‣  Package / component

‣  Sequence

‣  Others

‣  Interfaces ‣  Key classes with methods ‣  Prototypes ‣  …

9

I still don’t understand what corresponds to the blueprints for software apps.

Page 10: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

What must the system do?

10

Page 11: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

One prioritization

11

Page 12: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

12

I’m sorry but that’s not how I prioritize the features and I’m paying for this work!

Why not just get the customer to prioritize them to start with?

Page 13: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Three Qs of architecture

1.  Is it part of the essence of the system? ‣  If you can’t build the system without it, it’s essential

2.  What does it really mean? ‣  Do you really understand this feature

3.  How can I implement it? ‣  Lack of knowledge ‣  New or non-existent technology

13

Page 14: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Evolutionary design

‣  Designs evolve but not from the simple to the difficult

‣  Evolutionary design means that we can add to it as we go ‣  Incremental design

‣  Flexible design

‣  Iterative, incremental development

14

Why not start with the easy things and let the design evolve. Isn’t that an Agile principle?

Page 15: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Architecture reduces risk

15

Cha

nce

of fa

ilure

Project duration

Easy first

Focus on architectural significance

Page 16: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Our prioritization rationale

16

Page 17: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Sharpening our focus

17

Page 18: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

The board challenge

18

Page 19: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Scenarios

‣  A scenario can be one path through a use case ‣  The use case consists of many,

possibly infinite, scenarios

‣  A scenario can be a part of a use case or any meaningful sequence of actions

‣  Scenarios help us think about how the system works for one particular situation

19

Isn’t the board challenge a scenario?

Page 20: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Board challenge scenario

20

Create message

Page 21: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Code for the board challenge (1)

21

Page 22: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

22

Code for the board challenge (2)

Page 23: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Scenario scramble

23

Page 24: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

One possible scenario

24

Page 25: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Structure and relationships

25

Page 26: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Stop or go on?

Can we move on now? I know what we have to do for the board? This is too simple.

Wait a minute. What about saving the board, loading saved games, and so on. We can’t move on yet.

Page 27: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Focus on the goals Reasons to move on

‣  We know how to create a board

‣  We have described the interface for getting a particular tile and adding units to a particular tile on the board

‣  We have an idea about how the units, tiles, and board are related

Reasons to keep working on the board ‣  It’s not complete

‣  We haven’t figured out how to implement persistence so we can save and reload boards

‣  We haven’t established the coordinate system

27

Page 28: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Game specific units

We can probably work on the units next. I think I’m getting the hang of this evolving design.

What the heck does this mean?

28

Page 29: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Talk to the experts

29

Page 30: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

30

Each game based on the framework has different types of units, with different attributes and capabilities. So we need to be able to have properties for a unit that are different for each game, and support multiple data types for those properties.

What does “game-specific units” mean?

Page 31: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Commonality analysis revisited

31

1

2

3

4

Page 32: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Some possible properties

32

Page 33: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Unit commonality analysis

33

Page 34: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

No commonality

34

Page 35: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Draw upon your experience

35

Where have you had to solve a problem similar to this before?

So, everything can be unique and maybe even different types. Haven’t we solved a similar problem?

Page 36: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Handle the properties in a common way

36

Page 37: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

We’ve covered the 2nd key feature

37

Page 38: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Three-step process

38

We’ve gone through this a couple of times now. Can you identify a three-step process that will help you move forward with the third key feature: “coordinate movements”?

1

2

3

Page 39: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

39

Page 40: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Step 1: Ask the customer

40

Page 41: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Step 2: commonality analysis

41

Page 42: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Step 3: how to implement

42

There is no commonality!

Page 43: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Review: Reducing risk

43

Page 44: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

44

And you’ve got an (executable) architecture!

Page 45: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Additions to your toolbox

45

Page 46: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

But what if…

46

Page 47: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Two common turn descriptions Turn type 1

‣  Player A moves as many units as desired. Each move is performed as in steps 2-4 of turn type 1.

‣  Player A brings in reinforcements

‣  Player B goes through steps 1-2

‣  The turn counter is advanced by one

47

Turn type 2

‣  Player A moves one unit

‣  The game ensures that the move is valid

‣  The move is made

‣  The results of the move are calculated and the board is modified accordingly

‣  Player B goes through steps 1-4

‣  The turn counter is advanced by one

Page 48: HFOOAD Chapter 7fiech/resources/HeadFirstOOAD_Ch07.pdf · 2015. 10. 16. · Can we just start coding? A lot of people think that they have to get all of the details. You just want

Modify your design

48

Hint!