Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Here's another....file I/O difficulties.
#21
Quote: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.
Yes, design should adapt the needs at hand, obviously. I'm not suggesting a blanket coding style, however in my experience, the companies I've worked for have required similar styles - in C++, variable initialization is a given. Granted, you have some leeway with function length since the IDE you're using can help you out (outlining/folding, function selection, statement completion, declaration/definition locating, etc.) FreeBASIC does not currently have such an exclusive IDE, but I'm of the mind that an IDE shouldn't be the main factor in how you implement code, either.

Quote: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.
Again, it depends on who's reading your code. For hobby work, either individually or with a small team, then feel free to code however it takes to be better productive, of course. For employers, software teams mandate a certain style, regardless of your personal preference. I realize that FreeBASIC, C, C++, Java, etc. are different languages. However, I strongly feel that beginning programmers should learn habits similar to that of those languages, since 1) it will only help them in transitioning over, and 2) languages like FreeBASIC are designed to give you the freedom to be able to do that (make the transition from FB to, for example C++, very easy by following similar programming paradigms).

Quote: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'm not very familiar with web-programming, but no Java function I've ever been assigned to has been 1000 lines long ... I'd probably shoot myself.

Quote: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.
I know you're not. We're on the same page.

Quote:In C++ or Java ... code snipped ... 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.
Wink prepare to change, my friend:
Code:
'' note: op_new_???(...) and op_delete(...) are functions from my MACRO library ...

if not( iConnectorStream = null ) then
scope
    dim as StatementGenerator ptr myGenerator = op_new_StatementGenerator( blah, 1 )
    ...
    '' Here you can use myGenerator
    ...
    op_delete( myGenerator )
end scope
end if

'' Here myGenerator is not declared

http://www.freebasic.net/wiki/wikka.php?...KeyPgScope
stylin:
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 stylin - 01-10-2006, 07:05 PM
Here's another....file I/O difficulties. - by DrV - 01-16-2006, 03:08 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)