Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding Styles
#15
(08-09-2024, 11:21 PM)Kernelpanic Wrote:
Quote:
  • If a subroutine is generic enough that I might use it in some other program, or if I don't want to risk a subroutine modifying global variables, or if the subroutine is for a recursive process, I'll be setting up a SUB subroutine
A Sub or Procedure cannot change variables unless they are declared as Shared in the main program. Or did you mean something else?

(Just to try and clarify my usage of "SUB" subroutines vs "GOSUB" subroutines.)

I always make top level variables global.  Well, if ever I run into something that bites me in the rear, I'll likely change my habits.

I'll probably never change that habit because of the kind of programming I do (usually does not involve much code.)

(I'm a career OpenText Gupta Team Developer programmer, so there are certain organizational things from that programming environment that kind of stick with me when programming in BASIC.)

OMG, I'm having a rough night: just had to cancel a big mistake with an e-transfer.  In the midst of a migraine headache so having a hard time thinking straight.

If a subroutine has no need to use any global variables, then I will choose a SUB subroutine over a GOSUB subroutine.  Otherwise, i.e. a subroutine that is very intertwingled with the particular program, I will choose a GOSUB subroutine.

So a GOSUB versus subroutine call sort of tells me which kind of thing I'm dealing with just by how the subroutine is invoked.  (Little descriptive breadcrumbs without needing any other descriptive info.)

Now if I had variables that I really wanted to keep private to the main program, I'd likely put my main program in a "main" SUB.

Which is kind of odd considering my loathing of languages that always have a "main" function.

I think it all ties back to how code is organized in OpenText Gupta Team Developer.  (Programming with that has been my full-time job since 1995, so it does skew my thinking).
Reply


Messages In This Thread
Coding Styles - by Pete - 08-09-2024, 03:09 PM
RE: Coding Styles - by SpriggsySpriggs - 08-09-2024, 03:21 PM
RE: Coding Styles - by TerryRitchie - 08-09-2024, 05:29 PM
RE: Coding Styles - by Pete - 08-09-2024, 03:54 PM
RE: Coding Styles - by bplus - 08-09-2024, 04:03 PM
RE: Coding Styles - by SMcNeill - 08-09-2024, 09:03 PM
RE: Coding Styles - by Pete - 08-09-2024, 04:16 PM
RE: Coding Styles - by SpriggsySpriggs - 08-09-2024, 06:40 PM
RE: Coding Styles - by TerryRitchie - 08-09-2024, 07:52 PM
RE: Coding Styles - by Jack - 08-09-2024, 07:10 PM
RE: Coding Styles - by Jack - 08-09-2024, 07:19 PM
RE: Coding Styles - by Kernelpanic - 08-09-2024, 10:29 PM
RE: Coding Styles - by CharlieJV - 08-09-2024, 10:56 PM
RE: Coding Styles - by Kernelpanic - 08-09-2024, 11:21 PM
RE: Coding Styles - by CharlieJV - 08-09-2024, 11:27 PM
RE: Coding Styles - by Pete - 08-10-2024, 03:46 AM
RE: Coding Styles - by SMcNeill - 08-10-2024, 04:55 AM
RE: Coding Styles - by JRace - 08-10-2024, 09:41 AM
RE: Coding Styles - by SMcNeill - 08-10-2024, 10:43 AM
RE: Coding Styles - by OldMoses - 08-10-2024, 12:08 PM
RE: Coding Styles - by CharlieJV - 08-10-2024, 02:11 PM
RE: Coding Styles - by Pete - 08-10-2024, 02:55 PM
RE: Coding Styles - by bplus - 08-10-2024, 03:19 PM
RE: Coding Styles - by SMcNeill - 08-10-2024, 03:41 PM
RE: Coding Styles - by Pete - 08-10-2024, 04:28 PM
RE: Coding Styles - by SMcNeill - 08-10-2024, 11:08 PM
RE: Coding Styles - by Kernelpanic - 08-10-2024, 06:00 PM
RE: Coding Styles - by Pete - 08-10-2024, 07:30 PM
RE: Coding Styles - by TerryRitchie - 08-10-2024, 07:53 PM
RE: Coding Styles - by TempodiBasic - 08-11-2024, 12:46 PM
RE: Coding Styles - by Pete - 08-11-2024, 06:45 PM
RE: Coding Styles - by Kernelpanic - 08-19-2024, 06:35 PM
RE: Coding Styles - by quickbasic - 09-04-2024, 06:09 PM
RE: Coding Styles - by dano - 09-09-2024, 12:46 AM



Users browsing this thread: 36 Guest(s)