[Question] Managing a large plugin with 73+ classes and 15k+ lines of code (and growing)

Discussion in 'Spigot Plugin Development' started by unenergizer, Jun 8, 2015.

  1. Hi everyone,

    I am posting because I have a question about project setup and project management. I have been writing a RPG plugin from scratch and it is starting to get very large and fast. I have some questions and they are mostly to do with keeping everything organized and making sure the program is efficient and easy to read and understand.

    The pattern I chose to write the plugin is the singleton pattern. It seems to be working just fine for what I need it to do. However, I am wondering if the program will suffer from and performance issues by using this pattern. Does anyone have any experience with this?

    Also I have placed each event listeners into a class of it's own. The picture in the link below shows this:

    https://www.dropbox.com/s/2gshkncz6ks9s1j/Screenshot 2015-06-07 21.25.28.png?dl=0

    So this means that every time I need to use one of these events, I expand on the 1 event listener and insert my code into the already existing flow of code. I am starting to think this might be a bad idea. I know what each listener is doing. However I think it might be hard for someone to come behind me and see everything that is being done. Should I separate the event listeners into multiple files and place those class's into packages containing relevant code? Is it better and efficient to have multiple class's subscribed to the same event's? I think it would make the program more readable and easier to follow. However I don't know if it will effect performance and cause problems down the road as more and more class's subscribe to certain events.

    I want to do my absolute best to make sure that the code I am writing in this project is easy to understand and follow, efficient, and well written. It is very important to me that this runs the best it can, and is easy for me to update down the road. If I go several months without working on the project (because it's stable) and I am focusing on other projects, I want to be able to come back and see and understand what is going on.

    Thank you for reading this, and thank you for the help!

    -unenergizer

    EDIT:
    Changed title to reflect the actual number of class's in the plugin.
     
    #1 unenergizer, Jun 8, 2015
    Last edited: Jun 8, 2015
  2. What does the plugin do?
     
  3. You must test it yourself, with /timings or java profilers.

    no one here known how its the code of the plugin, as i can see, is not open source.

    Also it depends more on how its coded the plugin, runnables can increase the CPU Usage
     
  4. I'm also working on an RPG project for a server.

    If you are still planning on expanding the project, you should split it up into projects.

    For example, the combat system in one plugin, all NPC stuff in another, etc. Naturally things are going to depend on each other, so you're going to have a base project.

    If you would like to talk more, you can always PM me.
     
  5. It is a plugin similar to Dungeon Realms and WynnCraft. However it's more of a Diablo style than World of Warcraft.

    I have been doing routine testing for 30 minute periods while me and a group of friends run through the dev server. Though, this only happens when big features are implemented.

    I love Head First books! I learned java from one of them and udemy.com videos a few years ago. I have basic knowledge on several design patterns, but I could always learn more. I'll purchase this, thank you!

    I'm not really wanting to split the project into several smaller plugins. What are the benefits of having it split up? I can not really think of any myself. However having all the code in one big plugin is easier to manage, one click compile, and easier to update. Please correct me if I am wrong. Thanks!
     
    #6 unenergizer, Jun 8, 2015
    Last edited: Jun 8, 2015
  6. The benefits being you can bring other people on and have them work on specific parts.

    Yeah, I know you can use VCS so that multiple people can work, but I'm talking about projects in general.

    Another benefit is this:
    What happens when you have 2 servers (say one is the main world, and other is mini games). You can compile specific jars for each server. Or for example you have a city to trade in only, and the other main world. In the city, you don't want people killing each other so you leave out the jar for PVP.
    - the benefit = performance
     
    • Like Like x 1
  7. Another similar solution would be to create a module system in your base plugin, then you can load/unload modules as you like.
     
    • Agree Agree x 1