Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Structured Programming
Quote:
na_th_an Wrote:
Moneo Wrote:
axipher Wrote:I do fine with fb, and really, what’s wrong with using GOTO/GOSUB's, if the program works that should be enough. Shouldn't it???
Axipher, you made a very good point here that perhaps the structured programming purists missed.

Your point is: "if the program works...". I think that's the important issue. You wrote it, you tested it, you modify it, and you're happy with it. Almost all the QB/FB programs that all of us here write are for our own use, and are not going to have to pass inspection by some programming standards committee. If some of us chose to use gotos or GOSUB’s because we fell comfortable coding that way and have success doing so, then "to each his own."

If the programs we write were to be maintained by programmers other than ourselves, then yes, it would be a good convention to write these programs in a structured manner.
*****

The problem is, if we have to train and try to educate future programmers, we better teach them good practice.

I don't know how programming businesses are over there, but here, that you know how to do properly structured and indented programming is a must. Many businesses even have a "book of style" with directions on how to format your code. Because time is money, if some other employee has to keep with your project, it's better that he understands the sources in no time.

It's like when you are taking scripts. You get any pen on any kind of paper, and squibble fastly. Most of the time, you will understand it. I mean, it does the job. But what if you want the script to be read and understood, used and expanded by some other person? You have to use a proper paper, nice indentation and good calligraphy.

Structured programming is just that. It favourishes encapsulation, something that is a really important concept when you are going to work in a big project with more people. It favourishes readability. It also favourishes scalability. It's easier to debug and, most of all, easier to expand and to maintain.

I'm just talking of experience. I sometimes review my old programs and I have to spend some time figuring out where all those branches go and what do those unindented nested loops begin and end, which are inside which and stuff like that.

Plus, using GOSUB’s instead of SUBs is horrid for scalability. Imagine that you code something and place all your subroutines behind labels and you use GOSUB to call them. Now leave that program for two years. After that time, your boss asks you to add a new capability that someone else coded. You cut and paste the code and... ARGH! Same variable names! Everything goes haywire and you have to review the source line by line to replace the variable names. That takes time.

If you had used SUBs, you just stick the new SUB in your code and forget about it. You don't even have to read the new code. That's encapsulation.

That's why all my claims grow stronger and stronger. Meg has her own crusade as well. I think that in places like this we are "forming" future programmers. And no matter how we prefer to code, we should try to show them the "easiest way to success".

I do use GOTOs, but I strongly speak against newbies using them. Avoid GOTO like the plague until you know exactly what you are doing.





Instead of posting a meaningless post like usual, this post will actually contain information worth reading. Now Moneo, I did make a good point and na_th_an countered quite nicely, I think that most programs people make never do get released and are for personal use or for experiments. Some people though, like me, won't abandon a project until it is done and have a separate document explaining exactly what each part of the code does. Now if the program works and it is not being added to or being reviewed by someone who has never seen the code before, then using GOTO's and GOSUB's is ok, if I were making a program where there was more then just me working on it, then I would use SUB's instead. Now on the fact of indenting and UPPERCASE KEYWORDS, I am a great example, I actually do most of my coding on a Palm Pilot, I use the graffiti area to just write away, then when I transfer it to FreeBasic, it is all lower case and everything is aligned left, FreeBasic has 2 great features, 1 that turns all keywords into UPPERCASE and a feature that auto-indents. So I say don't worry about messy code when it comes to indents and keywords, they can easily be solved. Now na_th_an, I understand your stance on how we must teach future programmers proper techniques, but I found multiple teaching resource such as programs and books that teach BASIC and the first lessons use GOTO's and GOSUB's, also sometimes when examples are included with the source, you can't understand the code because of this. But if the source was not included or the program had no GOTO's or SUB's, the program would have worked just as well.

One last thing that deserves a paragraph of it's own, you all me posting off-topic or meaniningless posts, but then you go and flame them and create more useless posts, why not PM me and tell me to delete the post before anyone else posts???

P.S.: That's a lot of text, hope there's no mistakes :o I even corrected some of the quote's errors Big Grin
Even if you are the only one using the program. Can you explain why you prefer gosub over sub?
Reply


Messages In This Thread
Structured Programming - by GordonSweet - 12-05-2005, 04:29 PM
Structured Programming - by Plasma - 12-05-2005, 05:09 PM
Structured Programming - by GordonSweet - 12-05-2005, 07:57 PM
Structured Programming - by axipher - 12-05-2005, 08:19 PM
Structured Programming - by marzecTM - 12-05-2005, 08:35 PM
Structured Programming - by yetifoot - 12-05-2005, 09:58 PM
Structured Programming - by MystikShadows - 12-05-2005, 10:58 PM
Structured Programming - by TheDarkJay - 12-05-2005, 11:02 PM
Structured Programming - by yetifoot - 12-06-2005, 12:47 AM
Structured Programming - by TheDarkJay - 12-06-2005, 01:07 AM
Structured Programming - by axipher - 12-06-2005, 06:45 AM
Structured Programming - by Agamemnus - 12-06-2005, 07:00 AM
Structured Programming - by axipher - 12-07-2005, 02:05 AM
Structured Programming - by Agamemnus - 12-07-2005, 07:57 AM
Structured Programming - by axipher - 12-07-2005, 08:47 AM
Structured Programming - by GordonSweet - 12-07-2005, 12:51 PM
Structured Programming - by axipher - 12-07-2005, 08:06 PM
Structured Programming - by na_th_an - 12-07-2005, 08:16 PM
Structured Programming - by GordonSweet - 12-07-2005, 09:01 PM
Structured Programming - by yetifoot - 12-07-2005, 11:48 PM
Structured Programming - by na_th_an - 12-07-2005, 11:50 PM
Structured Programming - by Frenkel - 12-08-2005, 01:54 AM
Structured Programming - by axipher - 12-08-2005, 03:54 AM
Structured Programming - by yetifoot - 12-08-2005, 04:02 AM
Structured Programming - by axipher - 12-08-2005, 04:07 AM
Structured Programming - by GordonSweet - 12-08-2005, 12:29 PM
Structured Programming - by Frenkel - 12-08-2005, 03:20 PM
Structured Programming - by axipher - 12-08-2005, 07:02 PM
Structured Programming - by Agamemnus - 12-08-2005, 08:29 PM
Structured Programming - by marzecTM - 12-08-2005, 08:38 PM
Structured Programming - by thegrogen - 12-08-2005, 09:36 PM
Structured Programming - by axipher - 12-09-2005, 02:27 AM
Structured Programming - by Z!re - 12-09-2005, 02:59 AM
Structured Programming - by Deleter - 12-09-2005, 03:02 AM
Structured Programming - by axipher - 12-09-2005, 03:20 AM
Structured Programming - by marzecTM - 12-09-2005, 03:28 AM
Structured Programming - by axipher - 12-09-2005, 03:43 AM
Structured Programming - by Moneo - 12-09-2005, 05:39 AM
Structured Programming - by axipher - 12-09-2005, 05:49 AM
Structured Programming - by Moneo - 12-09-2005, 06:11 AM
Structured Programming - by axipher - 12-09-2005, 06:58 AM
Structured Programming - by Z!re - 12-09-2005, 03:33 PM
Structured Programming - by na_th_an - 12-09-2005, 04:53 PM
Structured Programming - by Z!re - 12-09-2005, 05:06 PM
Structured Programming - by marzecTM - 12-09-2005, 05:23 PM
Structured Programming - by Deleter - 12-09-2005, 05:26 PM
Structured Programming - by na_th_an - 12-09-2005, 05:41 PM
Structured Programming - by GordonSweet - 12-09-2005, 07:27 PM
Structured Programming - by axipher - 12-09-2005, 08:05 PM
Structured Programming - by GordonSweet - 12-09-2005, 09:15 PM
Structured Programming - by marzecTM - 12-09-2005, 10:00 PM
Structured Programming - by Moneo - 12-10-2005, 07:20 AM
Structured Programming - by axipher - 12-10-2005, 09:17 PM
Structured Programming - by Agamemnus - 12-11-2005, 07:33 AM
Structured Programming - by yetifoot - 12-11-2005, 07:52 AM
Structured Programming - by axipher - 12-11-2005, 08:29 AM
Structured Programming - by Agamemnus - 12-11-2005, 10:18 AM
Structured Programming - by axipher - 12-11-2005, 10:29 AM
Structured Programming - by Agamemnus - 12-11-2005, 11:28 AM
Structured Programming - by axipher - 12-12-2005, 01:49 AM
Structured Programming - by Nemesis - 12-13-2005, 11:26 AM
Structured Programming - by GordonSweet - 12-13-2005, 12:46 PM
Structured Programming - by axipher - 12-13-2005, 08:09 PM
Structured Programming - by Agamemnus - 12-14-2005, 11:24 AM
Structured Programming - by axipher - 12-14-2005, 06:52 PM
Structured Programming - by Agamemnus - 12-15-2005, 10:02 AM
Structured Programming - by GordonSweet - 12-15-2005, 12:29 PM
Structured Programming - by axipher - 12-15-2005, 08:05 PM
Structured Programming - by na_th_an - 12-15-2005, 08:26 PM
Structured Programming - by axipher - 12-15-2005, 08:47 PM
Structured Programming - by na_th_an - 12-15-2005, 08:51 PM
Structured Programming - by GordonSweet - 12-15-2005, 09:29 PM
Structured Programming - by na_th_an - 12-15-2005, 10:21 PM
Structured Programming - by GordonSweet - 12-16-2005, 12:19 AM
Structured Programming - by axipher - 12-16-2005, 05:16 AM
Structured Programming - by speedlemon - 12-16-2005, 06:20 AM
Structured Programming - by yetifoot - 12-16-2005, 06:24 AM
Structured Programming - by axipher - 12-16-2005, 06:42 AM
Structured Programming - by LooseCaboose - 12-16-2005, 07:13 AM
Structured Programming - by axipher - 12-16-2005, 07:29 AM
Structured Programming - by Mango - 12-16-2005, 09:22 AM
Structured Programming - by LooseCaboose - 12-16-2005, 11:06 AM
Structured Programming - by axipher - 12-16-2005, 07:07 PM
Structured Programming - by Anonymous - 12-16-2005, 07:19 PM
Structured Programming - by axipher - 12-16-2005, 07:30 PM
Structured Programming - by Carl Gundel - 12-16-2005, 09:52 PM
Structured Programming - by yetifoot - 12-16-2005, 11:58 PM
Structured Programming - by axipher - 12-17-2005, 06:46 AM
Structured Programming - by stylin - 12-17-2005, 09:28 AM
Structured Programming - by Deleter - 12-17-2005, 09:41 AM
Structured Programming - by Carl Gundel - 12-17-2005, 07:12 PM
Structured Programming - by thegrogen - 12-17-2005, 10:05 PM
Structured Programming - by Agamemnus - 12-17-2005, 10:16 PM
Structured Programming - by axipher - 12-17-2005, 11:18 PM
Structured Programming - by stylin - 12-17-2005, 11:30 PM
Structured Programming - by axipher - 12-18-2005, 12:00 AM
Structured Programming - by stylin - 12-18-2005, 12:11 AM
Structured Programming - by axipher - 12-18-2005, 01:03 AM
Structured Programming - by Z!re - 12-18-2005, 04:31 AM
Structured Programming - by Moneo - 12-18-2005, 06:36 AM
Structured Programming - by Z!re - 12-18-2005, 08:29 AM
Structured Programming - by marzecTM - 12-18-2005, 08:47 AM
Structured Programming - by stylin - 12-18-2005, 09:58 AM
Structured Programming - by marzecTM - 12-18-2005, 10:15 AM
Structured Programming - by Z!re - 12-18-2005, 10:22 AM
Structured Programming - by marzecTM - 12-18-2005, 10:24 AM
Structured Programming - by Z!re - 12-18-2005, 10:25 AM
Structured Programming - by Sumo Jo - 12-18-2005, 10:26 AM
Structured Programming - by marzecTM - 12-18-2005, 10:28 AM
Structured Programming - by Sumo Jo - 12-18-2005, 10:37 AM
Structured Programming - by marzecTM - 12-18-2005, 10:47 AM
Structured Programming - by Z!re - 12-18-2005, 10:51 AM
Structured Programming - by stylin - 12-18-2005, 11:11 AM
Structured Programming - by marzecTM - 12-18-2005, 11:20 AM
Structured Programming - by stylin - 12-18-2005, 11:23 AM
Structured Programming - by marzecTM - 12-18-2005, 05:24 PM
Structured Programming - by na_th_an - 12-18-2005, 11:09 PM
Structured Programming - by axipher - 12-19-2005, 12:10 AM
Structured Programming - by stylin - 12-19-2005, 01:50 AM
Structured Programming - by axipher - 12-19-2005, 02:07 AM
Structured Programming - by speedlemon - 12-19-2005, 04:57 AM
Structured Programming - by Zap - 12-19-2005, 05:17 AM
Structured Programming - by Moneo - 12-19-2005, 06:04 AM
Structured Programming - by axipher - 12-19-2005, 06:23 AM
Structured Programming - by Moneo - 12-19-2005, 06:24 AM
Structured Programming - by stylin - 12-19-2005, 06:28 AM
Structured Programming - by axipher - 12-19-2005, 06:39 AM
Structured Programming - by Moneo - 12-19-2005, 06:41 AM
Structured Programming - by axipher - 12-19-2005, 06:55 AM
Structured Programming - by Agamemnus - 12-19-2005, 08:44 AM
Structured Programming - by axipher - 12-19-2005, 09:29 AM
Structured Programming - by thegrogen - 12-19-2005, 09:38 AM
Structured Programming - by axipher - 12-19-2005, 09:56 AM
Structured Programming - by thegrogen - 12-19-2005, 10:04 AM
Structured Programming - by stylin - 12-19-2005, 10:05 AM
Structured Programming - by Z!re - 12-19-2005, 10:07 AM
Structured Programming - by axipher - 12-19-2005, 10:22 AM
Structured Programming - by thegrogen - 12-19-2005, 10:23 AM
Structured Programming - by Agamemnus - 12-19-2005, 10:42 AM
Structured Programming - by marzecTM - 12-19-2005, 11:03 AM
Structured Programming - by yetifoot - 12-19-2005, 06:52 PM
Structured Programming - by axipher - 12-19-2005, 08:58 PM
Structured Programming - by Agamemnus - 12-20-2005, 01:10 AM
Structured Programming - by Z!re - 12-20-2005, 01:15 AM
Structured Programming - by axipher - 12-20-2005, 06:44 AM
Structured Programming - by Agamemnus - 12-21-2005, 03:21 AM
Structured Programming - by axipher - 12-21-2005, 07:29 AM
Structured Programming - by Agamemnus - 12-21-2005, 11:08 AM
Structured Programming - by axipher - 12-21-2005, 08:10 PM
Structured Programming - by GordonSweet - 12-28-2005, 01:40 PM
Structured Programming - by Moneo - 01-01-2006, 12:46 AM
Structured Programming - by Blitz - 01-20-2006, 11:25 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)