none
Writting Pseudo code and Structured English

    Question

  •  

    How do I go about writing pseudo code and structured English for this piece of code below, and in what manner... does it have to be as accurate as the real code itself, how detailed does if have to be.. Are there any rules…it's hard enough writing the computer version…?

    Would appreciate any help…

    My code


    'Module -Level Declaration
    Const gst As Decimal = 0.1
    Const mdecCarn_PRICE As Decimal = 14.3
    Const mdecIRISE_PRICE As Decimal = 9.7
    Const mdecROSE_PRICE As Decimal = 8.5

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    'Declaring form variables

    Dim deliveryPrice As Decimal
    Dim quantity As Decimal
    Dim quantity2 As Decimal
    Dim quantity3 As Decimal
    Dim subTotal1 As Decimal
    Dim subTotal2 As Decimal
    Dim subTotal3 As Decimal

    'Variable values equal text box controls

    deliveryPrice = deliveryPriceInput.Text
    quantity = txtQuantity.Text
    quantity2 = iriseQuantity.Text
    quantity3 = txtCarnQty.Text
    addedDelivery.Text = FormatCurrency(deliveryPrice)

    'label values hold quantity values and multiply's it by the flowers price

    lblextendedPrice.Text = FormatCurrency(quantity * mdecROSE_PRICE)
    lblirise_extendedPrice.Text = FormatCurrency(quantity2 * mdecIRISE_PRICE)
    lblcarn_extendedPrice.Text = FormatCurrency(quantity3 * mdecCarn_PRICE)

    'Sub total variables set up to hold extended price values

    subTotal1 = FormatCurrency(lblextendedPrice.Text)
    subTotal2 = FormatCurrency(lblirise_extendedPrice.Text)
    subTotal3 = FormatCurrency(lblcarn_extendedPrice.Text)

    'Quantity sub totals and delivery price are added together to hold sub total value

    lblsubTotal.Text = FormatCurrency(subTotal1 + subTotal2 + subTotal3 + deliveryPrice)

    'Sub total value is mulitplied with gst value of 0.1% to produce gst price figure

    gstTotal.Text = FormatCurrency(lblsubTotal.Text * gst)

    'All values are added together to produce final total

    lbltotalPrice.Text = FormatCurrency(gstTotal.Text + deliveryPrice + subTotal1 + subTotal2 + subTotal3)

    Saturday, November 03, 2007 7:12 AM

Answers

  • Lee Harvey,

     

    According to your question on Pseudo-Code and Structured English in VB.NET development, I would like to provide you the suggestions as follows:

     

    1. Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.  At the same time, the pseudocode needs to be complete.  It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code.

     

    In general the vocabulary used in the pseudocode should be the vocabulary of the problem domain, not of the implementation domain.  The pseudocode is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized.

     

    For futher information, please take a look at the article: PSEUDOCODE STANDARD

     

    2. Suggestions from Nick Halstead blog: First you may want to make a list of the main tasks that must be accomplished. Then, focus on each of those tasks. As I stated above you should try to break each main task down into very small tasks that can each be explained with a short phrase. In my experience it is a bad idea to go too close to the correlation of one-to-one between pseudo code and real code. The reason being that your pseudo code is there to help plan the structure but not to help resolve the details that fall out of real world programming.

     

    The use of variables within pseudo code should be restricted if possible but when it is necessary you should show the initialization of the variables. Overall, remember that the purpose of pseudocode is to help the programmer efficiently write code. Therefore, you must attempt to add enough detail and analysis to the pseudo code. It can be that the pseudo code is being written by one programmer and the real code by another. In these circumstances it is best to follow a slightly more strict definition of pseudo code

    Hope that can provide you some idea.

    Wednesday, November 07, 2007 5:22 AM

All replies

  • Lee Harvey,

     

    According to your question on Pseudo-Code and Structured English in VB.NET development, I would like to provide you the suggestions as follows:

     

    1. Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.  At the same time, the pseudocode needs to be complete.  It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code.

     

    In general the vocabulary used in the pseudocode should be the vocabulary of the problem domain, not of the implementation domain.  The pseudocode is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized.

     

    For futher information, please take a look at the article: PSEUDOCODE STANDARD

     

    2. Suggestions from Nick Halstead blog: First you may want to make a list of the main tasks that must be accomplished. Then, focus on each of those tasks. As I stated above you should try to break each main task down into very small tasks that can each be explained with a short phrase. In my experience it is a bad idea to go too close to the correlation of one-to-one between pseudo code and real code. The reason being that your pseudo code is there to help plan the structure but not to help resolve the details that fall out of real world programming.

     

    The use of variables within pseudo code should be restricted if possible but when it is necessary you should show the initialization of the variables. Overall, remember that the purpose of pseudocode is to help the programmer efficiently write code. Therefore, you must attempt to add enough detail and analysis to the pseudo code. It can be that the pseudo code is being written by one programmer and the real code by another. In these circumstances it is best to follow a slightly more strict definition of pseudo code

    Hope that can provide you some idea.

    Wednesday, November 07, 2007 5:22 AM
  • Hi Lee,

     

    Imagine if you will the steps it would take to program a robot ( imagine C3P0 from StarWars could not talk but only maybe write feedback to you ) to make a hot drink like tea or coffee for you.

     

    Where would you start?

     

     

    Pseudo Code Block

     

    Are you standing?

    If yes then are you at home?

    If yes then walk to the kitchen.

     

    ....etcetera.

     

     

     

    A lot of coding is built on conditions or whether events like Has the water in the kettle boiled yet? are True or False or not determined yet.

     

    The kettle could be cold, hot ( like just switched off ) or warm.

     

    Write down in short sentences what needs to be achieved and what conditions or tests need to be made as above.

     

     

     

     

    Regards,

     

    John

     

    Wednesday, November 07, 2007 8:25 AM