180 likes | 350 Views
Simple UML. What is UML?. UML is a diagramming language designed for Object-Oriented programming UML can be used to describe: the organization of a program how a program executes how a program is used how a program is deployed over a network …and more. Design Patterns.
E N D
What is UML? • UML is a diagramming language designed for Object-Oriented programming • UML can be used to describe: • the organization of a program • how a program executes • how a program is used • how a program is deployed over a network • …and more
Design Patterns • Design Patterns describe the higher-level organization of solutions to common problems • They are a current hot topic in O-O design • UML is always used for Design Patterns • We will discuss some Design Patterns later on in this course
UML is complex • UML is a big, complicated diagramming language • UML comprises at least seven or eight different kinds of diagrams • This talk will cover just a tiny bit of one kind of diagram, the class diagram
Class diagrams • A class diagram shows classes, interfaces, and their relationships • We’ll cover most of classes and interfaces, and a few of the most important relationships
Name of the class Variables [optional] Methods Classes • A class is drawn as a rectangle with two or three compartments:
Variables I • A variable is written as:visibility name : typewhere: • + means public visibility • # means protected visibility • - means private visibility • <blank> means default (package) visibility • Example: +length:int
Variables II • Static variables are underlined • An initial value can be shown with =value • Example:-numberOfEmployees:int=10means numberOfEmployees is: • private, static, integer, with initial value 10
Methods • Methods are written as:visibility name (parameters) : returnTypewhere • visibility is the same as variables (+, -, #, blank) • parameters are given as name:type • if the returnType is void, it is omitted • constructors are preceded by «constructor» • an ellipsis (…) indicates omitted methods
Card cardId:int -copy:boolean=false «constructor» Card(int id) +isKind(desiredKind:int) +isSharable():boolean +toString():String Example of a class
A B C D Factory Product creates 1..4 Types of relationships Class Bextendsclass A Class Ccontains 1 to 4 objectsof class D Other kinds ofrelations
UML tools • Visio is a Microsoft tool for drawing UML diagrams • Dia is a freeware clone of Visio • Rational Rose is the "real world" standard; full round-trip code generation • Together (from TogetherSoft) appears to be a lot like Rational Rose
Tool availability • Visio: you can order a 60-day trial CD, but you can't just download a copy • Dia: Free, downloadable, but tricky to install and of unknown quality • Rational Rose: 233 MB, expires in 15 days • Together: 23 MB free download after filling out a form (basic version doesn't expire; fancy features expire in 30 days)
Tool links • Visio • http://www.microsoft.com/office/visio/ • Dia • http://www.lysator.liu.se/~alla/dia/dia.html • Rational Rose • http://www.rational.com/products/rose/index.jsp • Together • http://www.togethersoft.com/
Schedule for today • This UML talk • Brief introduction to WebCT • Work on your game design • Peer reviews of game designs
Assignments • Next Monday: • Finish designing your game • I want two informal designs: • A design for the absolutely minimal playable game • A design for the complete game • Next Wednesday: • Formal design of the minimal game • preferably in UML (or something close to UML) • Hand-drawn diagrams are fine