dkabot/DkabotShop — pull request #9 by jmhertlein (2013-08-06 06:03:32+00:00)
Title: Moderate Cleanup Effort

My server was initially going to use DkabotShop to replace VirtualShop, so I forked the project and started cleaning things up so that I would at least be able to maintain the fork for as long as we were relying on it. However, our server owner decided to do something a little different with our server economy and DkabotShop regrettably no longer fits the bill.

I figured I'd still contribute this back, if you want it.

To summarize changes, I focused on three things:
* Converted it to a Maven project, because Maven is awesome and makes dependencies easier to track
* Encapsulation and other proper OOP things
* DRY (Don't Repeat Yourself)

Encapsulation was what caused most of the code changes, as there were a lot of default-visibility methods in DkabotShop.java that I made static and public, and moved to their own utility class. DkabotShop was also turned into a singleton class (alas, a necessary evil).

With regards to the DRY principle, I moved a lot of onEnable into its own functions to improve readability (code becomes more self-documenting) and to just split things up for organizational purposes.

The main thing I *didn't* do is refactor the command-related classes (beyond renaming them and moving them to their own package). The first thing I would do for them is try to split them up into a series of smaller functions, rather than just big if-statement blocks for each command. Try to pick out code that different commands have in common (and is currently copy-pasted between them) and 'suck' the code out into its own method, and just reuse that method when you need to reuse functionality. "Write one implementation, test one implementation, then use it anywhere."

I realize these are some large changes, but they don't/shouldn't break functionality and I believe I did clean up the codebase a bit. I just felt like I should open a pull request rather than just delete my fork, so at least the effort might not go to waste.

Cheers.