Skip to content

Developer guidelines

Rogiel edited this page Sep 16, 2011 · 2 revisions

Never use singleton

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.

Document everything

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 is a service

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.

Correctly start and stop services

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.

Use the correct formatting

We use Eclipse Formatting Standards. Respect them!

Don't abbreviate: use complete names

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.

Don't pick a shortcut. Do the full job or don't do it at all

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.

If you don't know how to do, ask for help

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.

The server core is retail-only

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.

Clone this wiki locally