QuickShop-Reremake icon indicating copy to clipboard operation
QuickShop-Reremake copied to clipboard

Refactoring

Open yannicklamprecht opened this issue 7 years ago • 26 comments

Needs heavily refactoring

  • be SOLID

    • [ ] Single Responsibility Principle
    • [x] Open Closed Principle
    • [x] Liskov Substitution Principle
    • [x] Interface Segregation Principle
    • [ ] Dependency Inversion Principle
  • [ ] remove cyclic dependencies ( MsgUtil is depending on Util and the other way around, same for DatabaseHelper)

  • [x] properly inject dependencies instead of static abuse shit

  • [ ] properly handle configurations

  • [x] write Adapter for used functionality in libraries

  • [x] use PreparedStatement in the right way

  • [x] cache data instead of writing each time -> persist every N minutes

  • [x] encapsulate the classes to reduce complexity

  • [x] cleanup commands, introduce a subcommand system

  • [x] use Player#hasPermission instead of using an explicit PermissionProvider that is already injected into Bukkit system

  • [x] remove duplication of ServerNMS and ItemNMS

  • [x] refactor MsgUtil

    • reduce code duplication
    • apply SRP
  • [x] write javadoc for plugin

  • [x] Remove classes that are not used anymore

  • [x] refactor shop loader

yannicklamprecht avatar Nov 26 '18 15:11 yannicklamprecht

use Player#hasPermission instead of using an explicit PermissionProvider that is already injected into Bukkit system Actually this is from upstream https://github.com/KaiKikuchi/QuickShop's code. New code part already use hasPermission,

Ghost-chu avatar Nov 26 '18 15:11 Ghost-chu

Then it can be removed.

yannicklamprecht avatar Nov 26 '18 15:11 yannicklamprecht

com.comphenix.packetwrapper maybe will use again in next version, so temporarily not deleted

Ghost-chu avatar Nov 26 '18 15:11 Ghost-chu

cache data instead of writing each time -> persist every N minutes what cache data?

Ghost-chu avatar Nov 26 '18 16:11 Ghost-chu

use PreparedStatement in the right way Actually, i not be good at for SQL...

Ghost-chu avatar Nov 26 '18 16:11 Ghost-chu

properly handle configurations Yes, you are right

Ghost-chu avatar Nov 26 '18 16:11 Ghost-chu

I think i need sleep and find another time to continue refactoring.
00:03 BJT now.

Ghost-chu avatar Nov 26 '18 16:11 Ghost-chu

cache data instead of writing each time -> persist every N minutes what cache data?

Here we need to evaluate how frequently the database is accessed and if it is necessary to cache certain data changes to reduce load.

Good night.

yannicklamprecht avatar Nov 26 '18 16:11 yannicklamprecht

Complete Remove classes that are not used anymore

Ghost-chu avatar Dec 04 '18 07:12 Ghost-chu

What do you think of that config format?

!!org.maxgamer.quickshop.language.Language
command:
  descriptionDebug: '&ePrint debug infomation'
  noTargetGiven: '&cUsage: /qs export mysql|sqlite'
controlpanel:
  empty:
    hover: '&eLooking you want changing shop and click to clear.'
    normal: '&aEmpty: Remove shop all items &e[&d&lOK&e]'
  information: '&aShop Control Panel:'
  modeBuying:
    hover: '&eLooking you want changing shop and click to switch enabled or disabled.'
    normal: '&aShop mode: &bBuying &e[&d&lSwitch&e]'
  modeSelling:
    hover: '&eLooking you want changing shop and click to switch enabled or disabled.'
    normal: '&aShop mode: &bSelling &e[&d&lSwitch&e]'
  price:
    hover: '&eLooking you want changing shop and click to set new price.'
    normal: '&aPrice: &b{0} &e[&d&lSet&e]'
  refill:
    hover: '&eLooking you want changing shop and click to refill.'
    normal: '&aRefill: Refill the shop items &e[&d&lOK&e]'
  remove:
    hover: '&eClick to remove this shop.'
    normal: '&c&l[Remove Shop]'
  setOwner:
    hover: '&eLooking you want changing shop and click to switch owner.'
    normal: '&aOwner: &b{0} &e[&d&lChange&e]'
  sign:
    owner:
      line1: ''
      line2: Enter
      line3: new owner name
      line4: at first line
    price:
      line1: ''
      line2: Enter
      line3: new shop price
      line4: at first line
    refill:
      line1: ''
      line2: Enter amount
      line3: you want fill
      line4: at first line
  unlimited:
    hover: '&eLooking you want changing shop and click to switch enabled or disabled.'
    normal: '&aUnlimited: {0} &e[&d&lSwitch&e]'
language:
  contributors: [
    ]
  country: England
  version: 1
languageVersion: 2
shopDoesNotExist: '&cThere had no shop.'
sign:
  owner:
    line1: ''
    line2: Enter
    line3: new owner name
    line4: at first line
  price:
    line1: ''
    line2: Enter
    line3: new shop price
    line4: at first line
  refill:
    line1: ''
    line2: Enter amount
    line3: you want fill
    line4: at first line
signsUlimited: Unlimited

See Structure: https://github.com/Craftstuebchen/QuickShop-Reremake/tree/remaster/src/main/java/org/maxgamer/quickshop/language

See test case for loading: https://github.com/Craftstuebchen/QuickShop-Reremake/blob/remaster/src/test/java/org/maxgamer/quickshop/language/LanguageProviderTest.java

yannicklamprecht avatar Dec 05 '18 20:12 yannicklamprecht

404 Not Found

Ghost-chu avatar Dec 06 '18 04:12 Ghost-chu

404 Not Found

I know did some restructuring after that and forgot to link to a specific revision. https://github.com/Craftstuebchen/QuickShop-Reremake/tree/be3b4efb3cd6f359731de95f611a97003e953df1/src/main/java/org/maxgamer/quickshop/configuration

https://github.com/Craftstuebchen/QuickShop-Reremake/tree/be3b4efb3cd6f359731de95f611a97003e953df1/src/test

yannicklamprecht avatar Dec 06 '18 05:12 yannicklamprecht

Add a YamlProvider not a good idea in this project. Developer should keep the plugin source is simple and easy to modfiled because this is a Bukkit plugin. If add provider for all configuration, that's will make code mess and waste time.

But you are right, i need improve configuration files.

Ghost-chu avatar Dec 06 '18 06:12 Ghost-chu

In my opinion the objectification of the configuration is a need.

yannicklamprecht avatar Dec 09 '18 16:12 yannicklamprecht

This is a how make code clear, simple, and make the configuration file friendly and human-readable question

Ghost-chu avatar Dec 09 '18 17:12 Ghost-chu

So i will create a branch to work(Do a breaking changs on master 100% not a great idea) and try that.

Maybe i can explode the config.yml to mutil files.

Ghost-chu avatar Dec 09 '18 17:12 Ghost-chu

The Advantage of my system is, that outdated config values are automatically removed, when the model classes doesn't have the value anymore. New attributes are automatically updated if version number is increased in in main model class.

yannicklamprecht avatar Dec 09 '18 20:12 yannicklamprecht

I think you should forget everything. The code of this project should be thrown away. Keep the feature description and code it from scratch.

yannicklamprecht avatar Dec 24 '18 12:12 yannicklamprecht

Issue reopened. I'm cleaning codes and hope it keep the stable.

-> working for adapter configurations

Use reflect to read config to field and write to config from field

Ghost-chu avatar May 27 '19 14:05 Ghost-chu

refactored shop loader

Ghost-chu avatar May 30 '19 13:05 Ghost-chu

Finished use PreparedStatement in the right way and cache data instead of writing each time -> persist every N minutes

Ghost-chu avatar May 30 '19 14:05 Ghost-chu

Finished cleanup commands, introduce a subcommand system in 2.2.0

Ghost-chu avatar Jul 02 '19 12:07 Ghost-chu

This issue can be closed because we're under full rewriting.

Ghost-chu avatar Feb 11 '20 05:02 Ghost-chu

Reopen issue cause v3 under refactoring

Ghost-chu avatar Apr 06 '20 07:04 Ghost-chu

Cleanup the static abuse everywhere. Only use it when really need.

Ghost-chu avatar Apr 16 '20 14:04 Ghost-chu

Refactored MsgUtil class, but still have lots of works need to do.

Ghost-chu avatar Oct 02 '21 07:10 Ghost-chu