ClamSageCaleb / UNCC-SIX-MANS

The official 6 mans bot for the UNC Charlotte Rocket League Community
https://clamsagecaleb.github.io/UNCC-SIX-MANS/
MIT License
2 stars 0 forks source link

Code cleanup and refactoring #31

Closed mattwells19 closed 3 years ago

mattwells19 commented 3 years ago

It's time to clean up some of the tech debt I made while working on Norm.

The project needs to be rearchitected to follow a common design pattern used in the software development world. There will be three areas to take note of:

  1. Controllers: Where requests come in and responses go out.
  2. Services: Where we implement business logic to turn raw data into relevant data structures.
  3. Repositories: Where data is extracted from data sources and mapped into consistent interfaces known as Data Transfer Objects (DTOs).

Why is this important:

No new logic is expected to be added, only repositioning of functions and changes to the file structure.

Another thing to consider refactoring is how we handle errors. Right now we just return ErrorEmbeds whenever there's an error. To clean this up, it would be a lot nicer if we could throw some type of custom error object with a title and description and then handle the error back in bot.py. This should cut down on nearly all of the ErrorEmbeds and it makes it a lot easier to do input checking.

Consider using __init__.py files for initializing objects and simplifying imports.

mattwells19 commented 3 years ago

This item is no longer relevant as the ideas mentioned here will be implemented as part of the NormJS transition.