r/csharp • u/Banane9 • Dec 01 '13
Kiwana - A C# IRC Bot
Hi there, fellow C# fans. Please take a look at the IRC Bot I'm working on. I'd like to have some constructive criticism on the code and/or suggestions what to add.
Here's the repository: http://github.com/Banane9/Kiwana
I will update it on github and answer to the people suggesting changes here to take a look at them.
17
Upvotes
4
u/[deleted] Dec 01 '13
I only had a cursory glance, but I'd say two things:
One: Maybe you should encapsulate a few more things as objects rather than strings - i.e. a 'user' object and such. But that's up to you.
Two: Users = users != null ? users : new List<string>(); can be Users = users ?? new List<string>();
2
u/GeorgeHahn Dec 01 '13
Mind if I spend some time tidying with you? I've been trying to do a weekly-bimonthly PR to a random FOSS C# project and this looks pretty appealing.
2
u/Uncled1023 Dec 01 '13
Looking at it you have a good start. Pretty similar to what I am also doing. One thing I can point out is that to make sure you account for all issues with the server. Server timeout, *.net split, Nick taken, Nick needs identifying, possible ghosting of used nick, nick registration, differences between server messages from server to server.
Also, i would move your hard-coded commands within the main project to a plugin, since that is where all the other commands are located.
I don't want to distract from your thread, so msg me if you want to take a look at what i've done for some ideas.
8
u/Seikho_M Dec 01 '13
Consider refactoring your methods and taking a more object-orientated approach.
By refactoring, I mean shrink them. Make them more descriptive and easier to read and maintain. For example, in your 'Kiwana' project, the ParseLine() function is enormous. It could be reduced to 4 or 5 lines of code.
The goal is your code is readable by anyone. Your comments should never describe what you are doing, only why you are doing something. If you need a comment to describe what, you need to amend your code.
There is plenty of opportunity in your project to implement common design patterns (http://www.dofactory.com/Patterns/Patterns.aspx) and simple classes.
Overall, you seem to have the functionality down. It just needs tidying, which is a skill that comes with a lot of time and patience. You'll appreciate coming back to your code 5 years later and being able to read it without scratching your head.
1
u/rockyearth Dec 01 '13
Useless includes.
Many magic numbers , not easy to see what the code does.