1 G4MICE Design Iteration Malcolm Ellis Imperial College Saturday 3 rd April 2004.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Lecture 18 Templates, Part II. From Last Time: What is a Template? This is the “official” specification for a template. It says that to define a template.
Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions.
COMP171 Data Structure & Algorithm Tutorial 1 TA: M.Y.Chan.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Rossella Lau Lecture 8, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 8: Polymorphism & C++ pointer  Inheritance.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
OOP Spring 2006 – Recitation 31 Object Oriented Programming Spring 2006 Recitation 3.
1 Mouse Cases M.Ellis/Y.Torun Wednesday 31 st March 2004.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
CSE 332: C++ Classes From Procedural to Object-oriented Programming Procedural programming –Functions have been the main focus so far Function parameters.
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
Object-Oriented Design. From Analysis to Design Analysis Artifacts –Essential use cases What are the problem domain processes? –Conceptual Model What.
Object Oriented Software Development
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Object Oriented Programming Philosophy. Part 1 -- Basic Understanding & Encapsulation.
Recap, Test 1 prep, Composition and Inheritance. Dates Test 1 – 12 th of March Assignment 1 – 20 th of March.
4.1 Instance Variables, Constructors, and Methods.
1 G4MICE Design Iteration Malcolm Ellis MICE Video Conference 21 st April 2004.
1 Recon tests, Sci Fi status and Sci Fi design iteration Malcolm Ellis MICE Software Phone Meeting Wednesday 28 th April 2004.
Names and Scope. Scope Suppose that a name is used many times for different entities in text of the program, or in the course of execution. When the name.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Chapter 13. Procedural programming vs OOP  Procedural programming focuses on accomplishing tasks (“verbs” are important).  Object-oriented programming.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures C++ Review Part-I.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Structural Modeling Chapter 7. Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes in.
1 Structural Modeling Chapter 7. 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes.
Classes Representing Non-Trivial Objects. Problem Write a program that reads a temperature (either Fahrenheit or Celsius), and displays that same temperature.
Object Oriented Software Development
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Copyright © 2002 W. A. Tucker1 Chapter 10 Lecture Notes Bill Tucker Austin Community College COSC 1315.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Function Overloading and References
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (next Friday). After today you should know everything you need for assignment.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Module 7: Constructors #1 2000/2001Scientific Computing in OOCourse code 3C59 Module 7: Constructors and Destructors: In this module we will cover: Constructors.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More about.
Module 9: Operator overloading #1 2000/01Scientific Computing in OOCourse code 3C59 Module 9: Operator Overloading In this module we will cover Overloading.
Object-Oriented Programming Review 1. Object-Oriented Programming Object-Oriented Programming languages vary but generally all support the following features:
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Motivation for Generic Programming in C++
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
Review: Two Programming Paradigms
Chapter 5 Classes.
Abstract Classes and Inheritence Operator over-loading
More about OOP and ADTs Classes
Templates.
Creating and Using Classes
The Object-Oriented Thought Process Chapter 05
More about OOP and ADTs Classes
Dr. Bhargavi Dept of CS CHRIST
Classes and Objects.
CISC/CMPE320 - Prof. McLeod
ENERGY 211 / CME 211 Lecture 8 October 8, 2008.
SPL – PS3 C++ Classes.
Object Oriented Programming
Presentation transcript:

1 G4MICE Design Iteration Malcolm Ellis Imperial College Saturday 3 rd April 2004

2 Tasks for this workshop Saturday - Complete User Requirements Monday - Architectural Design – people should think about it over Sunday however! Tuesday - Detailed design rationale and CRC workshop Wednesday – Finalise interfaces and documentation, agree on responsibilities, coding “rules” and testing procedures Everyone returns home and starts detailed design

3 Some coding suggestions 7 ± 2 Rule – methods should not have too many lines! Methods which have no or very little functionality should be inline after the class declaration. Do not pass parameters by copy, prefer in order: const reference, reference, pointer All methods that can be declared const should be. Each package should have a clear policy on the ownership of newed objects (perhaps even for the whole software?) Be sure not to return pointers or references to temporary objects. Doxygen comments as you write the code!

4 More ideas… Use prefix ++ on iterators If method needs to return a class, and you would normally return a NULL pointer to indicate failure – consider instead using an “unhappy object”. Always give a concrete definition for the copy constructor, assignment operator and destructor (even for virtual classes). If you don’t want to define one, then at least declare it as private! When using pointers, always set them to NULL immediately after deleting them. Be careful not to have return with no argument in non- void functions.

5 In Addition How keen are we to do things in an Object Oriented manner? I’ve assumed that we are, but maybe there are other opinions? If we are doing this OO, then by definition there shall be no public or friend variables in classes, nor shall there be any global variables. We should definitely avoid making the classes de-facto C structs with set/get methods: Triplet point(); point.setVhit( h1 ); point.setXhit( h2 ); point.setWhit( h3 ); Triplet point( h1,h2, h3 );

6 Possible requirements for code acceptance Compiles with no warnings (exceptions may be necessary due to external packages, e.g. GEANT4). Passes all reference tests (Unit and System) for the package. Does not contain any hard-coded constants. Code containing new functionality should be supplied with reference tests whenever possible.

7 User Requirements Purpose is to describe the features and capabilities of our software. They will help to formalise the meaning and tasks of the various objects. We do not need to drag this process out, but should ensure that we cover all the areas listed in the Use Cases

8 Architectural Design Not enough time for detailed design, however the definition of the subsystems and in particular the interfaces between them is crucial. Keep references between requirements and subsystems of the domains diagram. Avoid discussions of implementation or similar detail – that is for the detailed design stage, which will be started at the end of the workshop. Detailed design will be done by everyone after the workshop.

9 Possible New Domains Persistent implementation of whatever transient classes we end up with (maybe similar to the HARP iDST system?) G4Beamline? Detector/Experiment Modelling and Representations Any others? We shall find out on Monday!

10 CRC Workshop Class Responsibility Collaboration Role-play where we all pretend to be instances of candidate objects Use cards to record details of the class and its responsibilities. Methods are visible to everyone, state (variables) are not. Three principle aims: –Refuse responsibilities (with justification!) –Minimise workload (delegate) –Empower collaborators Usually part of detailed design – still useful now

11 Example Sci Fi Diagram SciFiDoubletCluster SciFiDoubletCluster( const SciFiDigi& ) const ScidiFigi& digi() const int tracker() const Hep3Vecor position() const Hep3Vector direction() const const SciFiDigi& m_digihit … 1 SciFiDigi SciFiDigi( ??? ) int tracker() const int station() const int plane() const int fibre() const int adc() const int m_tracker int m_station …

12 Refuse Responsibilities For each request, each object should ask itself: –Should I? (that is, does this request fall outside of the “thing” that I am supposed to represent) –Could I? Have I been given enough information Am I clear exactly what is needed Do I have the information (state) to perform the task –These questions test the Interface and Implementation of the class.

13 Delegate Tasks Just because you (the class) have accepted the responsibility, it does not mean that you have to do everything! If you have access to another object (or objects) which are suitable to perform the task (or some part of it) then forward the request. Simple example – SciFiDoubletCluster::tracker() method could ask the SciFiDigi class what the tracker number is

14 Empower Collaborators It should not be necessary to know how classes work, and it is preferable not to access classes which are too far away (along links). Prefer: –SciFiKalTrack.addPoint( SciFiSpacePoint ) Over: –( SciFiKalTrack.points() ).add( SciFiSpacePoint )

15 Next Step We should now take the Use Cases and derive the relevant User Requirements from them and enter them into the document in real time…