Planning Code

Planning Code

<p> Planning Code Copyright 2007 by Milica Barjaktarovic</p><p>Before we build anything, we should have a plan, right? Imagine what would happen if we wanted to build a house without a plan, and then end up with the kitchen in the basement and bedroom in the bathroom, and then tried to fix it all after it was all built. Well, that’s what software engineering can look like… Therefore, we should plan our code so that we can code and test easily. </p><p>First we start with a specification, often just a description in English, which then gets translated into high-level pseudocode, which we then progressively refine until we can code it. </p><p>What is the difference between high-level and low-level pseudocode? The amount of detail. </p><p>For example:</p><p>If the high level pseudocode is: DoHwk</p><p>Low level can be: //DoHwk read book read notes solve problems</p><p>And then it can get lower and lower, until it almost looks like code. For example, all pseudocode in our textbook is on the lowest level possible. Notice that it doesn’t have any implementation details, e.g. about data types, etc. </p><p>This approach is the core of object-oriented approach, or “black box” approach, where we break the code into various pieces. Then it is easy to test because each “box” should have a clearly indicated input and output. We then know what happens when we put in a certain input, what output we should get. This is so simple, very common sense, and will save you a lot of headache when coding. ICS311 Worksheet</p><p>Task: architect code for function MakeDinner(.). The function takes as inputs veggies, rice and fish and produces a cooked meal. (Notice that later you can reuse this function in a variety of other functions such as FancyDinner or RaisingHealthyKids or PoisonSomeoneWithFood.) Assume that at your disposal is a library of functions describing and operating on kitchen equipment. </p><p>Details: write progressively more involved pseudocode. Try to keep track of what should be function inputs and outputs, but don’t make it the priority at this point. Spend more time thinking how to develop the pseudocode in stages.</p><p>Notice that the choice of “kitchen equipment” will depend on your assumptions. For example, you can assume that you have a Java library that contains Fridge, Stove, and Sink; or Firepit, Stream, Garden, and DryingRack. For example:</p><p>Class Fridge {</p><p>Object fridge;</p><p>OpenFridge(…) Close Fridge(…) GrabFromFridge(…) IncreaseTemp(….) DecreaseTemp(…) Clean(…) Defrost(…) }</p><p>Or, you could have a Java library of functions such as:</p><p>Class Water {</p><p>Object water</p><p>GetWater() ThrowDirtyWater() } where the implementation of GetWater() could be: GetWaterFromFawcett () or FetchWaterFromStream(). </p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us