1 / 32

Software Design

Software Design. i206 Fall 2010 John Chuang. Some slides adapted from Glenn Brookshear, Brian Hayes, Marti Hearst, or James Landay. Confidentiality Integrity Authentication …. Software Design. Distributed Systems. C/S, P2P Caching. Security. Cryptography. Network. Standards

Télécharger la présentation

Software Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Design i206 Fall 2010 John Chuang Some slides adapted from Glenn Brookshear, Brian Hayes, Marti Hearst, or James Landay

  2. Confidentiality Integrity Authentication … SoftwareDesign Distributed Systems C/S, P2P Caching Security Cryptography Network Standards & Protocols sockets Inter-process Communication Methodologies/ Tools Principles TCP/IP, RSA, … UML, CRC OperatingSystem Formal models Application Design Process I/O Finite automata regex Context switch Process vs. Thread Locks and deadlocks Algorithms Program Analysis Memory hierarchy ALUs, Registers, Program Counter, Instruction Register Memory Big-O Compiler/ Interpreter Assembly Instructions Data Structures Register, Cache Main Memory, Secondary Storage Searching, sorting, Encryption, etc. Machine Instructions CPU Op-code, operands Instruction set arch Data storage Stacks, queues, maps, trees, graphs, … Circuits Lossless v. lossy Info entropy & Huffman code Decimal, Hexadecimal, Binary Adders, decoders, Memory latches, ALUs, etc. Gates Data compression Number Systems Data AND, OR, NOT, XOR, NAND, NOR, etc. Boolean Logic Numbers, text, audio, video, image, … Truth table Venn Diagram DeMorgan’s Law Data Representation Binary Numbers Bits & Bytes John Chuang

  3. Outline (Next 5 Weeks) • Algorithm and Program • Programming Languages and Paradigms • Object-Oriented Design • Analysis of Algorithms • Data Structures • Regular Expressions John Chuang

  4. Algorithm and Program • An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process. • named after 9th century Persian mathematician Abu Ja'far Mohammed ibn Musa al-Khowarizmi • A computer program is a representation of an algorithm which prescribes the actions that are to be carried out by a computer. • A computer program consists of a set of instructions that the computer understands. John Chuang

  5. Algorithms: Levels of Abstraction • Problem: motivation for algorithm • Algorithm: procedure to solve the problem • Often one of many possibilities • Representation: description of algorithm sufficient to communicate it to the desired audience • Always one of many possibilities John Chuang

  6. Folding a Bird from a Square Piece of Paper Origami Primitives John Chuang Source: Brookshear

  7. Sequential Search Algorithm in Pseudocode Source: Brookshear • Pseudocode primitives in bold John Chuang

  8. Algorithm and Program • An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process. • A computer program is a representation of an algorithm which prescribes the actions that are to be carried out by a computer. • A computer program consists of a set of instructions that the computer understands. John Chuang

  9. Programming Languages • Machine language (1st generation) • Assembly language (2nd generation) • Simply a set of abbreviations for the machine code instructions • An assembler is used to translate the program into machine instructions • High-level language • A compiler or an interpreter is used to translate the program into machine instructions http://webopedia.internet.com/TERM/P/programming_language.html Source: Brookshear, Figure 6.2 John Chuang

  10. http://xkcd.com/303/ John Chuang

  11. Programming Paradigms • Imperative programming • describes computation in terms of statements that change a program state • Consistent with the sequential execution of instructions in hardware • E.g., procedural programming, object-oriented programming • Declarative programming • Describe desired results, without explicit description of steps • E.g., regular expressions, functional programming, logical programming John Chuang

  12. Imperative Programming • Procedural programming • Specifies a sequence of algorithmic steps • Use of procedures (aka routines, subroutines, functions, or methods) to improve modularity, reuse • Object-oriented programming • Specifies a collection of objects, each with its own data and methods, and the collaborations between the objects • OOP promotes modularity and reuse via abstraction, encapsulation, inheritance • Helps keep large software projects, and projects with changing requirements, manageable John Chuang

  13. OOP Example John Chuang Source: http://www.stanford.edu/~gpathy/umlshort/

  14. Object-Oriented Design • Object-oriented design based upon principles of abstraction, encapsulation, and modularity • Object-oriented design through the clarification of object roles, responsibilities, and collaborations John Chuang

  15. knows information performs services an object maintains connections (to other objects) makes decisions (to do the right things) Role and Responsibility • Application: a set of interacting objects • Object: an implementation of one or more roles • Role: a set of related responsibilities • Responsibility: an obligation to perform a task (action) or to know information (data) John Chuang Source: Wirfs-Brock and McKean, Object Design: Roles, Responsibilities, and Collaborations.

  16. knows information performs services a collaborator maintains connections (to other objects) makes decisions (to do the right things) Collaboration needs help • Collaboration: an interaction of objects or roles (or both) • Contract: an agreement outlining the terms of a collaboration message asking for help an object John Chuang Source: Wirfs-Brock and McKean, Object Design: Roles, Responsibilities, and Collaborations.

  17. 1. Design using 3 chips (classes) 2. Design using 3 chips (classes) Cohesion and Coupling • Q: how to come up with the right set of objects for a system? • Maximize cohesion (relationship within object) • Minimize coupling (relationship between objects) John Chuang

  18. Cohesion and Coupling • Design 2 has too much coupling and not enough cohesion. As a result, it is: • difficult to understand • difficult to locate faults • difficult to reuse, extend, or enhance • Design 1 has better abstraction, encapsulation, and modularity John Chuang

  19. OO Analysis & Design Process • Gather requirements • Develop use cases • Each use case describes what the system does to accomplish a particular customer goal • Analysis and Design • Iterative process of identifying roles, responsibilities, and collaborations • Textual analysis • Noun analysis to identify candidate classes • Verb analysis to identify candidate methods • Identification and use of design patterns • Design pattern: a general reusable solution to a commonly occurring problem John Chuang

  20. Unified Modeling Language (UML) • UML is a language for specifying, visualizing, constructing, and documenting a software system • Several types of diagrams, including: • Use Case diagrams • Class diagrams • Sequence diagrams • … John Chuang http://www.smartdraw.com/resources/centers/uml/uml.htm

  21. Use Case Diagram • A use case is a sequence of actions a system performs that yields an observable result to an external actor • A use case describes functionality of the system from the user's point of view • A good use case has: a single goal, an external initiator, a start condition, and an end condition • A use case is represented by an oval in UML • An actor is someone or something outside the system that interacts with the system • An actor can be a human being or another system or a device • An actor is represented by a stick figure in UML. John Chuang

  22. Class Diagram • Captures the logical structure of the system, including objects and their relationships with one another Source: Brookshear, Figure 7.4 John Chuang

  23. Class Diagram Example John Chuang Source: http://www.stanford.edu/~gpathy/umlshort/

  24. +: public - : private Representing Classes John Chuang Source: Learning UML 2.0

  25. Representing Classes John Chuang Source: Learning UML 2.0

  26. Relationships between Classes Source: Learning UML 2.0 John Chuang

  27. Relationships between Classes “HAS-A” Source: Learning UML 2.0 John Chuang

  28. Relationships between Classes Source: Learning UML 2.0 “IS-A” Note: Inheritance is also known as generalization John Chuang

  29. Class Diagram Example John Chuang Source: http://www.stanford.edu/~gpathy/umlshort/

  30. Collaboration Diagram • Shows interactions between classes for one or more use cases John Chuang Source: Brookshear, Figure 7.6

  31. Sequence Diagram • Shows interactions between classes over time for a particular use case • Place classes at the top of diagram • Draw vertical lines down from each class • Draw horizontal lines to the vertical lines to show interactions (method calls); label lines with the name of the message or method • Time goes from diagram’s top to bottom Source: Wikipedia John Chuang

  32. Software Design Process • Software design is a creative problem solving process • Understand the problem (create use scenarios) • Find algorithmic procedure that might solve the problem (consider different solution options) • Formulate the algorithm and represent it as a program • Evaluate the program for accuracy and its potential as a tool for solving other problems • Iterate! Traditional Software Life Cycle John Chuang http://www.math.bas.bg/~nkirov/2004/Horstman/ch13/images/spiral.png Source: Brookshear, Figure 7.2

More Related