Is use of GOSUB bad coding?

Everything else that doesn't fall into one of the other PB categories.
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Joakim Christiansen wrote:All people using GOTO's are gays!! :P
LOL, and those who don't use GOTO's are lesbians!! :P
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Pupil wrote:
Joakim Christiansen wrote:All people using GOTO's are gays!! :P
LOL, and those who don't use GOTO's are lesbians!! :P
Hiii... but what about all the gays who don't use goto, what are they ?? now i'm really confused :?: :roll:
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Hades wrote:@Pupil

Using Goto at all is bad coding style. That's all I wanted to say. You don't have to agree.
It's like I said: Do what you like.
I can't believe you're telling me my coding style is bad, how rude! ;)
At least we can agree on disagreeing. :)
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Goto's are gay!
--Kale

Image
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Kale wrote:Goto's are gay!
Like you? :twisted:
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

:shock:
--Kale

Image
dioxin
User
User
Posts: 97
Joined: Thu May 11, 2006 9:53 pm

Post by dioxin »

GOSUB/GOTO are powerful features but not everyone is up to handling them.
Those that can, get on with it.
Those that can't tell everyone else they're wrong.

Paul.
User avatar
Hades
Enthusiast
Enthusiast
Posts: 188
Joined: Tue May 17, 2005 8:39 pm

Post by Hades »

The wheels on my car are cornered. It's perfect that way. And anyone who tells me it isn't just can't drive. :roll:
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

dioxin wrote:GOSUB/GOTO are powerful features but not everyone is up to handling them.
Those that can, get on with it.
Those that can't tell everyone else they're wrong.

Paul.
A typical nonsense discussion, this matter seems often based on being scared what others think.

Is using an open file statement not equally 'bad'?
I mean i can overwrite a windows dll in a snap.

At least gosub's where very handy to me, goto's a little less but sometimes..
It's a pitty .net abandoned these at all.
Oh well, that's another topic :)

You know what REALLY bad programming is?
1) Things like DEFINT and so.

2) A programming language not being able to set an OPTION EXPLICIT (or lookalike).
I believe pb has this feature at last in this v4.0 release, if so, apreciated.

3) Well, you might think of this one.. not forcing a winmain procedure, well.. can't explain why but somehow i find this having to much of a Quick Basic taste..
Phoenix
Enthusiast
Enthusiast
Posts: 141
Joined: Sun Sep 04, 2005 2:25 am

Post by Phoenix »

Hades wrote:Using Goto at all is bad coding style
No, it's just a personal opinion. How you code is your own business. If the source code to PureBasic showed that Fred used Gotos everywhere, would that make you lose respect for Fred? Of course not.
User avatar
Hades
Enthusiast
Enthusiast
Posts: 188
Joined: Tue May 17, 2005 8:39 pm

Post by Hades »

:?

I'm well awere it's just my opinion that using Goto is bad coding style, but I have strong reasons to believe so. I always said do what you like. And it's absolutly possible to write a great program in a bad style. It's just harder.

Some people here sound like Goto is their god. :roll:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

well, i've never ever found a reason to use goto or gosub...

i tend to believe goto's are not the best choice in most cases, but i don't like the 'break' command either

in fact, anything that breaks the 'flow' of the code is what i do not like

ie. i want code to be 'closed', as in

Code: Select all

for a = 1 to 10
  b = b+1
next a
there's no jumping in or out, and it's quickly possible to see what belongs to what

well, perhaps someone can show me a case where goto is improving your code? (ah, a challenge! :-)) if no one can i think i'll switch to the 'goto is bad' camp :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

>where goto is improving your code?
I think no-one but it's simply a benefit, espec. a gosub.

I'm doing .NET, you know what i think is bad programming style?
Being possible to reuse a dimming statement in a loop like:

Foreach(...)
{
(objecttype...) x = new (objecttype...);
}

It works but i found it counter productive (speed reasons and such)

Note that this won't compile:
(objecttype...) x = new (objecttype...);
(objecttype...) x = new (objecttype...);

So why should it work in a loop?
I do understand but it's not logical to me.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

IMO, bad code is code that is hard to support.

If it does the job adequately: If the next guy can understand it and enhance it: If you can maintain it 1 year down the track: Then it is good code.

That is all that really matters.





Edit and aside: C++ is bad code waiting to happen.
@}--`--,-- A rose by any other name ..
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Dare2 wrote:IMO, bad code is code that is hard to support.

If it does the job adequately: If the next guy can understand it and enhance it: If you can maintain it 1 year down the track: Then it is good code.

That is all that really matters.

Edit and aside: C++ is bad code waiting to happen.
Hmm, no programmer will be able to understand code from someone else if it's size is becomming to large, even if it is rock solid code.
I mean all the jumps to different functions make it very difficult to understand the code.
Often a rewrite is a valid option, we encounter these matters so now and then.
Sometimes the decision is made to wait with updating to plan a major rewrite.

Yes.. all bad practises, documentation is poor and if someone leaves the building... well you can fill that one in yourself. :)

Frankly, i don't even think that documentation would help.
But then, i never document, i keep functionality as modular as possible.
Each functionality in a separate includefile.
Each function described briefly.
It is maintanable but does not help other programmers, at least myself.
Post Reply