Posted: Fri Aug 19, 2005 8:21 pm Post subject: Good Bot-Programming Style
This is like a poll, only not multiple choice, but posting your thoughts on the topic.
Question: How do you define a "good" programming style for writing bots?
The idea behind this is that a group of us (or just one if nobody else really cares) could put together a tutorial complete with the codes, and it would teach how to program a bot while encouraging "good" bot programming styles.
For example, I think that what WiredBots did was great... only problem is they had poor Perl coding in general, but their style of writing bots was what I liked and still use today:
Quote:
• Folder Names
¤ Basic names ("commands", "handlers", "extras/subroutines")
¤ Possibly go more in-depth ("commands/admins", "handlers/msn", etc)
• File Names
¤ Matches name of subroutine and/or command contained
¤ Generally each subroutine has its own file ("getFile.pl => sub getFile")
Well, if you've used the WiredBots code you know what I'm talking about.
Anyway, I think those features were great for writing bots... it keeps everything nice and organized. Like if you want to quickly find your handler for an MSN message, you just go to handlers/msn/ and you can find the subroutine you're looking for by its filename.
So this topic is for posting your ideas or thoughts on what would make a good bot programming style good (i.e. using modules like crazy, including pod data for commands to make your menu's easier to generate, etc.). _________________ Current Site (2008) http://www.cuvou.com/
A good programming style is good whether it's for bots, cgi's or applications. I know you're talking about how to layout and organize bot code, but I think fundamenal concepts work everywhere and you should think about separating the two ideas: good programming style; good bot programming organization.
Now on to your bot ideas: I think WiredBots made some interesting choices in laying out their code, they were thinking in the right direction, but I believe it was way over done. In particular, I think it leaves for a somewhat messy, hard to find things, hard to integrate code. And when you create a new bot, you have to copy all the handlers, extras, commands, etc to the new bot.
My thoughts (the way my bots do it) are to organize code into larger groups. To begin with, the handlers and extras never change, so they are directly integrated into my bot modules. In the same way, admin commands are all the same for my bots, so they are integrated into an Admin Commands module. It makes for much tighter, easier to read and maintain code. In the same way, when I create a new bot, its specific commands are contained in one module, where they naturally should be, imho.
I agree with you completely that it's important to use file names and function names that describe the functionality in them, so if you have individual commands, they should be the same name as the function. But, I don't think each subroutine should have its own file. Again, some code naturally goes together and you want to share functionality across subroutines. While you can do that when everything is in its own file, it's again hard to read, hard to maintain and results in you having to use globals more, etc. Instead, I put my main bot code into "Brain" modules, each brain knows how to do a certain thing, each brain has the same interface so that they are interchangeable. For instance, I can arbitrarily add brains together in a bot to give it improved functionality.
As a way to sum up... I believe in object oriented programming, where code and data are grouped together in logical units or modules. Using these modules together is a very simple task. On the other hand, if you have hundreds of files spread out over dozens of folders, you end up spending most of your time trying to find things, you have 20 files open in your editor instead of one or two and most importantly, you are not organizing your code in ways that make sense.
¤ Generally each subroutine has its own file ("getFile.pl => sub getFile")
Group them, yes, as Mojave says, but not in their own files. That tends to be the reason your templates seem to be so bloated.
I personally tend to group things - commands, modules, etc. The main "coding practices" to focus on are things like using strict, indenting, and not to copy code without credit, even if it just means they put "# Origionally by darkmonkey" or something.
However, nowadays, there's mainly n00bs doing bots, and nothing "advanced" and new is coming out. They are now just template copies - and most of them are in dutch .
This forum is really dying. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Sat Aug 20, 2005 5:40 am Post subject:
darkmonkey wrote:
However, nowadays, there's mainly n00bs doing bots, and nothing "advanced" and new is coming out. They are now just template copies - and most of them are in dutch .
This forum is really dying.
This is quite normal actualy. In the time this forum has been here, and wiredbots before it, there are ups and downs. I've in fact told you in particular this before. The only real thing that will kill a forum like this, is people saying things like that. If you think its dieing, fine, but do something constructive to help, or do nothing at all.
Anyway, i know my development comes in spurts as i either have the time or pay to do so. Now hasn't been one of those times, but next months looking better
In reality i just hate you ragging on "n00bs" as if anyone wasn't just a n00b at some point. If you want to see advanced programming then lets see yours?
Sorry this post took a rather negative turn but it the entire tone of your post irked me. BTW most of the time all of the development happening will be n00bs because there are very few of us who do this as more than just a one off thing.
Guess i'm saying, be nice, you where a n00b, you might still be a n00b, i might be a n00b, and if you don't have anything nice to say, don't say anything at all. My nice thing to say....
Cer...I actualy use some combination between yours and Mojaves view. I like to have my code organized as modules, and stored in folders. Multiple brain modules in a brain folder, filter modules in a filter folder etc. One sub per file gets realy hard to maintain in a hurry. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
Some of us go off on roadtrips to far away places where they don't even have internet access; some of us are out of school, flirting with girls, going to movies, and generally causing trouble; some of us are painting our houses, raising our kids, hosting barbeques.
Most of us realize that forums ebb and flow, that bot development isn't our number one priority, that programmers need breaks and that stepping away for a time helps refocus your thoughts, and that things will pick up again in the next month.
This is neither. Just the "good" coders have in general been replaced by newbs.
Quote:
In reality i just hate you ragging on "n00bs" as if anyone wasn't just a n00b at some point.
I'm not raging them, I'm just saying that that's what the forum mainly consists of.
Quote:
If you want to see advanced programming then lets see yours?
Soon ^_^
Quote:
Most of us realize that forums ebb and flow, that bot development isn't our number one priority, that programmers need breaks and that stepping away for a time helps refocus your thoughts, and that things will pick up again in the next month.
Fair enough, but do you really expect it to ever be as active as it was a year ago, with commands being released and relevent discussion? Currently, and in the future (IMHO), it will just be newbies or people stuck asking "how do you do XX" and then leaving. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Sun Aug 21, 2005 10:31 pm Post subject:
Actualy I do. Just months before that people made the same complaints. Several months before that, the same, etc, over and over. Those of us who pay attention know it happens. Wiredbots.com had the same issues and the same ebb and flow. Anyway dieing or not its still here and survived the doom sayers before you so i'm neither worried nor concerned. Mojave and I both do more coding in the winter, summer is travling, playing, moving, road trips, etc. I also know that oddly enough more bot development happens during school, as if those of us with class can't get out in time to do any real world distraction so we turn to computers for those months.
BTW I beleive Matt here is on the very brink of releasing a Yahoo module wich should at least stir up controversy if not actual development. For myself it will probably be another month or so before i can dedicate real time to development but i have some exciting ideas (well i think they are exciting).
Last note. As you get older you realy do find that time changes. I used to think a week was a long time to wait for something, now even my bot projects are planned in months with 6 or more months from now not realy seeming like that far off. Might not be sage wisdom but it is a reality that crept up on me, when I realized i was content waiting 6+ months for releases of books, software, movies, etc. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
Bots aren't the most basic type of script. If you make a bot, you should either make it and plan on people using it just the way it is, or make it planning on people custimizing the coding to fit their needs. If you make it planning on the coding getting changed, that meens the person would know the coding language. So just give them a little help by indenting, leaving comments at more complicated parts, and by using proper coding. If you're making it for them to just use without modifying, it won't matter how it's coded. Just put a readme file in there telling them where to put the bot's Name and Pasword.
Actualy I do. Just months before that people made the same complaints. Several months before that, the same, etc, over and over. Those of us who pay attention know it happens
I both agree and disagree with that quote from eric, on one side i do agree that this happened near the beginning, just after i joined (wow i was the 25th user [just checked lol]), but on the other hand, i dont see this forum moving very fast at all. I login every few months, and see only like 2 pages of new topics everytime i login. I remember when the forum had like 30/40 people logged in most of the time, now i'm lucky to see 3 online at once.
Heh, i think this has been my longest post ever in this forum, i never was much of a talker.. eh?