Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Here's another....file I/O difficulties.
#19
Sometimes you have really long functions (even longer if you do profusely comment!), and you can't split them. Take for example a fast syntactic analyzer. The fastest way to create it is with a SELECT CASE structure and a different entry for each keyword.

Note that I am an optimization and speed freak. Sometimes the "best looking algorithm" and the "best split function" are also way slower than uglier counterparts. When I coded my last finished QB game (i.e. Jill) the movement subroutine took up to 400 lines or so. I could've split it in subroutines, but the amount of data needed to be passed back and forth would have turned the process into a snail walking over sand :lol: That's why my code style is not always very ... rational.

Besides, I'm working now doing lots of web-coding mostly in Java, JSP and PHP, and I can assure you that you will find 1,000 lines functions quite easily :lol: specially when you have html rendering plus database handling plus open directory reading plus connection to a mail server plus call to a PDF generating library all in place (I mean, just the calls to all those subsystems take lots of lines - I just wrote a SQL query that took 15 lines five minutes ago Big Grin).

I think I'm missing something. What I claim is for declaration on top of your function/sub or main section. I am not encouraging module globals.

You claim to declare variables when they are used. And you talk about scope. As far as I know (correct me if I'm wrong, I've been several months unaware of additions to fB), then only way you have to isolate visibility in BASIC is inside a FUNCTION or a SUB. In C++ or Java you have your brackets so you have a perfect way to isolate chunks of code - this makes your life easier. In this case, I find extremely useful declaring and instancing objects when they are needed, in the fashion of:

Code:
if (iConnectorStream != null)
{
   StatementGenerator myGenerator = new StatementGenerator (blah, 1);
   ...
   // Here you can use myGenerator
}

// Here myGenerator is not declared

But in BASIC this is not possible (again, AFAIK Wink). Until it is, I'll keep declaring my stuff on top of each SUB/FUNCTION.

I suppose it's a matter of taste, but I find it more comfortable having all my declarations packed in a special section in the code rather than scattered around thousands of lines Big Grin plus I don't see the advantages of what you are suggesting, mainly 'cause you can't isolate chunks of code.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Messages In This Thread
Here's another....file I/O difficulties. - by Anonymous - 01-10-2006, 01:26 PM
Here's another....file I/O difficulties. - by na_th_an - 01-10-2006, 05:46 PM
Here's another....file I/O difficulties. - by DrV - 01-16-2006, 03:08 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)