Silverfrost Forums

Welcome to our forums

Structured programming newbie! could someone please advise?

12 Oct 2007 3:57 #2354

Quoted from weaverwb Would that be a computer program to prove Fermat's Last Theorem, then?

Ha! I deserved that!(':lol:')

Hehe, I'm glad that didn't get lost in the mix. Was it actually your intention to allude to Fermat's famous comment?

Quoted from weaverwb For some of us, remembering ijklmn is no problem and we find no other use in typing each and every variable.

This isn't the only reason for strong typing, though, is it? (or even the main one, in my book). I think the typo-catching safety net is the best argument for IMPLICIT NONE. What are your thoughts on that?

12 Oct 2007 8:27 #2355

Hehe, I'm glad that didn't get lost in the mix. Was it actually your intention to allude to Fermat's famous comment?

well, no; my thought was to Mark Antony coyly saying that he could not read Jullie's last will at the funeral oration. Your suggestion is much better.

On the typo catching issue, which is often given as the primary reason for explicit typing, is a bit more complicated for me. Depending on the application, I use two types of variable names. In the world where data dictionaries are needed and names are terribly long, there is the joy of cutting and pasting. Otherwise, I strive for short but descriptive and easy to spell, easy to recognize a misspelling (unless I'm making a joke; e.g., using O). Still, of course, misspellings occur but they mostly fall out in the first level debugging (cleanup) and don't take anywhere near the time that re-understanding a difficult algorithm later takes. I almost always use the explicit typing rules even if I'm, for some odd reason, using implicit none.

Simply, I don't consider the cost of the safety net worth the pretty modest additional safety. When I teach it, I tell'em what their options are as opposed to telling them that there is only one good way to do things. When you meet young programmers on the job, they think there is only one right way to do things (this confusion of fad and style with true constraints is not limited to programming; young scientists have difficulty distinguishing among fads, hypothesizes, theory, and observations).

This plays into a broader problem. Studies have revealed that a difference between beginners and experienced folk is that beginners think there is only one way to solve a problem and they bang away at it until the cows come home. Experienced folks know that there are many ways to solve a problem and they discard the hardest ways until they find an easier path. I believe the more you make beginners aware of the flexibility available in exercising their craft, the sooner they'll gain the confidence to explore alternatives.

12 Oct 2007 8:56 #2356

Quoted from weaverwb I strive for short but descriptive and easy to spell, easy to recognize a misspelling (unless I'm making a joke; e.g., using O).

I'm glad you mentioned O! In my last post, I was going to observe that FORTRAN is fault-tolerant in having a default typing that renders benign the O/0 (which are of course adjacent on the keyboard) typo, on account of O defaulting to type integer, which in turn defaults to 0 if it is not set explicitly - then I remembered that O is the first character *after *IJKLMN ...

Nearly a default integer, but not quite. An 'off by one' error. How ironic.

Andy

13 Oct 2007 11:59 #2357

I'm not sure what your arguments are suggesting, but two useful points.

  1. IMPLICIT NONE or /IMPLICIT_NONE is a very useful coding environment.

  2. The use of a MODULE for many parameter and global variable declarations assists in reducing the declaration overload at the start of a routine.

If you have, in a long and round about way suggested differently, I would strongly disagree.

John

13 Oct 2007 5:27 #2358

Sorry about the length of things which may have obfuscated my basic point; I'll try to summarize:

Programming is a craft. the best tools are those that permit the craftsman to express himself in ways that best suit him.

Folks that insist that there is only one correct style may be managers who wish that all programmers are the same and can easily be replaced or, imho, worse, software folks who actually believe it (for a list of most of the fads I've had to live through, see 'Great Software Debates' by Alan Davis. Perhaps the chapter 'Software Lemmings' introduces it well.)

Fortran programmers should be especially sensitive to this as the current fad is that all code should be C++ (although I sense a transition to Java. A 'Death March' project I bailed from about 6 years ago is trying to convert a near-real time system that handles about 30 million people to Java. In this case, my prognostication was wrong -- I said, when I left, that the project would take five years, cost $106, and the result would be a slower response time. It is now six years, has cost several x $106, and they are pretty much where they started, using the old code which works fine. They have only successfully converted about two programs out of a couple hundred.).

** For me, IMPLICIT NONE is not a useful coding environment** for reasons that I explained. I find it a very inefficient environment.

There are sensible reasons, given above, why **newbies should be told of their choices **so they can decide for themselves. One reason I didn't list is the fear that they'll grow up and try to impose these preferences/fads on everyone through modifications to programming languages.

MODULEs are nice and I like using them, however, I think the primary issue is the declarations of local variables.

Please login to reply.