Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering COSC 4460 Spring 2002 Hello, world!

Similar presentations


Presentation on theme: "Software Engineering COSC 4460 Spring 2002 Hello, world!"— Presentation transcript:

1 Software Engineering COSC 4460 Spring 2002 Hello, world!

2 Applet for “Hello,World!” import java.awt.Graphics; class HelloWorld extends java.applet.Applet { public void paint (Graphics g) public void paint (Graphics g) { g.drawString(“Hello, World!”, 10, 10); g.drawString(“Hello, World!”, 10, 10); } }

3 Review of Symbols Applet HelloWorld Graphics paint() class Generalization Dependency

4 Class Diagram for HelloWorld Applet HelloWorld Graphics paint() HelloWorld is a class. Applet is a class. HelloWorld inherits the properties of Applet and is a child of Applet. Graphics is a class. HelloWorld uses the paint method from Graphics.

5 Class A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics.A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics. A class implements one or more interfaces.A class implements one or more interfaces. You use classes to capture the vocabulary of the system you are developing.You use classes to capture the vocabulary of the system you are developing. Well-structured classes have crisp boundaries and form a part of a balanced distribution of responsibilities across the system.Well-structured classes have crisp boundaries and form a part of a balanced distribution of responsibilities across the system.

6 Identifying Classes in a Project Modeling a system involves identifying the things that are important to your particular view.Modeling a system involves identifying the things that are important to your particular view. These things form the vocabulary of the system you are modeling.These things form the vocabulary of the system you are modeling. If you are building a house, walls, doors, windows, cabinets, and lights are some of the important things.If you are building a house, walls, doors, windows, cabinets, and lights are some of the important things. Each has a set of properties.Each has a set of properties. For example, walls have height, witdth and color, doors also have height width and color, but also can open in or out. Lights could have a type, size and intensity.For example, walls have height, witdth and color, doors also have height width and color, but also can open in or out. Lights could have a type, size and intensity.

7 More on Class Properties Different users might care about different properties, so all users of the system must be considered in the decision of what properties to use.Different users might care about different properties, so all users of the system must be considered in the decision of what properties to use.

8 Attributes Class properties in UML are called attributes.Class properties in UML are called attributes. A class is shown in UML as a rectangle.A class is shown in UML as a rectangle. Shape origin width height move() resize() display() name attributes operations

9 Operations Operations can be defined in a class to change the value of properties or to perform some action, such as writing the property values.Operations can be defined in a class to change the value of properties or to perform some action, such as writing the property values. In Java, the operations are called methods.In Java, the operations are called methods. In C++, the operations are called functions.In C++, the operations are called functions.

10 Names in UML Every class must have a name.Every class must have a name. The “simple name” is just a string of characters.The “simple name” is just a string of characters. The “path name” is the simple name prefixed with the complete name of the package where the class is located.The “path name” is the simple name prefixed with the complete name of the package where the class is located. If a user defined class is not a part of a package, then it must be located in the same file or directory with the class that calls or uses it.If a user defined class is not a part of a package, then it must be located in the same file or directory with the class that calls or uses it. Rectangle Wall simple names path names java::awt::Rectangle house::structures::Wall

11 Names in UML Notice that class names start with a capital letter.Notice that class names start with a capital letter. Attribute and Operation names start with a lower case letter, with each word following the first word having the first letter capitalized.Attribute and Operation names start with a lower case letter, with each word following the first word having the first letter capitalized. height: Float width: Float isLoadBearing: Boolean = false Wall increaseHeight(increase: Float) increaseWidthByTen() Definition for class Wall

12 Stereotypes in UML You can add to the UML language using stereotypes.You can add to the UML language using stereotypes. > New() New(p: Policy) > Process(o:Order) … > isSuspect(o:Order) isFraudulent(o:Order) > validateOrder(o:Order) FraudAgent Definition for class Wall

13 Responsibilities A responsibility is a contract or obligation of a class.A responsibility is a contract or obligation of a class. Responsibilities are written in free-form text.Responsibilities are written in free-form text. They can be written in an extra box at the bottom of the class symbol, or they can be written as a note.They can be written in an extra box at the bottom of the class symbol, or they can be written as a note.

14 Responsibilities in a Class > New() New(p: Policy) > Process(o:Order) … > isSuspect(o:Order) isFraudulent(o:Order) > validateOrder(o:Order) FraudAgent Responsibilities --determine the risk of a customer order --handle customer-specific criteria for fraud responsibilities operations name attributes

15 Review of Symbols Applet HelloWorld Graphics paint() class Generalization Dependency

16 Class Diagram for HelloWorld Applet HelloWorld Graphics paint() HelloWorld is a class. Applet is a class. HelloWorld inherits the properties of Applet and is a child of Applet. Graphics is a class. HelloWorld uses the paint method from Graphics.

17 Figure 3-3 HelloWorld Inheritance Hierarchy ImageObserver Object Component Container Panel Applet HelloWorld HelloWorld is a child of Applet. Applet is a child of Panel. Etc. ImageObserver is an interface.

18 Root Package in Java java applet awt lang HelloWorld Each class in the class libraries lives in a package. Sometimes a package lives inside another package. java.applet.Applet shows the hierarchy of packages and classes.

19 Names Package namesPackage names –java.applet –java.lang –java.awt.image Class names (fully qualified)Class names (fully qualified) –java.applet.Applet –java.lang.Object –java.awt.Graphics

20 Components Physical pieces of the finished system.Physical pieces of the finished system. The Java compiler transforms the source code for a class into a component that can be executed.The Java compiler transforms the source code for a class into a component that can be executed.

21 HelloWorld Components hello.class hello.java hello.html hello.jpg

22 HelloWorld Components hello.class hello.java hello.html hello.jpg

23

24

25

26

27


Download ppt "Software Engineering COSC 4460 Spring 2002 Hello, world!"

Similar presentations


Ads by Google