Note that there are some explanatory texts on larger screens.

plurals
  1. POProcess to pass from problem to code. How did you learn?
    primarykey
    data
    text
    <p>I'm teaching/helping a student to program.</p> <p>I remember the following process always helped me when I started; It looks pretty intuitive and I wonder if someone else have had a similar approach.</p> <ol> <li>Read the problem and understand it ( of course ) .</li> <li>Identify possible "functions" and variables.</li> <li>Write how would I do it step by step ( algorithm ) </li> <li>Translate it into code, if there is something you cannot do, create a function that does it for you and keep moving.</li> </ol> <p>With the time and practice I seem to have forgotten how hard it was to pass from problem description to a coding solution, but, by applying this method I managed to learn how to program.</p> <p>So for a project description like: </p> <blockquote> <p><em>A system has to calculate the price of an Item based on the following rules ( a description of the rules... client, discounts, availability etc.. etc.etc. )</em></p> </blockquote> <p>I first step is to understand what the problem is.</p> <p>Then identify the item, the rules the variables etc.</p> <p>pseudo code something like:</p> <pre><code>function getPrice( itemPrice, quantity , clientAge, hourOfDay ) : int if( hourOfDay &gt; 18 ) then discount = 5% if( quantity &gt; 10 ) then discount = 5% if( clientAge &gt; 60 or &lt; 18 ) then discount = 5% return item_price - discounts... end </code></pre> <p>And then pass it to the programming language..</p> <pre><code>public class Problem1{ public int getPrice( int itemPrice, int quantity,hourOdDay ) { int discount = 0; if( hourOfDay &gt; 10 ) { // uh uh.. U don't know how to calculate percentage... // create a function and move on. discount += percentOf( 5, itemPriece ); . . . you get the idea.. } } public int percentOf( int percent, int i ) { // .... } } </code></pre> <p>Did you went on a similar approach?.. Did some one teach you a similar approach or did you discovered your self ( as I did :( ) </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload