Copyright W. Howden1 Lecture 8: O/O Programming. Copyright W. Howden2 Topics OO Programming Languages Developing programs from Designs –Class and method.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

J-Unit Framework.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Testing Object Oriented Programs CSE 111 4/28/20151.
Copyright W. Howden1 Singleton, Wrapper, and Facade Patterns CSE 111.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Lecture 5a: Sequence Interaction Diagrams CSE 111 Copyright W. Howden1.
Copyright W. Howden1 Lecture 3: Elaboration and System Architecture.
Copyright W. Howden1 Lecture 6: Design Evaluation and Intro to OO Design Patterns.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Copyright W. Howden1 Lecture 11: UML Terminology and Additional Models and Notation.
Copyright W. Howden1 Lecture 13: Programming by Contract.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Copyright W. Howden1 Lecture 4: Sequence Interaction Diagrams.
Copyright W. Howden1 Lecture 14: Callbacks, Singletons and Wrappers.
Copyright W. Howden1 Lecture 5: Collaboration Diagrams.
Lecture 5b: Basic Design Patterns CSE 111. Basic Design Patterns We know our subsystem interface classes and (some of) their methods We need to create.
System Architecture Lecture 3 CSE 111 Spring /22/20151Copyright William E. Howden.
1 Lecture 2: Elaboration Tasks and Domain Modeling.
Copyright W. Howden1 Lecture 15: Generalization, Polymorphism and States.
Copyright W. Howden1 Lecture 6: Collaboration Diagrams.
Copyright W. Howden1 Lecture 2: Elaboration Tasks and Domain Modeling.
Lecture a: Additional UML Models: Package, Activity, Deployment Lecture b: Generalization, Aggregation and Additional Domain Model Notation Copyright W.
Copyright W.E. Howden1 Lecture 16: Factories and Frameworks.
Abstract Data Types and Encapsulation Concepts
Copyright W. Howden1 State Models and the State Pattern.
Lecture 7: UML Class Diagrams CSE 111 7/15/20151Copyright W. Howden.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
Object-Oriented Analysis and Design
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Object-Oriented Software Testing. C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are.
Mapping Designs to Code Larman, Chapter 20 CSE432 Object Oriented Software Engineering.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Systems Analysis and Design in a Changing World, 3rd Edition
Chapter 8 - Additional Inheritance Concepts and Techniques1 Chapter 8 Additional Inheritance Concepts and Techniques.
Design Model Lecture p6 T120B pavasario sem.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Software Engineering Lecture 8 Object-Oriented Analysis.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
Topic: Junit Presenters: Govindaramanujam, Sama & Jansen, Erwin.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CSCE 240 – Intro to Software Engineering Lecture 3.
ISBN Chapter 12 Support for Object-Oriented Programming.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Abstract Data Types and Encapsulation Concepts
7.1 What Is An Object Object-oriented program - Description or simulation of application Object-oriented programming is done by adopting or extending an.
Chapter 3: Using Methods, Classes, and Objects
Abstract Data Types and Encapsulation Concepts
Lecture 4: Sequence Interaction Diagrams
Copyright 2007 Oxford Consulting, Ltd
Basic OOP Concepts and Terms
Object-Oriented PHP (1)
2.1 Introduction to Object-Oriented Programming
Presentation transcript:

Copyright W. Howden1 Lecture 8: O/O Programming

Copyright W. Howden2 Topics OO Programming Languages Developing programs from Designs –Class and method definition –Structuring the set of program classes Testing for Object Oriented programs

Copyright W. Howden3 OO Programming Languages Simula (Simulation) SmallTalk (AI Community) C++ (C) Eiffel (Software Engineering, CASE) Java (Devices) C# (Copyright Problems)

Copyright W. Howden4 Sample Differences ConceptSmalltalkC++Java Garbage Collect.  Pointers  Inheritancesinglemultiplesingle Interface Class  Root Object Class  Type checking  (run)  Abstract Class  (  enf) 

Copyright W. Howden5 Seminal O/O Ideas Information hiding –Construct modules/components where you access information via operations that hide how it was implemented Abstract Data Types –Original information hiding idea

Copyright W. Howden6 Abstract Data Types Abstract objects and a set of operations on them Implementation is not part of definition Definition of object given by axioms involving objects and operations

Copyright W. Howden7 List ADT Definition Constructors: s = observersNilprepend(n,s’) null?(s)TrueFalse head(s)Errorn tail(s)Errors’

Copyright W. Howden8 ADT’s and OO Classes Alternative points of view 1. Classes define implementations of ADT specifications 2. ADT’s are for simple algebraic objects such as numbers and lists. Classes are for more complex structures. 3. Alternative forms of abstraction ADT’s: type abstraction O/O Classes: procedural

Copyright W. Howden9 Developing Programs from Designs Order of implementation strategy GUI layout details Class Definitions Method definitions

Copyright W. Howden10 Order of Implementation Bottom up Top Down Least-Coupled First

Copyright W. Howden11 Bottom Up Functional Design Strategy –Start with functions at the bottom of the design tree –Need drivers to carry out tests Application to OO Designs? –Objects which receive messages but do not send them –E.g. DS MemberData

Copyright W. Howden12 Top Down Functional Design Strategy –Start with functions at the top of the design tree –Need stubs to carry out tests Application to O/O designs? –Objects which send messages but do not receive them –E.g. DS Start class, GUI Frame, etc.

Copyright W. Howden13 Least-Coupled First Rationale? –Easier to do unit testing E.g. DS –LogOn class in DomainLogic Our approach for DS: implement each subsystem separately: e.g. GUI, DL, DB

Copyright W. Howden14 GUI Layout Information sources –Interaction sequence diagrams Forms through which the user interacts –Collaboration diagrams Frame and Dialog Objects used in Design

Copyright W. Howden15 Screens and Interaction Diagrams

Copyright W. Howden16 Sample DS GUI Layout

Copyright W. Howden17 Class Definition Map from UML Class description to PL (Java) class definition Determine class visibility in class definitions Additional Details. E.g. –For GUI classes determine event management strategy –Additional classes

Copyright W. Howden18 Dating system example GUI class definition

Copyright W. Howden19

Copyright W. Howden20

Copyright W. Howden21 Class Visibility All dialog classes except Message will be defined as inner classes of GUIFrame Message will be top level globally visible class DomainLogic package will be imported, to get visibility to this class

Copyright W. Howden22 GUI Event Strategy Need actionperformed(ActionEvent e) methods for processing button pushes Declare that GUI (and the dialogs) implement ActionListener. Adopting strategy where we attach the event processing methods directly to the units that contain the event causing components

Copyright W. Howden23 Aditional Detailed Classes? E.g. Primitive data type parameters in Java are call by value Will need to define simple classes to allow call by reference class BooleanRef {public boolean val; public BooleanRef(){} }

Copyright W. Howden24 public class GUI extends Frame implements ActionListener {private Button start; private Button end; public DomainLogic domainLogic; private LogOnDialog logOnDialog; private MemberCommandsDialog memberCommandsDialog; private AdminCommandsDialog adminCommandsDialog; private int userType; public String userName; private MessageDialog message; public GUI(DomainLogic dL) {....} public void actionPerformed(ActionEvent e){... } class LogOnDialog extends Dialog implements ActionListener {...} class MemberCommandsDialog extends Dialog implements ActionListener {... } class AdminCommandsDialog extends Dialog implements ActionListener {... } class GetMemberNameDialog extends Dialog implements ActionListener {... } class SelectDaterPreferencesDialog extends Dialog implements ItemListener,ActionListener {...} class EnterMemberDataDialog extends Dialog implements ActionListener {... } class SelectedDateeDialog extends Dialog implements ActionListener {... } }

Copyright W. Howden25 Method Definition Object receives a message -> corresponding class method Method logic: –Examine Collaboration diagram for object responses to messages

Copyright W. Howden26 Dating system example Domain Logic method definition

Copyright W. Howden27

Copyright W. Howden28 String setMemberData(String name, dateeData dD) {String userName; MemberData memberData; userName = logOn.getUserName; if (userName == name) {memberData = dB.getMemberData(userName); if (memberData =/ null) {memberData = memberData.setDateeData(dD); dB.updateMemberData(memberData) return “UpdateMade”; } return “NotAMember”; } return “notLoggedOn”; }

Copyright W. Howden29 Introduction to Object Oriented Testing Unit testing Test individual classes or small groups of classes during development Test first programming Write the class tests before the class Functional testing Use test scripts that describe a sequence of program interactions and behavior verifications for system testing

Copyright W. Howden30 Self Testing Classes Class has a main method that is used for testing Main method: –Creates an instance of the class –Calls class methods that change the state –Calls class methods that verify results of a test May require special test methods in CUT (Class Under Test)

Copyright W. Howden31 Test Case Collection of test and verify methods Main method –Creates instance of class under test –Performs initialization –Runs test methods Could be self-testing class or separate class

Copyright W. Howden32 Tests and Test Suites Test = TestCase or TestSuite TestSuite = Collection of Tests

Copyright W. Howden33 TestRunners Special class whose instances run tests Execute a TestRunner with Test Object Test runners capabilities –Fully automatic: execute all test cases –StepAndWait: user approval to go to next test case –Error reports: accept from test cases

Copyright W. Howden34 J-Unit OO Unit Test Framework A TestRunner with a GUI interface –Executes a test suite Classes that you can use to set up test suites of test cases, to be run by TestRunner. E.g. TestSuite contains an add method for adding test objects to a test suite object E.g. test cases are instances of a class that subclasses TestCase and inherits a runTest() method that is called by TestRunner

Copyright W. Howden35 J-Unit Usefulness Nifty use of OO mechanisms, in order to make it work Provides user with a nice interface for running tests Easier to create your own test suites and test cases, than to figure out how to use it