1 OO Class Design PrinciplesStefan Kluth 3OO Class Design Principles 3.1Dependency Management 3.2The Copy Program 3.3Class Design Principles.

Slides:



Advertisements
Similar presentations
Clean code. Motivation Total cost = the cost of developing + maintenance cost Maintenance cost = cost of understanding + cost of changes + cost of testing.
Advertisements

Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
SOLID Object Oriented Design Craig Berntson
Software Quality Assurance Inspection by Ross Simmerman Software developers follow a method of software quality assurance and try to eliminate bugs prior.
(Quickly) Testing the Tester via Path Coverage Alex Groce Oregon State University (formerly NASA/JPL Laboratory for Reliable Software)
Software Engineering and Design Principles Chapter 1.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
Debugging CPSC 315 – Programming Studio Fall 2008.
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
Microprocessors Introduction to ia64 Architecture Jan 31st, 2002 General Principles.
1 CMSC 132: Object-Oriented Programming II Software Development IV Department of Computer Science University of Maryland, College Park.
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Applied Software Project Management Andrew Stellman & Jennifer Greene Applied Software Project Management Applied Software.
1 CMSC 132: Object-Oriented Programming II Software Development III Department of Computer Science University of Maryland, College Park.
Guide To UNIX Using Linux Third Edition
SM3121 Software Technology Mark Green School of Creative Media.
Package design and the Iterative process model. What is a package? Classes are not sufficient to group code –Some classes collaborate, implying dependencies.
Problem with Software Requirements are complex The client does not know the functional requirements in advance Requirements may be changing Technology.
CODING Research Data Management. Research Data Management Coding When writing software or analytical code it is important that others and your future.
Software Development Unit 6.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Agile Design.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 17 Slide 1 Extreme Programming.
Language Evaluation Criteria
Test Driven Development An approach to writing better code Jimmy Zimmerman Intel Corporation.
Lecture 18 Page 1 CS 111 Online Design Principles for Secure Systems Economy Complete mediation Open design Separation of privileges Least privilege Least.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Experiences Reviewing Scientific C++ Code Marc Paterno f CD/Special Assignments.
CS 360 Lecture 3.  The software process is a structured set of activities required to develop a software system.  Fundamental Assumption:  Good software.
©Ian Sommerville 2000, Mejia-Alvarez 2009 Slide 1 Software Processes l Coherent sets of activities for specifying, designing, implementing and testing.
OHTO -99 SOFTWARE ENGINEERING “SOFTWARE PRODUCT QUALITY” Today: - Software quality - Quality Components - ”Good” software properties.
1 Software Development Configuration management. \ 2 Software Configuration  Items that comprise all information produced as part of the software development.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
Design and Programming Chapter 7 Applied Software Project Management, Stellman & Greene See also:
Extreme/Agile Programming Prabhaker Mateti. ACK These slides are collected from many authors along with a few of mine. Many thanks to all these authors.
OHTO -99 SOFTWARE ENGINEERING “SOFTWARE PRODUCT QUALITY” Today: - Software quality - Quality Components - ”Good” software properties.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Cohesion and Coupling CS 4311
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Design Principles iwongu at gmail dot com.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
WATERFALL DEVELOPMENT MODEL. Waterfall model is LINEAR development lifecycle. This means each phase must be completed before moving onto the next!!! WHAT.
Programming Fundamentals Lecture No. 2. Course Objectives Objectives of this course are three fold 1. To appreciate the need for a programming language.
1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Design and Planning Or: What’s the next thing we should do for our project?
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
WHAT IS PHP FRAMEWORK? Set of Classes and Functions(Methods) Design for the development of web applications Provide basic structure Rapid application development(RAD)
Software Quality Assurance and Testing Fazal Rehman Shamil.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Lecture 1 Page 1 CS 111 Summer 2013 Important OS Properties For real operating systems built and used by real people Differs depending on who you are talking.
Coupling and Cohesion 1.
C++ coding standard suggestion… Separate reasoning from action, in every block. Hi, this talk is to suggest a rule (or guideline) to simplify C++ code.
Chapter 25: Architecture and Product Lines
Objects First with Java
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
Software Design Lecture : 9.
CSE 303 Concepts and Tools for Software Development
Chapter 8 Software Evolution.
Principles of Object-Oriented Design
NOTICE! These materials are prepared only for the students enrolled in the course Distributed Software Development (DSD) at the Department of Computer.
Refactoring.
Presentation transcript:

1 OO Class Design PrinciplesStefan Kluth 3OO Class Design Principles 3.1Dependency Management 3.2The Copy Program 3.3Class Design Principles

2 OO Class Design PrinciplesStefan Kluth 3.1 Dependency Management ● The parts of a project depend on each other – components, programs, groups of classes, libraries ● Dependencies limit – flexibility – ease of maintainance – reuse of components or parts ● Dependency management tries to control dependencies

3 OO Class Design PrinciplesStefan Kluth 3.1 Dependency Management and Software ● Software systems are the most complex artificial systems ● There will be a lot of dependencies ● Software development was and is always concerned with dependencies ● OOAD gives us tools to manage dependencies – trace dependencies e.g. in UML models – use OO language to manipulate dependencies

4 OO Class Design PrinciplesStefan Kluth 3.1 Problems with Software ● Rigid ● Fragile ● Not Reuseable ● High Viscosity ● Useless Complexity ● Repetition ● Opacity These statements apply to an average physicist/programmer who develops and/or maintains some software system. Software gurus will always find some solution in their code. Do you want to rely on the guru? What if that person retires, finds a well-paid job or gets moved to another project?

5 OO Class Design PrinciplesStefan Kluth 3.1 Rigid Software ● Difficulties with changes – Unforeseen side effects occur frequently – Hard to estimate time to complete modifications ● "Roach Motel" – Always in need of more effort ● Management reluctant to allow changes – Official rigidity, "don't touch a working system" – Users forced to develop workarounds

6 OO Class Design PrinciplesStefan Kluth 3.1 Fragile Software ● Small changes have large side effects – New bugs appear regularly – In the limit of P(bug|change) = 1 system is impossible to maintain ● It looks like control has been lost – Users become critical – Program looses credibility – Developers loose credibility

7 OO Class Design PrinciplesStefan Kluth 3.1 Not Reuseable ● You have a problem and find some piece of code which might solve it – but it brings in a lot of other stuff – it needs changes here and there ● Eventually you have two choices – Take over maintainance of the branched code – Roll your own ● You would like to include headers and link a library maintained by somebody else

8 OO Class Design PrinciplesStefan Kluth 3.1 High Viscosity ● Viscosity of the design – Hard to make changes properly, i.e. without breaking the design → make hacks instead ● Viscosity of the environment – Slow and inefficient development environment – Large incentive to keep changes localised even if they break designs – Design changes are very difficult

9 OO Class Design PrinciplesStefan Kluth 3.1 Useless Complexity ● Design/code contains useless elements ● Often for anticipated changes or extension – May pay off – Meanwhile makes design/code harder to understand ● Or leftovers of previous design changes? – Time for a clean-up ● Tradeoff between complexity now and anticipated changes later

10 OO Class Design PrinciplesStefan Kluth 3.1 Repetition ● Added functionality using cut-and-paste – Then slight modifications for local purpose ● Find same structure repeatedly – More code – Harder to debug and modify ● There is an abstraction somewhere – Refactor into function/method – Create class(es) to do the job

11 OO Class Design PrinciplesStefan Kluth 3.1 Opacity ● Design/code difficult to understand – We have all suffered... – What is clear now may seem strange later ● Ok when its your code – You suffer in silence ● Not acceptable in collaboration – Need to code clearly, may need to rearrange – Code reviews?

12 OO Class Design PrinciplesStefan Kluth 3.1 Dependencies Managed ● Code is less rigid ● Code is less fragile ● Reuse is possible ● Viscosity is low

13 OO Class Design PrinciplesStefan Kluth 3.1 Less Rigid Code ● Modules can be interchanged ● Changes are confined to a few modules ● Cost of changes can be estimated ● Changes can be planned and scheduled ● Management is possible

14 OO Class Design PrinciplesStefan Kluth 3.1 Less Fragile Code ● Confined changes mean P(bug|change) is small ● New bugs will most likely appear where the changes was made, i.e. localised – Easier to fix (hopefully) ● Risk of changes can be estimated ● Credibility of code and developers conserved

15 OO Class Design PrinciplesStefan Kluth 3.1 Reuseable Code ● A module can be used in a different context without changes – Just use headers and link a library ● No need to compile and/or link lots of unrelated stuff

16 OO Class Design PrinciplesStefan Kluth 3.1 Low Viscosity ● Design is easy to modify – No quick hacks needed – Proper design improvements will actually happen ● Large scale changes affecting many modules are possible – Reasonable compile and link times for the whole system – May depend on adequate hardware as well

17 OO Class Design PrinciplesStefan Kluth 3.1 Compile and Link Times ● Compile and link times are unproductive ● In a project with N modules compile and link time can grow like N 2 (assuming every module is tested) when dependencies are not controlled ● Loss of productivity ● Long turnaround times → slow development ● Dependency management essential in large projects

18 OO Class Design PrinciplesStefan Kluth 3.1 Code Changes ● Modules/packages and makefiles – Verify that makefiles are reliable ● Changes to libraries (reuseable code) – All affected users must relink (and retest) ● Shared libraries – Need to distribute (and restart programs) – Validation by users still needed – Need recompile after interface changes

19 OO Class Design PrinciplesStefan Kluth 3.2 The Copy Routine ● Code rots ● There are many reasons for code rot ● We'll make a case study (R. Martin) ● A routine which reads the keyboard and writes to a printer

20 OO Class Design PrinciplesStefan Kluth 3.2 Copy Version 1 A simple solution to a simple problem ReadKeyboard and WritePrinter are probably reuseable

21 OO Class Design PrinciplesStefan Kluth 3.2 Copy Version 2 Many users want to read files too... But they don't want to change their code... can't put a flag in the call Ok, so we use a global flag Its backwards compatible To read files you have to set the flag first

22 OO Class Design PrinciplesStefan Kluth 3.2 Copy Version 3 bool GFile; void Copy(void) { char ch; while( 1 ) { if( GFile ) { ch= ReadFile(); } else { ch= ReadKeyboard(); } if( ch == EOF ) break; WritePrinter( ch ); } Oh dear, we introduced a bug in version 2 (printing EOF isn't nice) Version 3 fixes this bug

23 OO Class Design PrinciplesStefan Kluth 3.2 Copy Version 4 Users want to write to files, of course they want it backwards compatible We know how to do that! The Copy routine seems to grow in size and complexity every time a feature is added The protocol to use it becomes more complicated

24 OO Class Design PrinciplesStefan Kluth 3.2 Copy done properly in C Finally a good C programmer comes to the rescue! But this is C?! FILE, fgetc and fputc behave like an interface class FILE represents a generic byte stream manipulated by fgetc, fputc etc.

25 OO Class Design PrinciplesStefan Kluth 3.2 Copy in C++ More complicated but easy to add new features

26 OO Class Design PrinciplesStefan Kluth 3.2 Copy Routine Summary ● Lack of sensible design leads to code rot – Useless complexity, repetition, opacity ● Software systems are dynamic – New requirements, new hardware ● A good design makes the system flexible and allows easy extensions – Abstractions and interfaces ● An OO design may be more complex but it builds in the ability to make changes

27 OO Class Design PrinciplesStefan Kluth 3.2 Dependency Management Summary ● Controlling dependencies has several advantages for software system – Not rigid, not fragile, reuseable, low viscosity ● Also affects development environment – Lower compile and link times, less testing – More productive work ● Plan for changes and maintainance