Fundamentals of Software Development 1Slide 1 Today’s Summary UML class diagrams – –Why classes are important – –UML class diagrams – relationships – –UML.

Slides:



Advertisements
Similar presentations
Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Advertisements

Fundamentals of Software Development 1Slide 1 Recap: Constructors, the new operator and the this object Three ideas:Three ideas: –How to write a constructor.
Fundamentals of Software Development 1Slide 1 Today’s Summary Statements: Conditionals (if-then-else)Statements: Conditionals (if-then-else) Investigated.
Fundamentals of Software Development 1Slide 1 Review: Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote.
Fundamentals of Software Development 1Slide 1 Today’s Summary Hello World concepts – –main, static, console Programming patterns involving assignment and.
Fundamentals of Software Development 1Slide 1 Why have interfaces? A Java interface is the “face” that one class shows othersA Java interface is the “face”
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
Fundamentals of Software Development 1Slide 1 One class can describe many different instancesOne class can describe many different instances –Two NameDroppers,
Chapter 71 Inheritance Chapter 7. 2 Reminders Project 4 was due last night Project 5 released: due Oct 10:30 pm Project 2 regrades due by midnight.
Fundamentals of Software Development 1Slide 1 Interfaces Outline:Outline: –Generic interface versus Java interface –What a (Java) interface is: Its syntaxIts.
Structured Programming and UML Overview Session 2 LBSC 790 / INFM 718B Building the Human-Computer Interface.
1 Classes, Encapsulation, Methods and Constructors Class definitions Scope of Data –Instance data –Local data The this Reference Encapsulation and Java.
C++ Classes in Depth. Topics Designing Your Own Classes Attributes and Behaviors Writing Classes in C++ Creating and Using Objects.
Fundamentals of Software Development 1Slide 1 Method invocation versus definition To define (write) a method means to write its codeTo define (write) a.
Modular Programming and Use Case Models Session 3 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Objectives Explain the purpose and objectives of object- oriented design Develop design class diagrams Develop interaction diagrams based on the principles.
Fundamentals of Software Development 1Slide 1 UML class diagrams: Outline Why types / classes are importantWhy types / classes are important –Why types.
Fundamentals of Software Development 1Slide 1 Today’s Summary Things, types and names – –What are names? types? – –Why use names? – –How to use a name:
(c) University of Washington03-1 CSC 143 Java Inheritance Reading: Ch. 10.
Object Oriented Software Development
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first.
Writing Classes (Chapter 4)
CSCI-383 Object-Oriented Programming & Design Lecture 9.
Fundamentals of Software Development 1Slide 1 Recap: Key ideas in WordGames Defining a classDefining a class Extending a class versus implementing an interfaceExtending.
Java Classes Using Java Classes Introduction to UML.
Fundamentals of Software Development 1Slide 1 Today’s summary Attitudes toward learning:Attitudes toward learning: –Working in groups –Learning by doing.
Introduction To System Analysis and Design
Object-Oriented Analysis and Design An Introduction.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Fundamentals of Software Development 1Slide 1 UML class diagrams: What are they? Unified Modeling Language (UML)Unified Modeling Language (UML) –“A family.
Design Class Diagrams (DCDs)
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Programs and Classes A program is made up from classes Classes may be grouped into packages A class has two parts static parts exist independently Non-static.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
Chapter 5 Introduction to Defining Classes
EGR 2261 Unit 11 Classes and Data Abstraction  Read Malik, Chapter 10.  Homework #11 and Lab #11 due next week.  Quiz next week.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
 Implementing a class ◦ Implementing an interface ◦ Using documented stubs before coding ◦ Writing JUnit tests before coding ◦ Using fields CSSE 220 Object-Oriented.
Class Diagrams Chapter 3. Classes and Objects Classes are the descriptions –definitions Objects are the things –instances.
1 Unified Modeling Language Michael K. Wildes University of California, Riverside – Extension Program Presentation 2.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
Unified Modeling Language (UML)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
UML2-1 UML Exercise A "draw" utility program lets users draw several geometric objects on a diagram. A geometric object may be a Circle, Rectangle, Square.
Object Oriented Analysis & Design By Rashid Mahmood.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Unit 1 - Introducing Abstract Data Type (ADT) Part 1.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.
Fundamentals of Software Development 1Slide 1 Today’s Summary InterfacesInterfaces –What are they? –Why are they important? –How do they relate to WordGames?
Fundamentals of Software Development 1Slide 1 Recap: Key ideas in BallWorlds so far Writing a class:Writing a class: –structure –process Writing methods:Writing.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Recap: Key ideas in WordGames
Recap: The design of Word Games
Object-Oriented Concepts
Winter 2018 CMPE212 9/21/2018 CMPE212 – Stuff…
Creating and Using Classes
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Defining Classes and Methods
Winter 2019 CMPE212 4/5/2019 CMPE212 – Reminders
Fundamentals of Software Development 1
Presentation transcript:

Fundamentals of Software Development 1Slide 1 Today’s Summary UML class diagrams – –Why classes are important – –UML class diagrams – relationships – –UML class diagrams – details for each class MethodsMethods –Invoking a method –Defining a method Summarized on the next few slides Summarized on the slides after the above summary

Fundamentals of Software Development 1Slide 2 Why classes are important What does an object’s type tell you? – –Answer: How the object operates! What attributes the object has What operations the object can do Fact: The type of an object is simply the name of the class to which the object belongs What can you conclude from the above statements? The class (i.e. type) of an object tells you how the object operates!Answer: The class (i.e. type) of an object tells you how the object operates! Questions?

Fundamentals of Software Development 1Slide 3 Review: UML class diagrams What they areWhat they are –A notation to assist object-oriented design (not just Java) Why use UML?Why use UML? –UML as sketch To figure out a designTo figure out a design To communicate ideas and alternativesTo communicate ideas and alternatives –UML as blueprint To convey the design to the coderTo convey the design to the coder –UML as programming language To generate code automatically from the designTo generate code automatically from the design This is how we (and most people) use UML class diagrams – as a tool to help our thinking

Fundamentals of Software Development 1Slide 4 Review: UML class diagrams – relationships-only Order Line Product Corporate Customer OrderCustomer Personal Customer Employee salesRep is-a (by extending a class) is-a (by implementing an interface) has-a 1means one *means 0 or more 1.. *means 1 or more 0.. 1means 0 or 1 lineItem 1 * * * * Questions?

Fundamentals of Software Development 1Slide 5 UML class diagram with details Together, let’s examine JavaEyes and fill in the details for the EyeBall class in the UML class diagramTogether, let’s examine JavaEyes and fill in the details for the EyeBall class in the UML class diagram What are the attributes? Their types?What are the attributes? Their types? –Any comments needed? What are the operations? Their types?What are the operations? Their types? –Any comments needed? EyeBall eyeBallColor : Color xPosition : int yPosition : int radius : int EyeBall(Color eyeBallColor) draw( Graphics graphics) look(int x, int y) Moves the EyeBall to follow the mouse to the given (x, y) point There are two ways to show an object-type attribute: Draw a HAS-A arrow to it List it in the detailed box Choose the former if you want to emphasize the relationship Sets the EyeBall color to the given color Questions?

Fundamentals of Software Development 1Slide 6 Method invocation versus definition “There is a difference between knowing the path and walking the path.” ~ Morpheus“There is a difference between knowing the path and walking the path.” ~ Morpheus “There is a difference between defining a method and invoking a method.” ~ CSSE Prof.“There is a difference between defining a method and invoking a method.” ~ CSSE Prof.

Fundamentals of Software Development 1Slide 7 Method invocation versus definition To define (write) a method means to write its codeTo define (write) a method means to write its code –The code is a recipe to follow when the method runs –Methods often have parameters – information that comes into the method when it is run To invoke (call, run) a method means to cause the method’s code to runTo invoke (call, run) a method means to cause the method’s code to run –Sending it actual values to substitute for the formal parameters of the method Example (on next slides)Example (on next slides)

Fundamentals of Software Development 1Slide 8 Method invocation versus definition To define (write) a method means to write its codeTo define (write) a method means to write its code To invoke (call, run) a method means to cause the method’s code to runTo invoke (call, run) a method means to cause the method’s code to run Example (on next slide):Example (on next slide): –The NameDropper class in the blue box defines: A field called myName to hold the NameDropper’s name to dropA field called myName to hold the NameDropper’s name to drop A constructor called NameDropper that takes the name to store in the fieldA constructor called NameDropper that takes the name to store in the field A method called transform that takes a phrase to tranformA method called transform that takes a phrase to tranform –The statements in the yellow box cause the NameDropper constructor and transform method to run They each run several times, with different actual arguments substituted for the formal parameters in the NameDropper definitionThey each run several times, with different actual arguments substituted for the formal parameters in the NameDropper definition These statements would themselves appear in some other classThese statements would themselves appear in some other class

Fundamentals of Software Development 1Slide 9 public class NameDropper extends StringTransformer implements StringTransformable { private String myName; public NameDropper(String nameToUse) { this.myName = nameToUse; } public transform(String phrase) { return this.myName + “says ” + phrase; } } NameDropper person1, person2, person3; person1 = new NameDropper(“Calvin”); person2 = new NameDropper(“Hobbes”); person3 = new NameDropper(“lobster”); person1.transform(“you look funny today, Hobbes.”); person2.transform(“you looker even funnier.”); person1.transform(“no, YOU look funnier.”); person3.transorm(“I amd just a lonely lobster.”); Definition of the NameDropper class Invoking the NameDropper constructor and transform method

Fundamentals of Software Development 1Slide 10 What’s Ahead? Before the next session:Before the next session: –Do Homework 6 (no late homework!) Including the reading and the associated online quizIncluding the reading and the associated online quiz –Next session: WordGames - Implementing your own classes!WordGames - Implementing your own classes! Reminder: Find the homework assignment from the Schedule page of the CSSE 120 Angel site angel.rose-hulman.edu Suggestion: Routinely do your homework in F-217 (CSSE lab). A student assistant is there every Sunday through Thursday evening, 7 pm to 9 pm, so you can get immediate answers to any questions you might have.