Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: best practice

by dragonchild (Archbishop)
on Aug 27, 2001 at 18:21 UTC ( [id://108130]=note: print w/replies, xml ) Need Help??


in reply to Re: best practice
in thread best practice

I disagree with not writing Perl pseudocode. (Or, rather, I would if I ever wrote pseudocode.) Just because Perl is a higher-level language than C doesn't mean that writing in it frees you from good design practices.

It ends up that most of the uses people put Perl to are simple enough that pseudo-code isn't necessary. However, I worked on a project that was a full-fledged system. We wrote pseudo-code on whiteboards and the like a number of times. Whenever I didn't write pseudo-code, I generally regretted it. (However, I still didn't write pseudo-code. I'm great on theory, lazy in practice. It's also why I'm great with rewrites. *grins*)

Now, pseudo-code takes a lot of forms. For example, if you're writing a CGI script, the pseudo-code has been created for you - it's called CGI.pm and you should use it. Your design document is the mockup of the page you want to create. (You do create mockups of your website beforehand, right?)

Another example would be the brainstorming you do with a coworker that gives you the idea in mind. You then go and write a prototype. You test that, adding onto it, and end up with your development module. You bang on that some more and end up with v0.1 - that's a type of pseudo-code we call "prototyping" and "iterative development".

Now, I'm not saying that doing PDL, or the like, is a bad thing. In fact, in languages that require you to do more work (like C++ or Fortran), it's necessary if you're doing anything with any sort of complexity.

To achieve a similar level of design-need in Perl, you probably have a much higher level of output-need. Which boils down to:

To achieve 'A' in C, you need pseudo-code. To achieve 'A' in Perl, you might need pseudo-code, but it's probably a good idea.

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!

Replies are listed 'Best First'.
Re: Re: Re: best practice
by Aighearach (Initiate) on Aug 27, 2001 at 22:41 UTC
    Just because Perl is a higher-level language than C doesn't mean that writing in it frees you from good design practices.
    Of course. I'm not suggesting abondoning good design practices. I'm suggesting a different set of design practices that is popular amoung some groups of Perl programmers.
    You do create mockups of your website beforehand, right?
    No, I use a template system so that design and code are seperate, and design can be changed on the fly. Perhaps the web designers resposible for the look and feel do mockups; I wouldn't know what good web design practices are, I'm just a programmer.
    Now, pseudo-code takes a lot of forms. For example, if you're writing a CGI script, the pseudo-code has been created for you - it's called CGI.pm and you should use it.
    No, that's called code reuse, and yes it is a wonderful thing.
    You then go and write a prototype. You test that, adding onto it, and end up with your development module. You bang on that some more and end up with v0.1 - that's a type of psuedo-code we call "prototyping" and "iterative development".
    No, that's a rough draft or prototype, not pseudocode. By definition, pseudocode is not real code and cannot be executed. Not everything that is part of the design phase is pseudocode.
    --
    Snazzy tagline here
Re: Re: Re: best practice
by George_Sherston (Vicar) on Aug 27, 2001 at 22:43 UTC
    You wouldn't happen to have a blob of pseudocode lying about the place that you could paste in to give a flavour of how you write it? Perhaps with a corresponding finished snippet? I sort of have an idea of what pseudocode is, but I'd be grateful for pointers about how much detail others find it useful to go into, etc.

    § George Sherston
      I personally don't write pseudocode, primarily because the type of projects I work right now on tend to not need it. However, according to
        Code Complete
      , pseudocode should adequately describe the functioning of the routine in detail enough to implement it in any language, yet not go into so much detail that it's obvious what language it was designed for.

      For example, you wouldn't say "Increment $i by 1.", because you've limited what languages you can write this pseudo-code in. Instead, you'd say "Increment the Bank Record Number by 1.". Or, even better, you would say "Go to the next Bank Record."

      Say you were taking money out of a ATM. (This is a common example in the books.) It might look something like:

      Put your card into the ATM Input your PIN# when requested Input desired amount of money Wait for money to arrive Take money and card and receipt
      Now, you can take those five lines and convert them into running code in any language, given a set of functions that can interface an ATM. I haven't limited your choice of language.

      ------
      /me wants to be the brightest bulb in the chandelier!

      Vote paco for President!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://108130]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-19 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found