Design Diagrams for CFC’s & Databases - Pete Freitag › presentations › cfunited ›...

Preview:

Citation preview

www.cfunited.com

Design Diagrams for CFC’s & Databases

Pete Freitag

Foundeo Inc.

2

Who Am I?

I own Foundeo, Inc

� Consulting� Products for ColdFusion Developers

10+ Years in ColdFusion Community

� Blog: petefreitag.com

� Twitter: @pfreitag

Agenda

Why use Diagrams?

Diagrams for CFC’s

� UML Class DiagramsDiagrams for Databases

� ER DiagramsDiagram Software

3

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

Suppose You Are Building a House...

5

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

You May Run Into Some Problems

7photo credit: robstephaustralia on flickr

Builders Use Blueprints

8

photo credit: Thristian on flickr

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

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

What is the Value of Diagrams?

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

� Simple is often best.

11

Paper Vs. Software

12

Software Vs. Paper

Paper, Napkins, Whiteboards

� Quick & Easy� Portable - Create or Take Anywhere

� Hard to Modify

13

Software Vs. Paper

Software Diagraming Tools

� Editable� Forward / Reverse Engineering

� More Readable� Often Overcomplicated� Expensive

14

Design Diagrams for CFC’s

15

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...

UML Class Diagrams

17

Class Name

UML Class Diagrams

18

Properties

UML Class Diagrams

19

Methods

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.

UML Class Diagrams: Methods / Functions

method( arg : type ) : returns

21

UML Class Diagrams: Interfaces

Interfaces (such as those defined with

CFINTERFACE) are denoted with

<<interface>>

22

UML Class Diagrams: Abstract

Abstract is denoted with italic text

For napkins or whiteboards use: {abstract}

23

UML Class Diagrams: Relationships

Class Relationships Are Denoted with Arrows

� Pay Attention To:a) Arrow Head

b) Solid / Dashed Lines

24

UML Class Diagrams: Relationships

25

UML Class Diagrams: Relationships

You don’t always need to be detailed:

26

UML Class Diagrams: Implements

27

Implements or Realization<<realize>>

Product & Publisher Implement Nameable

UML Class Diagrams: Inheritance

28

Inheritance orGeneralization

Book Extends Product

UML Class Diagrams: Composition

29

Composition,Dependency,Usage

Book Uses or Depends on Publisher

UML Package Diagrams

30

UML Package Diagram

Show Classes In Package

31

Other Types of UML Diagrams

32

UML Use Case Diagram

33

Sequence Diagrams

34

image source: wikipedia

Activity Diagrams

35

image source: wikipedia

Pop Quiz

What Type of Relationship is this:

36

Pop Quiz

What type of Relationship is this?

37

Database Design Diagrams

38

Entity Relationship Diagrams (ER Diagrams)

39

Used to show fields and relationships

between entities (tables)

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

ER Diagrams: Crows Foot Notation

One to One Relationship

41

ER Diagrams

One to Zero or One

42

Product May Relate to Zero or One Book

ER Diagrams: Crows Foot Notation

One to Many

43

ER Diagrams

One to Zero, 1, or Many

44

ER Diagrams: Relationships

45

ER Diagrams

Many to Many

46

Diagram Software

Reverse Engineering

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

Forward Engineering

� Generates Source Code or DDL from a diagram.

47

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

Generating CFC’s from UML

Brian Kotek’s CFC Stub Generator

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

49

Recommended Reading

UML Distilled by Martin Fowler

50

Thank You,Questions?

51

Recommended