Zàf Mohammed
Zàf Mohammed

Reputation: 117

Useful design patterns for creating a neat Python Web App

We decided to refactor our code as almost every new feature was implemented as a form of a hack. Would to get some tips on what design patterns would be useful to have in a web app. Things like Factory or Facade don't suit, I feel those are more suited for libraries and not a web app.

The gist of the web app is that it is a sort of translator that understands a user's queries and creates large queries to our DBs. It's a sort of search service. We have a ton of features and configuration that keep stepping on each other's functionalities and we have to add ugly hacks to overcome them. Hoping to have a good base that lets creating long complex chain of rules easier to modify.

Upvotes: 0

Views: 190

Answers (1)

Marked as Duplicate
Marked as Duplicate

Reputation: 1249

It's not easy to give practical & concrete advice in cases where all you have is a general overview of the project's functionality. But you may start gradually rewriting clusters of deeply intertwined classes with SOLID principles. Don't be too ambitious and attempt to refactor your entire codebase at once without a solid plan and timeframe.

I'd especially emphasize the one/single-responsibility principle, which seems to be the largest cause of trouble. There have been entire books written on refactoring. You may also check the C2 Wiki to find tips that might be applicable to you. There is no design pattern that'll act as a magical cure. Reduce complexity by simplifying the web of connections between your 'modules': crossroads, especially non-explicit ones, are bad.

Upvotes: 1

Related Questions