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:
Controllers: Where requests come in and responses go out.
Services: Where we implement business logic to turn raw data into relevant data structures.
Repositories: Where data is extracted from data sources and mapped into consistent interfaces known as Data Transfer Objects (DTOs).
Why is this important:
Makes the code easier to read and follow.
Better structure makes things easier to find and clear where new implementations fit in.
Makes data sources easily swappable. With only the repositories accessing the data source the only thing that needs to change when switching data sources are the repositories and nothing else.
Follows the separation of concerns principle in SOLID software development.
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.
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:
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 inbot.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.