P4L5 Design Principles

pdf

School

Georgia Institute Of Technology *

*We aren’t endorsed by this school

Course

6310

Subject

Computer Science

Date

Oct 30, 2023

Type

pdf

Pages

14

Report

Uploaded by SuperElkMaster712

Design Guidelines e Design CAN'T resly be taught, but has to be learned through experience o Offered severa ways to learn from the experience of others l e Design principles are informal guidelines Design Quality » One of severa ways of gauging the quality of designs e Utimate validation of design is to build the program and have its users report their satisfaction o Can buld 8 prototype or conduct design reviews e Various metrics can compute actudl numbers assessing the quality \ « Least expensive but conceivably most valuable
Design Guidelines Coupling e also caled 8 design principle or design heuristics » Extent to which 3 module is dependent on other modules * an ipformal piece of e Coupling of your advice about the . modules should be low in structure of 8 design order to make it easier to maintain them o téke the form of * invented by Larry k do's and don'ts Constantine Cohesion Orthogonality . o Extent to which the features of a o Extent to which 8 module has 8 system can be varied independently single purpose i gie purp e Enhance the orthogonality of your system in order to « Cohesion shoud be high g:/aa'fgblfgotrg i?Spfli‘cgr;?s in order to enhance understandability and o Clarifies system promote reuse descriptions and support automatic generation e Developed by David l e Invented b.y Larry McGovern and Christopher Constantine Date
e also caled encapsulation o Extent to which the implementation details of a system are encapsulated behind abstract interfaces e Use of inheritance can Information Hiding Catalog e Give the principle's name, author, definition and implications of its use violate information hiding e Only guidelines and not e developed by David Parnas hard-and-fast rules Place the letter indicating the described design principle into the text box next to the situation describing it: A. Coupling B. Cohesion C. Orthogonality D. Information hiding B C D A Improves reusability Enables maximum variability Raises the level of adbstraction Requires more code reading
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Catalog e Give the principle's name, author, definition and implications of its use e Only guidelines and not hard-and-fast rules Liskov Substitution Principle e Barbara Liskov e Subclass instances should satisfy . parent-class constraints e Implies that child class instances should obey parent class invariants \ and method contracts
Law of Demeter e Karl Lieberherr e Suggests limits on the classes that can be referred to by 8 given method o Limits the objects that can be referred to e Reduces coupling, but sometimes requires extra wrapper classes Hollywood Principle e Donald Wallace o Frameworks consist of a set of abstract classes together with rules for the ways that therr concrete subclasses may interact » Suggests that calls should be made from the framework to the client classes e also caled inversion of control \ « "Don't cal us; we'l cal you"
Dependency Inversion PrinCip'e e Robert Martin e High level modules shoud not depend uoon low level modules. Both should depend upon abstractions e Related to inversion of control e Opposite to the way that modules are structured in traditional layered architectures Layering shoud be one of abstraction, rather than one of control or data access. | « Controling pruncuples are enforced at highest levels in our architecture Open-Closed Principle e Bertrand Meyer e A class shoud be open for extension but closed for modification o After releasing a class, any enhancement to it shoud be made only iIn subclasses o Helps deal with the fragie base class problem
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Imagine you have designed the following classes: class Motor { public void run() { /*run algorithm...*/ } } class FancyMotor { public void run() { /* run fancy algorithm... */ } } class Robot { // complex Robot class Motor motor; X public void boot () { motor.run() ; } Interface Segregation Principle e Robert Martin e Suggests that clients depend on an interface to a part of the large class's features » Note the relationship of this principle to role-based design o Class interfaces shoud be broken into small pieces corresponding to single use case Assume the Robot class is very complex, and now we have to change it to include 8 new FancyMotor, Making this change wil be difficut with the current design because it violates which design principle? Substitution Principle Law of Demeter Hollywood Principle Dependency Inversion Principle Open-Closed Principle
Reuse Equivalency Principles e Robert Martin e The granule of reuse should be the granule of release e Release highly cohesive code units e Java package e Converse of this principle is the Common Reuse Principle Common Closure Principle e Robert Martin » Regardess of the level of granularity we are forced to use, group the related elements into 8 common release unit » In Java, this woud typicaly be a8 package o Classes that change together, should be released together
Dependency Structure Matrix » Device devised by Baldwin and Clark to ded with the management of design changes e Boolean matrix in which rows and columns correspond to components e Order of rows and columns doesn’t matter to the information conveyed Lattix Image B Aot - C\Ant_161.0dz * Left SEde conveys the hierarChical Wiw e o NowoowivwaWn structure of the system’s components. JEYo[: comi : 2 e Numbers in the cels can provide counts of dependencies 1 e Red triangles indicate violations of user-specified design principles e Brown squares internal to the overal DSM indicate candidate modules having no violations
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Acyclic Dependency Principle e Robert Martin o Dependencies between packages must not form cycles e Should be able to permute the rows and columns of the DSM o Component only depends on other components beneath it e Violation of this property would lead to 8 system that is difficult to maintain and understand Sfabili'ty e Robert Martin e A module is hard to change if 3 lot of other modules depend on it » Stable Dependency Principle suggest that you should depend in the direction of stability No package should be dependent on packages that are more likely to change than it e Martin's Stable Abstraction Principle e Easy to extend
Bad Smells » Kent Beck and Martin Fowler popularized the notion of refactoring in the 1990’s e Move some design activities into the actual implementation phase of development o Reduce rework in situations with rapidly changing requirements e Code situations that are suggestive of design problems » Fowler’s book recognize dozens of bad smells besign Heuristics - Riel e Do not change the state of an object without going through its public interface N * Means that 8 method in a8 class cannot change an instance variable without caling the setter e Users of a class must be dependent on its public interface, but a class should not be dependent on its users » Distribute system inteligence horizontally as uniformly as possible Distribute system inteligence vertically down narrow and deep containment hierarchies
Single Choice Principle e In procedural code, systematic variation is often dealtt with via case statements or else-If cascades e In object-oriented code, this gpproach is considered 3 bad smell e Use pardllel, factored subclasses, with the choice-specific code embodied in 8 subclass method l e Written by Bertrand Meyer Transparency o Suggests providing interfaces that enable clients to be written without having to concerned with extraneous details o Generality comes with the cost of extra design and testing work
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Intentionality e Most abstract o Design software in such 3 way that intent is manifest and locadlized in the code o Supports traceability, validation, and maintainability. e Improve intentionality by appropriate use of cohesion and naming conventions James Gosling was the author of the Java programming language. At a Java Users Group meeting he was asked: "f you could do Java over 3gain, what would you change?" He replied: "'d leave out classes" Which of the principles or heuristics that have been mentioned in this lesson supports this idea? Mark al that apply: Liskov Substitution Principle Interface Segregation Principle Stable Abstraction Principle Riel: Inheritance should be used only to model 3 generdlization hierarchy X]PX]XI1><
Summary e A catalog of design principles is too abstract to be immediately useful e By being made aware of these principles you wil be sensitized to problematic situation when they arise * Then look up the relevant principle and its suggested solutions

Browse Popular Homework Q&A

Q: . the position that distinguishes between DNA and RNA is 2. the carbon that the phosphate group…
Q: In outer space two space modules are joined together by a massless cable. These probes are rotating…
Q: Assuming the company uses direct labor-hours to compute its predetermined overhead rate, what is the…
Q: A stereo store is offering a special price on a complete set of components (receiver, compact disc…
Q: Netowrk Concepts Class: Considering the total number of IPv4 addresses is limited to 4,294,967,296…
Q: According to a recent report​ (based on historical​ data), 47% of college student internships are…
Q: After having been on the air for more than a decade, Fox's American Idol seemed to be suffering from…
Q: Graph the feasible region subject to the following constraints: Select the correct answer below: O…
Q: A person exerts a horizontal force of 190 N in the test apparatus shown in the figure. Find the…
Q: In Oracle database, If we have Iname field in our table then regardless of how the value have been…
Q: Two blocks are connected by a very light string passing over a massless, frictionless pulley (see…
Q: You may be wondering, "Why bother with a technical analysis?" Explain how it is used, why it is…
Q: When Dylan jumps into the air, his height in feet above the surface of the water is given by h = -…
Q: Companies can choose from several different branding strategies. Kohl’s, with its own Croft &…
Q: 5 Determine if the following are functions of x, and if they are determine if they are 1-1. Explain…
Q: Find the quotient and remainder using synthetic division for r3 + 6x? + 15x + 15 x + 2 The quotient…
Q: 1) The circuit in the above figure (1) has a supply voltage of 60 volts, and three resistors of…
Q: Which of the following is not an example of an open ended question? O What features do you want on…
Q: ind the intervals on which f is increasing or decreasing. Find the local maximum and minimum values…
Q: The following data was collected from 1 bag of Hershey Kisses®. Each Kiss® was weighed in grams with…
Q: Definition 3: Let X be a subspace of Rn and let X be the set of all vectors in R" that are…
Q: The Brew House needs to decide which of two coffee maker designs is better environmentally. Using…