UML OverviewUnified Modeling LanguageUML – symbology for diagrams+ public- private# protected~ protected<<abstract>><<singleton>><<interface>>A note or commentvisibility stereotypesUML – symbology for static (class) diagramsClass Name-------------instance attributesClass Attributes-------------object methodsClass Methodsinherits from (points to parent)implements this interfacecomposition (exclusively “owns it”)• contains it• the diamond on the owner• shows the multiplicity (0 or more)aggregation• references it • knows about it, doesn’t own it • the diamond is on the owner• shows multiplicity (1 to 1 or more)Points to an Instance of a classClass NamemyObjectName:Class11..**Note: class method or Attributes are underlined.An instance of a classis written as the instancename : the class nameand underlined.Note: two different waysto show a classUML (Unified Modeling Language) – Class Diagram<<abstract>> Vehicle-------------theSteeringWheel: WheelTire tires[4];Door doors[4];Engine engine; -------------int pressGasPedal(int force)int turnWheel(int degree)int pressBrake();getCurrentVelocity(): intF100Pickup-------------Bed bed;Color externalColor;Color tnteriorColor;Seat seats[2];-------------int pressBrake();boolean isDoorOpen(int doorNum);Camero-------------AlpineStereo stereo;Color externalColor;Color tnteriorColor;Seat seats[4];-------------int pressBrake();boolean isDoorOpen(int doorNum);UML styleVsMy Java style for writing attributes/method andreturn typesClass NameAttributesMethodsClassInheritanceAttribute nameArrayMethod ReturnMethod ParametersUML – modifiers & stereotypes<<abstract>> Vehicle--------------Wheel theSteeringWheel;-Tire tires[4];-Door doors[4];-Engine engine; -------------#int pressGasPedal(int force)+int turnWheel(int degree)int pressBrake();~int getCurrentVelocity();F150Pickup--------------Bed bed;-Color externalColor;-Color tnteriorColor;-Seat seats[2];-------------boolean openDoor(int doorNumber);boolean isDoorOpen(int doorNum);Camero--------------AlpineStereo stereo;-Color externalColor;-Color interiorColor;-Seat seats[4];-------------boolean openDoor(int doorNumber);boolean isDoorOpen(int doorNum);privateprotectedpublicunspecifiedpackageIs APickupTruck--------------Wheel wheels[4];Seat seats[2];FordF150------------CargoBed bed;TowHitch towHitch;Is A2 instances of a ClassPrinter-------------Print(int.int)GreenPrinter-------------Print(int.int)Is A (also called Specialization)Method OverridingbillsFordF150PickupnafisasPickupPolymorphic Classes Represented in UMLPolygon-----------numberOfSides : int =0area : float = 0.0-----------computeArea(): float <<abstract>>Square---------numberOfSides=4---------Square(float)computeArea(): floatTriangle---------numberOfSides=3---------Triangle(float,float, float)computeArea(): floatComputer class (UML)<<abstract>>Computer<<interface>> IUSBInterface<<interface>> ISerialInterface<<interface>> IVideoCardInterfaceNonmodularComputer<<interface>> IDeviceTypesmyNonmodularComputre:NonmodularComputerIs AImplementsIs An Instance OfClass DefObject InstanceComputerV2 class (UML)<<abstract>>ComputerV2---------------- serialIF: ISerialInterface- USB_IF IUSBInterface- videoCardIF IVideoCardInterface---------------+ ComputerV2()<<interface>> IUSBInterface<<interface>> ISerialInterface<<interface>> IVideoCardInterfaceSuperDeluxoComputer<<interface>> IDeviceTypesmySuperDeluxoComputer:SuperDeluxoComputeruses composition insteadof inheritanceIs An Instance OfInheritance<<abstract>>Vehicle--------------------Wheel wheels[];Seat seats[];Car------------------Trunk trunk;Wheels wheels[4];Seat seats[4];<<abstract>>PickupTruck---------------CargoBed bed;Wheels[4]Seats seats[2];<<interface>>ISteerable----------------------float Turn(float degree);SteeringWheel-----------------turn(float degree):floatImplements AIs AHas AMotorcycle--------------------Wheels wheels[2];Seat seats[1];HandleBar-----------------float turn(float degree);Has AIs AIs ANote: UML allows two styles for writing methods and attributes. The java style and the more general way.)Telephone class<<abstract>>Telephone-------------------------Color color;-String phoneNumOfTelephone;-String phoneType;-boolean inAPhoneCall=false;------------------------getAConnection():booleanboolean makeACall(String num);boolean talk(String whatToSay);String listen();boolean hangUp();<<interface>> IDialerDevice------------------dial(String number): boolean;DeskPhone----------------------------CordlessPhone----------------------------<<interface>> ISoundInputDevice--------------------------------------------------------getSoundIn(Sound soundReceived)<<interface>> ISoundOutputDevice----------------------------------------------putSoundOut(Sound sound);changeVolume(float percentage)mute(boolean muteOn);UML styleVsMy Java stylePayPhone and TV classes<<abstract>>PayPhone-------------------------float amountDepositied;-CoinSlot myCoinSlot;-CoinReturn myCoinReturn;------------------------boolean insertCoin(float coin);float pressCoinReturn();<<interface>> IDialerDevice----------------------------------------------------dial(number)<<interface>> ISoundInputDevice--------------------------------------------------------getSoundIn(Sound soundReceived)<<interface>> ISoundOutputDevice----------------------------------------------void putSoundOut(Sound sound);void changeVolume(float percentage)void mute(boolean muteOn);<<abstract>>Telephone----------------------------<<abstract>>TV----------------------------Subclasses – abstract and concrete<<abstract>>Fax<Machine<<interface>> IAbilityToDial<<interface>> IAbilityToInputSound<<interface>> IAbilityToOutputSound<<abstract>>Telephone<<abstract>>CellPhone<<abstract>>SpeakerPhoneBlackberrymyBlackberryNotation shows aninstance of a class<<interface>>
View Full Document