The Art of Design

Download The Art of Design

Post on 02-Jan-2016




0 download


ECE230 Lectures Series. The Art of Design. Ying Wu Electrical Engineering & Computer Science Northwestern University Outline. Data flow Top-down vs. bottom-up Coarse to fine Two examples MP#2 MP#4. Data Flow. Data - PowerPoint PPT Presentation


  • The Art of DesignYing Wu Electrical Engineering & Computer ScienceNorthwestern Universityyingwu@ece.northwestern.eduECE230 Lectures Series

  • OutlineData flowTop-down vs. bottom-upCoarse to fine Two examplesMP#2MP#4

  • Data FlowDatadata representation describe your inputs/outputsE.g. 1: an inputted sentence?E.g. 2: a segment of a command line?Inputs and outputs of the building blockswhat are given?what are expected?Data flowblocks are connected through data flow

  • Flow chartCoding is a very very small part of programmingdesign 40%coding 10%debugging 50%The starting point of designalways draw flow chartsorganize your thoughts by flow chartsuse testing cases to validate your flow charts

  • Top-downIncremental programmingDivide-and-conquerTask decompositionNo matter how small a task is, you can always divide it into a set of small sequential subtasksYou need to understand your tasksFocusMake the structure clear and neatAlways use the basic controlsSequential Selectionrepetitive

  • Coarse to FineCoarse FineCoarse designdetermines the structure of the programtells the basic ideadetails are all ignoredconcentrate on data flowOrganize it by subtasksRefinementA rough block can always by replaced by a refined flowchart It is much easier, because the tasks are simpler

  • Bottom-upBrain-storming programmingBottom designcreating a set of small toolsthinking based on basic operationsBottom Upputting tools togetherthis needs more experiences

  • ToolsExtracting those basic operationsE.g. 1: bypass all white spacesE.g. 2: check digitsForming functionsinputsoutputserror checking

  • Before you start Data representation?How do you represent a segment?st/edYour objectives?Find a segment determine st/ed

  • A Coarse Design

  • Code itint main(){cout
  • Checking after actionsCommand line buffer[500]Find the first element of a seg.Successful?Find the last element of the seg.Successful?Copy the segment to piece[100]piece screenStart the next segmentErrorYNNYYN

  • int main(){cout
  • Coarse-to-fine

  • Coarse-to-fine

  • Go even finer

  • Put things togetherFrom coarse-to-finealways draw flowchartskeep all your flowchart Adding things little by littledont put together all at onceValidate the new componentswhenever you refine a block, always debug it and make sure the whole thing is correctkeep the structure of the program clear