Skip to main content

All Questions

Tagged with
1 vote
1 answer
314 views

Where to create repository instances?

I've several repositories. To make them testable, I add the ORM session in the constructor. class Repository: def __init__(session): self.session = session def save(object): self.session()...
4 votes
2 answers
459 views

Data processing pipeline design for processing data

I have a use case for which I need to build a data processing pipeline Customer contact leads data coming from different data sources like csv, data base, api has to be first mapped to a universal ...
1 vote
3 answers
988 views

Storing multiple instances on a Singleton?

RefactoringGuru's example Singleton in Python has an _instances dictionary field class Singleton(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls....
2 votes
1 answer
131 views

A Design Pattern for a component which both writes to and reads from an ordered event log

I am searching for a good design for a set of components I am writing for a system. I believe it is very likely there is a Design Pattern, or set of Design Patterns, which could be combined to solve ...
-2 votes
2 answers
1k views

Best practice: keep DB models in one file or split into modules?

I've a Python project with ~30 SQLAlchemy models and I'm not sure where they belong. All models belong to the DB but also to a module, so I'm not sure about the right namespace. Here are some ideas: ...
1 vote
2 answers
107 views

Dynamic web application hitting database on front page load to fetch profile image

Folks, I am in middle of writing a web application (Python/Flask) where home page has user profile image in the navbar which is coming from a database (blob), I am wondering if this is a good practice....
2 votes
2 answers
562 views

Is this architecture overkill? What is a good way to architect this software?

I have an algorithm I am trying to implement that has steps 1 to 5. There are several different ways I could implement each step. Each calculation step is essentially just an astronomy calculation, ...
2 votes
1 answer
247 views

How do I structure my functions (and classes?) which interact with my Database/ORM?

So I am working on my first project using SQLite and SQLModel as ORM. Creating and handling the first table in my database was easily structured: A function for each CRUD-Operation. But now I have ...
2 votes
1 answer
261 views

Design patterns for long chains of computations in python (functions vs classes?)

A recurring pattern which I see in my code is chaining together a lot of functions. This is the result of a large number of processing steps needed for a given task. This could be e.g. a data ...
-1 votes
1 answer
218 views

How can I use builders for products with incompatible interfaces?

I am working on a program to automatically design heater units based on varying client specifications. The process for creating each heater is quite involved and requires multiple optional steps ...
5 votes
1 answer
12k views

Using singletons in Python (Django)

I was suggested to define a singleton in Python in the following way: class Controller: pass # ... controller = Controller() However, this way, controller cannot be replaced with a derived ...
0 votes
1 answer
239 views

How do we nest decorators?

It is possible to nest many decorators. @decorator_one @decorator_two @decorator_three @decorator_four def some_silly_function(): pass How do we write a decorator class so that the order in which ...
0 votes
1 answer
474 views

Multiple models/controllers python app

I am trying to tinker with the MVC pattern and I have a problem when trying to design the MVC structure. I need a model for products, however as I need to manage more and different data, I can help ...
0 votes
0 answers
133 views

Python Typechecking versus TypedDicts?

From what I understand from this answer, it is not possible to use a typeddict and typechecking in a function. So for example, if one has a function: def some_func(some_int: int, some_dict:...
1 vote
1 answer
463 views

What is an apporpriate design pattern when dealing with Pandas and databases?

We're dealing with a lot of "data analysis", basically different sorts of data mangling, aggregations and calculations using Pandas. Usually, the data is time series data. All underlying ...

15 30 50 per page
1
2 3 4 5
9