• Welcome to Valhalla Legends Archive.
 

Newb Mac Programmer (soon to be)

Started by Lime-Marine, March 16, 2003, 05:05 PM

Previous topic - Next topic

Lime-Marine

ok guys, As SOME of you may know i am starting LimeBot (mac binary bot) to rival kane. I learning c++ and all and i'm wondering, the structure of a bot consists of A. Main.cpp being main commands B. Commands.cpp (commands). and C. Login.cpp (login to b.net) and a few more. Is this correct?

Camel

#1
there is no single correct way to set up your bot
imho, the more split up code is, the easier it is to deal with, given that it's organized well. however, it would be entirely possible to create a bot with a single main.cpp

Zakath

#2
The new version of ZakBot that I'm working on has 3 source files: ZakBot.cpp, BinaryBot.cpp, and ZakBot.res. The original version had 6 or so, as I recall (I'm too lazy to check right now).

Sky's BinaryChat has over 100 different source files.

Division of code among source files is just an organizational choice. Normally you split different functional themes among different files, but you could divide things up however you like. BinaryBot.cpp, for example, is the implementation file for a framework class - it is completely standalone, is not intended to be modified, and thus is some 1000 or so lines long.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Kp

#3
Though it is an organizational choice where you put what functions, I'd like to point out that usually when you compile a file, everything in that file is compiled for the resulting object.  A bigger file will take longer to compile.  Therefore, there is some value in having source files split out so that you don't needlessly recompile functions that haven't changed in months, just because they're in the same file as the new function you're writing and debugging.  The counterpoint is that fewer object files reduces the chance of using an outdated struct definition and confusing the program; however, most decent compiler suites will identify such dependencies for you.  Confused yet? ;)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Camel

#4
imho, you should *always* use .h files for all your declarations, even if you only have one .cpp file, because i find it helps in getting all of the important declarations "up at the top."