Computer Science 240 © Ken Rodham 2006 Principles of Software Design.

Slides:



Advertisements
Similar presentations
Software Engineering and Design Principles Chapter 1.
Advertisements

Algorithms and Problem Solving-1 Algorithms and Problem Solving.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
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.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
Object-oriented Programming Concepts
Chapter 1 Principles of Programming and Software Engineering.
Object-Orientated Design Unit 3: Objects and Classes Jin Sa.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Data Abstraction: The Walls
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Working with Classes Chapter 6. 2 Class definition A class is a collection of data and routines that share a well-defined responsibility or provide.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Computer Science 240 Principles of Software Design.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
Introduction SWE 619. Why Is Building Good Software Hard? Large software systems enormously complex  Millions of “moving parts” People expect software.
Chapter 5CSA 217 Design in Construction Chapter 5 1.
Comp 245 Data Structures Software Engineering. What is Software Engineering? Most students obtain the problem and immediately start coding the solution.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Ceg860 (Prasad)L6MR1 Modularity Extendibility Reusability.
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.
Object-Oriented Modeling and Design
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
Computer Science 340 Software Design & Testing Design Principles Review.
CSE 219 Computer Science III Program Design Principles.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Computer Science 340 Software Design & Testing Design Principles Review.
Facade Introduction. Intent Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Chapter 12 Object Oriented Design.  Complements top-down design  Data-centered view of design  Reliable  Cost-effective.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Introduction to Design (and Zen) CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Designing Classes. Software changes Software is not like a novel that is written once and then remains unchanged. Software is extended, corrected, maintained,
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Data Structures Using C++ 2E
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
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.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Object-Oriented Design Concepts University of Sunderland.
Chapter 10 Software quality. This chapter discusses n Some important properties we want our system to have, specifically correctness and maintainability.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 6.0.
7. Modular and structured design
CS240: Advanced Programming Concepts
CSC 222: Computer Programming II
Data Abstraction: The Walls
Principles of Programming and Software Engineering
CS240: Advanced Programming Concepts
Object Oriented Practices
Objects First with Java
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Algorithms and Problem Solving
Software Design Principles
Presentation transcript:

Computer Science 240 © Ken Rodham 2006 Principles of Software Design

Introduction Core principles of software design –Fundamental and relatively constant –When were our textbooks published? How could they still be relevant? Evaluation criteria for designs in this course Design evaluation is inherently subjective Specifying specific evaluation criteria will help make grading as predictable as possible

Goals of Software Design Manage COMPLEXITY Make and keep software systems ORGANIZED as they evolve Combat design ENTROPY Create systems that –Work –Are easy to understand, debug, and maintain –Are easy to extend and hold up well under changes –Reusable

Design is inherently iterative Design, implement, test, Design, implement, test, … Feedback loop from implementation back into design provides valuable knowledge Designing everything before beginning implementation doesn’t work Beginning implementation without doing any design also doesn’t work The appropriate balance is achieved by interleaving design and implementation activities in relatively short iterations

Abstraction Abstraction is one of the software designer’s primary tools for coping with COMPLEXITY Programming languages and OSes provide abstractions that model the underlying machine Programs written solely in terms of these low-level abstractions are very difficult to understand Software designers must create higher-level, domain- specific abstractions, and write their software in terms of those –High-level abstractions implemented in terms of low-level abstractions

Abstraction Many domain-specific abstractions can be taken directly from the “domain model” Other abstractions do not appear in the domain model, but are needed for internal implementation purposes –Mid-level abstractions such as: NotificationManager, PersistenceManager, UserSession, UndoRedoManager, ThreadPool

Abstraction Each abstraction is represented as a class Each class has a carefully designed public interface that defines how the rest of the system interacts with it A client can invoke operations on an object without understanding how it works internally This is a powerful technique for reducing the cognitive burden of building complex systems

Naming A central part of abstraction is giving things names (or identifiers) Selecting good names for things is critical Class, method, and variable names should clearly convey their function or purpose Class and variable names are usually nouns Method names are usually verbs –Exceptions Object properties (ID, Name, Parent, etc.) Event handlers (MouseMoved, UserLoggedIn)

Cohesion Abstractions should be highly cohesive Each class represents one, well-defined concept –All operations on a class are highly related to the class’ concept –Cohesive classes are easy to name Each method performs one, well-defined task –Unrelated or loosely related tasks should be in different methods –Cohesive methods are easy to name

Abstracting All the Way Some abstractions are simple enough to store directly using the language’s built-in data types –Name => string –Pay Grade => int –Credit Card Number => string Often it is best to create classes for such simple abstractions for the following reasons: –Data validation –Related operations –Code readability

Decomposition In addition to Abstraction, Decomposition is the other fundamental technique for taming COMPLEXITY Large problems subdivided into smaller sub- problems Subdivision continues until leaf-level problems are simple enough to solve directly Solutions to sub-problems are recombined into solutions to larger problems

Decomposition Decomposition is strongly related to Abstraction The solution to each sub-problem is encapsulated in its own abstraction (class or subroutine) Solutions to larger problems are concise because they’re expressed in terms of sub-problem solutions, the details of which can be ignored The decomposition process helps us discover (or invent) the abstractions that we need

Decomposition Levels of decomposition –System –Subsystem –Packages –Classes –Routines Hypo- and Hyper-Decomposition When have we decomposed far enough? –Size metrics –Complexity metrics

Algorithm & Data Structure Selection No amount of decomposition or abstraction will hide a fundamentally flawed selection of algorithm or data structure.

Minimize Dependencies Dependencies –Class A CALLS Class B –Class A HAS MEMBER OF Class B –Class A INHERITS FROM Class B

Minimize Dependencies Minimizing the number of interactions between different classes has several benefits: –A class with few dependencies is easier to understand –A class with few dependencies is less prone to ripple effects –A class with few dependencies is easier to reuse

Minimize Dependencies When classes must interact, if possible they should do so through simple method calls –This kind of dependency is clear in the code and relatively easy to understand

Separation of Interface and Implementation Maintain a strict separation between a class’ interface and its implementation This allows internal details to change without affecting clients interface Stack + class StackImpl

Information Hiding Many languages provide “public”, “private”, and “protected” access levels All internal implementation is “private” unless there’s a good reason to make it “protected” or “public” A class’ public interface should be as simple as possible

Information Hiding Don’t let internal details “leak out” of a class –search instead of binarySearch –ClassRoll instead of StudentLinkedList Some classes or methods are inherently tied to a particular implementation. For these it is OK to use an implementation-specific name –HashTable –TreeSet

Code Duplication Code duplication should be strenuously avoided –Identical or similar sections of code Disadvantages of duplication: –N copies to maintain –Bugs are duplicated N times –Makes program longer, decreasing maintainability Solutions –Factor common code into a separate method or class –Shared code might be placed in a common superclass