CS2110: SW Development Methods Design of methods (functions) Class design – CRC cards – UML class and sequence diagrams Software Design.

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

Modeling Main issues: What do we want to build How do we write this down.
Modeling Main issues: What do we want to build How do we write this down ©2008 John Wiley & Sons Ltd. vliet.
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Use Case - Example University library system requirements
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Objects First With Java A Practical Introduction Using BlueJ Designing object-oriented programs How to write code in a way that is easily understandable,
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Interfaces. In this class, we will cover: What an interface is Why you would use an interface Creating an interface Using an interface Cloning an object.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating.
Chapter 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
SOS OOP Fall 2001 Object Oriented Programming in Java Week 1 Read a design Design a small program Extract a design Run a VAJ program Change that program,
© Copyright Eliyahu Brutman Programming Techniques Course.
CS 501: Software Engineering Fall 2000 Lecture 12 Object-Oriented Design II.
UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation.
Introductory case study. 2 The problem The most difficult part of any design project is understanding the task you are attempting You have been contacted.
Software Engineering Case Study Slide 1 Introductory case study.
CS 4240: The OO Paradigm Revisited Readings: Chap. 1 of Design Patterns Explained OO (some review) Coupling, cohesion.
Use Case Diagram : Library System
Introduction To System Analysis and design
Systems Analysis and Design in a Changing World, Fifth Edition
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.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
High-Level Design With Sequence Diagrams COMP314 (based on original slides by Mark Hall)
1 Object orientation. 2 What benefits does OO give? Primarily –Encapsulation (Associates data & operations) –Types & specialisation –Software re-use.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Chapter 17 GRASP: Designing Objects with Responsibilities. 1CS6359 Fall 2011 John Cole.
Computer Science II 810:062 Section 01. How is CS I different from CS II? When you teach Java there are a series of decisions that have to be made…
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Systems Analysis and Design in a Changing World, 3rd Edition
Information System Design (IT60105) Lecture 26 Object-Oriented System Testing.
Object Oriented Software Development
Object-oriented Design and Programming CS 2210: SW Development Methods Reading: Chapter 2 of MSD text – Section on UML: look at class diagrams but.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Object-Oriented Principles Applications to Programming.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
OOP Review CS 124.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
CSCE 240 – Intro to Software Engineering Lecture 3.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
Copyright © Jim Fawcett Spring 2017
GRASP – Designing Objects with Responsibilities
Algorithms and Problem Solving
Main issues: • What do we want to build • How do we write this down
Week 10: Object Modeling (1)Use Case Model
Start at 17th March 2012 end at 31th March 2012
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
Interfaces and Inheritance
Programming Logic and Design Fourth Edition, Comprehensive
Algorithms and Problem Solving
Lecture 8 Object Concepts
CS 501: Software Engineering
Presentation transcript:

CS2110: SW Development Methods Design of methods (functions) Class design – CRC cards – UML class and sequence diagrams Software Design

Old problems Before OO, many languages followed the procedural paradigm –A program was based on functions that worked like static methods in Java –A “main” function started things functional decomposition –Break problem down –Function deals with subproblem –Hierarchical. Levels of abstraction Problems: –Control and coordination centered in main method –Required changes have big impacts –Logic may be distributed –Data changes affect may modules

Functions: What we call them: functions, methods, modules Functions are a core construct in OO and non-OO programs Principals of good functions apply in either language –But less of a problem in OO – can you think why?

What makes a function good? Your answers:

Good qualities in functions: Lots written about this! Clean Code: A Handbook of Agile SW Craftsmanship Robert C. Martin –Read Chapter 3 in UVa digital library version

Good Qualities in Functions Small –How small? Do One Thing: Strong Cohesion –Why? –One level of abstraction per function Thus, functions fall into levels of abstraction –Name reflects the one task it does

Interface Qualities of Functions What about its interface? –Inputs, return value/arguments –Other sources of data or “output” Side effects Some rules?

Good Qualities in Functions (2) Number of arguments: small Flag arguments –What are they? What bad thing do they suggest is happening? Avoid side effects Avoid “output” arguments –Arguments that are changed after the function executes –Java: possible for “mutable” classes

Good Qualities in Functions (3) Don’t Repeat Yourself (DRY) Command/Query Separation –Do something. Or answer something. Don’t do both. Returning Errors –Return value? Output argument? Burden on caller? –Exceptions: what advantages?

Classes So far we ’ ve just talked about objects We note that many objects are a “ type of ” the same kind of thing – The same “ abstraction ” – E.g. 1, 2, 7 and 10 – whole numbers – E.g. 1, 3.5, 25, pi – numbers – Bob, Sally, Joe – Students But, they are Persons too, aren ’ t they? – cs201, cs202, engr162 – Courses

Classes, Type Classes define a set of objects with the same properties (state, behavior) A class definition serves as a “ cookie cutter ” for creating new objects – Instantiation of an object of a certain class – In Java, we do this with new and a constructor is called – Creates an individual object, also called an instance Variables and data objects have a type – What the rules are for that object – An object ’ s class is one form of object-type Also any superclass it extends, and any interface it implements

Finding Classes from Specifications Study the textbook, Sect Next In-Lab exercises – Several problems for groups to do in lab – Later you ’ ll get sample solutions for all these problems

Sample Problem: Library Loans Problem overview: Imagine you were going to write a set of classes that would be part of a software system to support loans in a library. A description might be: The library contains books and journals. It may have several copies of any given book. Books and journals have titles and a call-number. Each copy has a copy-number. For each book we record the author. Some of the books are on "reserve" and can only be checked-out for 3 hours, but all other books can be borrowed as a regular loan (for a three week period). Members of the library can normally borrow up to six items at a time, but staff members can borrow up to ten items. Members of staff can borrow journals, but not regular members. The system must keep track of when books and journals are borrowed and returned. Our system might want find out what items have been borrowed by a given member, and which copies of an item have been checked out and by whom.

Class Identification What are possible classes here? Why? How do you recognize classes? What makes a good class name?

Sample Problem: Library Loans Problem overview: Imagine you were going to write a set of classes that would be part of a software system to support loans in a library. A description might be: The library contains books and journals. It may have several copies of any given book. Books and journals have titles and a call-number. Each copy has a copy-number. For each book we record the author. Some of the books are on "reserve" and can only be checked-out for 3 hours, but all other books can be borrowed as a regular loan (for a three week period). Members of the library can normally borrow up to six items at a time, but staff members can borrow up to ten items. Members of staff can borrow journals, but not regular members. The system must keep track of when books and journals are borrowed and returned. Our system might want find out what items have been borrowed by a given member, and which copies of an item have been checked out and by whom.

Methods and Fields Pick a class: name its methods and fields

Class Relationships Do any classes have “ structural links ” to other classes? –“ link ” might mean “ part-of ” relationship. – This is a static relationship – Are such “ links ” one-to-one, one-to-many? Which objects might call methods on objects of another class? – This is a dynamic relationship (while the program is running)

Another View on Defining Classes Classes have – Responsibilities In words: what is its role? Data encapsulation and management? Organizer of other objects? Some level of control or task-execution? Methods implement these – Relationships Static connections to other objects Dynamic interactions with other objects

The CRC Card Technique Read info on “CRC cards” here: odel.htm odel.htm