design diagrams for cfc’s & databases - pete freitag › presentations › cfunited ›...

51
www.cfunited.com Design Diagrams for CFC’s & Databases Pete Freitag Foundeo Inc.

Upload: others

Post on 28-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

www.cfunited.com

Design Diagrams for CFC’s & Databases

Pete Freitag

Foundeo Inc.

Page 2: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

2

Who Am I?

I own Foundeo, Inc

� Consulting� Products for ColdFusion Developers

10+ Years in ColdFusion Community

� Blog: petefreitag.com

� Twitter: @pfreitag

Page 3: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Agenda

Why use Diagrams?

Diagrams for CFC’s

� UML Class DiagramsDiagrams for Databases

� ER DiagramsDiagram Software

3

Page 4: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

What is the Value of Diagrams?

Always ask this question.

� May not provide as much value for small projects with a solo developer.

� It’s easy to get carried away.� They should increase productivity not decrease it.

4

Page 5: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Suppose You Are Building a House...

5

Page 6: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

And given this...

The foundation should be 75 feet by 20 feet where the north and south walls are 75 feet and the east and west walls are 20 feet long. The north wall has jut out that is 10 feet by 20 feet, and should start 10 feet from the east wall.. The foundation should be 10 feed deep. The north wall jut out has a doorway that is centered and 36” wide, and 80” high. The doorway should have a porch, that is 10 feet by 4 feet, having steps centered, and raised 3 feet. The porch should be eight and a half feet high, with a railing four feet high. As you can see it is very hard to extract the details logically with a large block of text, this is why diagrams can be much more effective...

6

Page 7: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

You May Run Into Some Problems

7photo credit: robstephaustralia on flickr

Page 8: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Builders Use Blueprints

8

photo credit: Thristian on flickr

Page 9: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

What is the Value of Diagrams?

Improved Communication

� It is often easier to communicate an idea via a diagram.� A picture is worth...

� Standard diagram notations.� Less prone to error & misinterpretation.

9

Page 10: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

What Is The Value of Diagrams

Better Software

� See how everything fits together before writing code.

� Decreased re-factoring.

� Easier to see the holesBetter Understanding

� Visualize the Problem

10

Page 11: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

What is the Value of Diagrams?

They don’t need to be fancy to have value.

� Simple is often best.

11

Page 12: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Paper Vs. Software

12

Page 13: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Software Vs. Paper

Paper, Napkins, Whiteboards

� Quick & Easy� Portable - Create or Take Anywhere

� Hard to Modify

13

Page 14: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Software Vs. Paper

Software Diagraming Tools

� Editable� Forward / Reverse Engineering

� More Readable� Often Overcomplicated� Expensive

14

Page 15: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Design Diagrams for CFC’s

15

Page 16: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Unified Modeling Language (UML)

16

Developed in 1997 by the Object

Management Group.

Defined specifications for several software

architecture diagrams:

� Use Case Diagrams� Class Diagrams

� State Diagrams� Sequence Diagrams

� And More...

Page 17: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams

17

Class Name

Page 18: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams

18

Properties

Page 19: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams

19

Methods

Page 20: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Properties / Attributes

20

name : data type

Could be used for:

� this scope (public)

� CFPROPERTY tags� Private (variables scope)

a) Use - prefix to denote private.b) + Denotes public.

Page 21: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Methods / Functions

method( arg : type ) : returns

21

Page 22: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Interfaces

Interfaces (such as those defined with

CFINTERFACE) are denoted with

<<interface>>

22

Page 23: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Abstract

Abstract is denoted with italic text

For napkins or whiteboards use: {abstract}

23

Page 24: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Relationships

Class Relationships Are Denoted with Arrows

� Pay Attention To:a) Arrow Head

b) Solid / Dashed Lines

24

Page 25: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Relationships

25

Page 26: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Relationships

You don’t always need to be detailed:

26

Page 27: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Implements

27

Implements or Realization<<realize>>

Product & Publisher Implement Nameable

Page 28: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Inheritance

28

Inheritance orGeneralization

Book Extends Product

Page 29: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Class Diagrams: Composition

29

Composition,Dependency,Usage

Book Uses or Depends on Publisher

Page 30: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Package Diagrams

30

Page 31: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Package Diagram

Show Classes In Package

31

Page 32: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Other Types of UML Diagrams

32

Page 33: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

UML Use Case Diagram

33

Page 34: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Sequence Diagrams

34

image source: wikipedia

Page 35: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Activity Diagrams

35

image source: wikipedia

Page 36: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Pop Quiz

What Type of Relationship is this:

36

Page 37: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Pop Quiz

What type of Relationship is this?

37

Page 38: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Database Design Diagrams

38

Page 39: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Entity Relationship Diagrams (ER Diagrams)

39

Used to show fields and relationships

between entities (tables)

Page 40: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams

Not Standardized

Several Notations to represent cardinality

� Crow’s Foot Notation is my preference, and is used by most software.

� UML has a notation as well

40

Page 41: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams: Crows Foot Notation

One to One Relationship

41

Page 42: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams

One to Zero or One

42

Product May Relate to Zero or One Book

Page 43: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams: Crows Foot Notation

One to Many

43

Page 44: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams

One to Zero, 1, or Many

44

Page 45: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams: Relationships

45

Page 46: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

ER Diagrams

Many to Many

46

Page 47: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Diagram Software

Reverse Engineering

� Uses DB Schema, or Source code, and generates diagrams.

Forward Engineering

� Generates Source Code or DDL from a diagram.

47

Page 48: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Diagram Software

Visio (UML, ERD) - Windows $559.95

ArgoUML (UML) - Any OS, Open Source

SQLEditor (ERD) - Mac, $79

Many More

� http://en.wikipedia.org/wiki/List_of_UML_tools� http://en.wikipedia.org/wiki/Entity-

relationship_model#ER_diagramming_tools

48

Page 49: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Generating CFC’s from UML

Brian Kotek’s CFC Stub Generator

� cfcstub.riaforge.org� Takes XMI File (XML format for UML)

49

Page 50: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Recommended Reading

UML Distilled by Martin Fowler

50

Page 51: Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited › ...diagrams can be much more effective... 6. Y ou May Run Into Some Problems 7 ... Class Relationships

Thank You,Questions?

51