Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Pseudo? vb

Options
  • 10-12-2002 11:52am
    #1
    Registered Users Posts: 446 ✭✭


    is pseudo code just plain english?
    Would you write it at the top of the program or as comments?


Comments

  • Registered Users Posts: 1,562 ✭✭✭Snaga


    pseudo code is a logical representation of what your real code will do, but its language independant.

    Its usually done as part of your design phase of a project. It allows you to have a nigh-on complete knowledge of how the real system will work.

    So when it comes to writing the system itself you wont get stung with too many 'whoops, I didnt think of _that_" moments requiring a rewrite of a whole section of code.

    If youve got it straight in your head before you begin the real code then actual development time is reduced aswell.

    It can be in english if you like, though a lot of people prefer a more structured 'programming language' style approach.


    In an example shamelessly copied from a google query on 'pseudocode examples' the following should show you an idea of what it would look like.
    
    Set total to zero
    
    Set grade counter to one
    
    While grade counter is less than or equal to ten
    
         Input the next grade
         Add the grade into the total 
    
    
    Set the class average to the total divided by ten
    
    Print the class average
    

    If you hand that to a vb programmer, a C++ programmer, a Java programmer etc etc they will all end up with code that does the same thing.

    As for its place, dont have it in your actual code in comments, include it as part of your design document. (If you dont have one...you should! ;) )


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by Snaga
    As for its place, dont have it in your actual code in comments, include it as part of your design document. (If you dont have one...you should! ;) )

    Well said. And, for all you budding java programmers out there....javadocs do not count as design documents ;)

    jc


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    One problem with pseudo-code is that it isn't quite as language-independant as some people (especially project managers who aren't experienced programmers) think.

    In particular they often reflect either OO or non-OO ways of thinking. Non-OO pseudo-code should generally be thrown in the bin if you are using an OO language. If you don't throw it in the bin you may be tempted to read it.

    Project managers and designers who don't bring in questions of which languages will be used until pretty much the end of the design phase may produce totally useless pseudo-code (and useless documentation of other sorts). As such it's probably even worse than having a particular language in mind from the very beginning.


  • Closed Accounts Posts: 42 BOP


    I would suggest using ur psuedo code as comments in your code. Many well regarded books advise this method, "Code Complete" being the one Im familiar with. The thoery is that when you have ur psuode code done (with pen + paper) for a routine you then type it in and write the actual code after its corrosponding pice of pseudo code.You finish with a perfectly commented piece of code.

    I'm not to sure about having reams of psuedo code as part of your design docs, dont they become irrelevnt as sone as a change is made to the code ? whos going to go back and update the design doc? Anyway thats a matter of opionion, but I thinnk every programmer should know the value of psuedo code.


  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    It's in maths books like!

    Comments is where you would use it best but I hate the thing


  • Advertisement
Advertisement