- 
                Notifications
    You must be signed in to change notification settings 
- Fork 18
Developer guidelines
Ok, singletons are easy, but so are unmodular. With singleton you cannot change implementations neither have two or more interchangeable implementations. Since we don't use singleton, we use something that can emulate it. That's Google Guice (http://code.google.com/p/google-guice/): with it, we can inject all the dependencies during service construction and let the framework deal with circular dependencies and any other issue.
Don't forget to javadoc classes! Even if it is something trivial, it's important to have the whole code documented. Something that looks obvious to you, might not look to others. Obviously, you should always use english. And besides an fully documented code looks awesome!
Everything in the server is a service: network, logging, VFS, templates, character control, NPC control, AI, etc. Don't ever implement business outside a service! Packets are not supposed to do anything but interpret data.
If those methods are not correctly implemented the modularity will be nullified and become impossible to restore the server without restarting the whole JVM. Don't forget to be careful with garbage.
We use Eclipse Formatting Standards. Respect them!
If you use an abbreviation today, you will know what you meant with that. But there is no guarantee that you and anyone else will understand what was that supposed to mean.
You could do the job by a shorter way, but forgetting javadocs, extensibility and usability. But then, when any change is required it will be required to redo everything you have done AND implement the new functionality. The bottom line is: do it right, take your time.
Nobody knows everything, you might be best one at one thing, but might not do anything right in another. That's normal. If you are not sure if what you are doing is a good idea, don't continue your work; stop and ask someone. If you need someone to review your code, push it into a new branch.
If you want to implement any mod, you should do it using a plugin. If you include your code in the core, everybody, even the ones who don't want it, will need to have the code loaded and consuming resources. Besides that, code complexity will increase and will become even harder to maintain the code.