Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding Efficiency
#22
(08-15-2024, 06:06 PM)justsomeguy Wrote: You know I always want write clean, efficent code, but my muddled brain always ends making thing way more complicated and I feature creep.

I start out thinking about doing this:
Code: (Select All)
FUNCTION GetMonth$(month)
    SELECT CASE month
        CASE 1: GetMonth$ = "January"
...
END FUNCTION

I end up doing this. Big Grin

Code: (Select All)
month$ = "JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember."
DO
INPUT "Input a number between 1 and 12"; n%
i% = 1: m$ = "": DO
  n% = n% + (INSTR("JFMASOND.", MID$(month$, i%, 1)) > 0)
  m$ = _TRIM$(m$ + CHR$((ASC(MID$(month$, i%, 1)) * -(n% = 0)) + (32 * -(n% <> 0))))
i% = i% + 1: LOOP WHILE i% < LEN(month$) AND n% >= 0
PRINT m$
LOOP
LOL, that's a perfect example of the "clever" code I spoke of earlier. It's beautiful code in its own strange way but come back to it a year later and it looks like an alien took a dump in the source, especially if every single stage of it is not documented well.

Please don't think I'm making fun of your code. Just a perfect example of how some of our "feature creepy" minds work. Smile
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply


Messages In This Thread
Coding Efficiency - by SMcNeill - 08-11-2024, 12:16 AM
RE: Coding Efficiency - by TerryRitchie - 08-11-2024, 01:21 AM
RE: Coding Efficiency - by SMcNeill - 08-11-2024, 03:25 AM
RE: Coding Efficiency - by CharlieJV - 08-11-2024, 01:29 AM
RE: Coding Efficiency - by Pete - 08-11-2024, 07:22 PM
RE: Coding Efficiency - by Dimster - 08-12-2024, 06:34 PM
RE: Coding Efficiency - by Pete - 08-13-2024, 09:46 PM
RE: Coding Efficiency - by SMcNeill - 08-13-2024, 11:11 PM
RE: Coding Efficiency - by Pete - 08-13-2024, 11:23 PM
RE: Coding Efficiency - by SMcNeill - 08-13-2024, 11:28 PM
RE: Coding Efficiency - by TerryRitchie - 08-14-2024, 01:21 AM
RE: Coding Efficiency - by Pete - 08-13-2024, 11:53 PM
RE: Coding Efficiency - by Pete - 08-14-2024, 03:38 PM
RE: Coding Efficiency - by SMcNeill - 08-14-2024, 04:26 PM
RE: Coding Efficiency - by mdijkens - 08-15-2024, 11:29 AM
RE: Coding Efficiency - by Pete - 08-15-2024, 03:20 PM
RE: Coding Efficiency - by Kernelpanic - 08-15-2024, 05:57 PM
RE: Coding Efficiency - by justsomeguy - 08-15-2024, 06:06 PM
RE: Coding Efficiency - by TerryRitchie - 08-16-2024, 03:21 AM
RE: Coding Efficiency - by justsomeguy - 08-16-2024, 07:09 AM
RE: Coding Efficiency - by Pete - 08-15-2024, 11:14 PM
RE: Coding Efficiency - by dano - 08-16-2024, 12:33 AM
RE: Coding Efficiency - by Pete - 08-16-2024, 12:35 AM
RE: Coding Efficiency - by SMcNeill - 09-11-2024, 01:55 AM
RE: Coding Efficiency - by Pete - 09-11-2024, 06:45 AM
RE: Coding Efficiency - by SMcNeill - 09-11-2024, 07:59 AM
RE: Coding Efficiency - by bplus - 09-11-2024, 01:51 PM
RE: Coding Efficiency - by SMcNeill - 09-11-2024, 02:01 PM
RE: Coding Efficiency - by bplus - 09-11-2024, 02:39 PM
RE: Coding Efficiency - by Pete - 09-11-2024, 02:48 PM
RE: Coding Efficiency - by dano - 09-12-2024, 01:41 PM
RE: Coding Efficiency - by Jack - 09-12-2024, 04:01 PM
RE: Coding Efficiency - by Kernelpanic - 09-12-2024, 08:13 PM
RE: Coding Efficiency - by Pete - 09-13-2024, 06:56 PM



Users browsing this thread: 28 Guest(s)