Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Structured Programming
#11
well i cant say im structured, afterall i just really started making a game where it doesnt end after a set amount of commands like a question game, but i cant say im not structured, if anyone has seen my code, i try and keep it structured, atleast i think
Reply
#12
The words "structured programming" are abused.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#13
how are the words abused, yes the words vary in definition, but that doesnt mean tehre abused, unless ur thinking something else
Reply
#14
Yes, they are abused because people twist their definition to their own evil needs.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#15
well everyone has there own needs which need to be met am i right, but just because someone takes them a different way then u think they should be taken doesnt mean they are being abused, although i could be wrong rite AGA, look at my code for the patin program for instance, which i got working, then i did something and it got messed up, and notepad only has 1 undo lvl
Reply
#16
As I understand it the main principle behind Structured Programming is avoiding the use of GOTO and GOSUB, apart from of course such as sensibly making sure your DIMs are at a the start and DATAs at the end. It also helps to try to use descriptive names to Variables and strings. Unfortunately this all make extra work, long names for variables may even slow up the program.

Avoiding the use of GOTO and GOSUB is fairly easy with BBCBASIC as it boasts the option of PROCedures. Liberty basic has no such luxuries and needs the constant use of these, though like QB any essential line numbers can be replaced by descriptive [labels]. However there is if course a much wider use of LB ( especially on the US).

BBCBASIC accepts only line numbers. There are several hundred examples of both languages on my site. Most of those in the BBCBASIC for Windows were published on a UK magazine the Beebug in the 80s and have now been released from copyright, and which I am continually adding. You may find some of interest for converting to QB and FB etc. Though in a ,BBC format there is a program BBCtoBAS for converting any to a readable ASCII BAS format, all run by activating the BBCMENU.EXE provided in each ZIP.

Gordon

http://sionet.mysite.wanadoo-members.co.uk/npage4.html
Reply
#17
most programmers flame the use of goto and gosub, and are always saying that you should use SUB's instead, but sometimes you just got to use goto's to accomplish a task rather then copy and re-paste the need code over and over again
Reply
#18
GOTO can always be substituted by a structured block. Most of the time, it's better not to use it 'cause you get a more readable code, specially if you are working with someone else. It's just good practice.

Sometimes, a GOTO comes handy to do an optimization, but if you are placing it as a patch you better revise your code. This is just an advice: it's better to rework an algorithm than patching it - spaghetti is easy to produce and can be hard to debug.

GOSUB is an absolute no-no. It doesn't have ANY advantages over structured SUBs or FUNCTIONs. Absolutely none. Why using a messy solution when you have a clean one, which also allows more stuff to be done?

I've always said that GOTO is great if you know what you are doing. Seriously, don't take this as a leet discuss, 'cause it isn't. It's just me giving advice. I've been coding for ages, and I've had to fight with a 200 lines-long spaghetti function just to find that I missed a very simple detail. If I would have had the function correctly structured, just a few watches would have made it to discover the bug.

So Aga wrote it perfectly some time ago: GOTO is like chocolate :lol:
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#19
Thanks for all your advice guys.

Gordon
Reply
#20
Quote:GOTO can always be substituted by a structured block

im not sure its strictly true how about nested do's and wanting to exit them all. i know you could set a flag to kick out of each DO in turn but i prefer this style.

Code:
Do
  Do
    Do
      goto pimp
    Loop
  Loop
Loop

pimp:
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)