Low Level Design

download Low Level Design

of 24

description

What is low level design? Diff b/w low level and high level design.........

Transcript of Low Level Design

  • Low-level design

  • AnnouncementsMidterm next Tuesday 12:30-1:45Room MEB 253 netid a*-jke*Room DCL 1310 (this) netid jmc*-z*Rules like in previous yearsConflict: email Steve by the end of the dayMilestone 3 meetings are March 15-19But practice UML part BEFORE midtermWA3 due today

  • A good designSatisfies requirementsEasy to implementEasy to understandEasy to changeEasy to check for correctnessIs beautiful

  • Keep It Simple (S)Everything should be as simple as possible, but no simpler. (Einstein)A design is finished not when there is nothing to add, but when there is nothing to take away. (Saint-Exupery)Measuring a program by the number of lines of code in it is like measuring an airplane by how much it weighs. (Gates)

  • Keep it SimpleEliminate duplicationEliminate unnecessary featuresHide informationNo surprises (follow standards)

  • Davis Design PrinciplesDont reinvent the wheel.Exhibit uniformity and integration.Minimize the intellectual distance between the software and the problem as it exists in the real world.Structure the design to accommodate change.

  • DavisThe design should be structured to degrade gently, even when aberrant data, events, or operating conditions are encountered.The design should be assessed for quality as it is being created, not after the fact.The design should be reviewed to minimize conceptual errors.

  • Design: VerbBounce from high-level to low-levelNew requirements come after design is createdDesign is created incrementallyAs requirements are knownAs better design ideas are inventedAs design flaws are discovered

  • Low-level DesignMany different techniquesFlow chartsDecision tablesPseudo-codeState machines

  • Decision tablesUsed to specify program with complex conditionsMakes it easy to see if any cases are missingCan be implemented with IF statements

  • Tax code exampleThe recovery period is 27.5 years for residential real property, 31.5 years for non-residential real property placed in service before May 13, 1993, 39 years for non-residential real property placed in service after May 12, 1993, 50 years for railroad gradings and tunnel bores, except that nonresidential real property on an Indian reservation has a recovery period of 22 years.

  • Decision table for recovery period Real propertyResidentialPlaced before May 13, 1993Railroad grading or boreOn Indian reservation

    27.5 years31.5 years39 years50 years22 yearsTT142T53ActionsConditionsTTTTTFTFFFFFFFFFxxxxx

  • Pseudo-codeAlso known as Program Design LanguageAdvantages:Expressive and compactCan use any editor(Sometimes) can compile itDisadvantages:Must know the language

  • Pseudo-codefloat computerRecoveryPeriod(property) {if (isReal(property)) {if (isResidential(property)) return 27.5;if (onReservation(property)) return 22;if (isRailroad(property)) return 50;if (property.date > May 13, 1993)return 31.5;else return 39;}}

  • Pseudo-codeWorks well with refinementWrite pseudo-codeAs commentsWith stubsGradually implement it allExecute and test as you go

  • State Machines (FSM)Lots of theoryHow to minimize number of statesHow to merge state machinesHow to tell whether two state machines are equalCan generate code directly from state machinesBut usually do not

  • State diagram for stop lightR/RR/RR/YR/GY/RG/R22542304Events are time delays, in seconds.

  • Pseudocode for stop lightAction = Record {integer wait, east, north}Action: Actions[1 .. 6]repeat foreverfor I = 1 to 6 dosetEast(actions[i].east)setNorth(actions[i].north)wait(actions[i].wait)end for

  • State diagram for socketsqlen!=0activeCONNECTINGuninitializedCONNECTEDpassiveqlen!=0newconn1()isconnected()accept()newconn1()disconnect()isconnecting()isconnected()isconnected()listen()connect()

  • Implementing socketSocket is an objectActions are methods of the socketState is stored in variable of the objectEach method uses IF statement to make sure socket is in the right stateWhen IF statements get too complicated, use State Pattern

  • State PatternFrom Design PatternsSocketSocketStatelisten()connect()newconn1()...PassiveStateConnectingStateConnectedState...

  • Detailed designLots of different techniquesMost only works in a few placesPseudocode works most places, but often there is a better techniqueOften best to use code and skip detailed design

  • Good designGood design is product of many small stepsDo the right thingEach step adds a featureDo one more thing rightDo the thing rightEach step makes design a little simplerEliminates one more unnecessary complexity

  • Next: MidtermTuesday, March 9, 12:30-1:45Two roomsCheck Wiki and newsgroup for detailsLook at previous exams and Charlies QsCovered somewhat different materialMaterial includes all lectures and readings until today, including guest lecture