Software Architecture Design Patterns exercise

Hello engineers :slight_smile:

I have a student project, an application to track user expenses. You can create many users, each user can create a group, add necessary users to the group and then for each group create any number of expenses. There are some other functions available and the application is ready and working.

The task is to apply two design patterns to this application and I have no idea what patterns I can implement in this case (except the obvious Singleton pattern to create only one instance of database communication class).

If you have any experience or fresh knowledge of Design Patterns it would be a huge help if you can point me in the right direction.

I would read through these, but make sure you pay special attention to when and where to use them. Always keep in mind that every decision in programming is a tradeoff.

I would favor using dependency injection for the database connection over a singleton. singletons come with the trade-off of introducing global state, and are considered by many to be an anti-pattern. At their very best I’d describe them as a foot-gun

https://www.michaelsafyan.com/tech/design/patterns/singleton

I’ll over state my case:

Never use a singleton in python

because Python already has modules, which do everything a hand-rolled singleton does, for free. If you need singleton state, just use fields in the module.