Omnissiah
✅ object composition: a database perspective
composition vs inheritance is abundantly discussed, but there are issues when it gets to store composited objects
i can't really seem to find many discussions about this, so maybe this is an unsolved problem (even considering implementation depends on the requisites) or i am trying to do the wrong thing (eventually not too unsurprising)
there are discussions about what structure to use for writing trees in databases, but this is kinda a specialized one: it's not really deep, but it can be pretty wide, there can be 5, 10, 20 fields for a single object
and some of them, even the most of them, could be collections
so writing every field as a table means a join for everyone, and having a query with 20 joins for an object will never happen
there are other options, for example some of those could be owned objects, but this may bring the table to have hundreds of columns, and still would not solve the collections situation
one could even think of writing both MainObject and contained data in the same table, or use a table for each, two tables could be better than 20 tables, but then maybe the models can get pretty different between db and business logic, and you always have to translate structure back and forth...
i don't know, maybe i'm too worried, maybe there are better dbs than relational ones for this (but tbh a graph db doesn't seem appropriate either) , maybe hard crafting the domains and the queries for a specific case is the only way, but still this would need to have a decent performance and a decent understandabilty, and something is off
you could have a (denormalized) field in MainObject to tell which composition has stuff, maybe it could help in sparse matrix cases, but maybe not really; atm using a single table intuitively would seem to work best, because again the issue are the joins
16 replies
✅ Reengineering repository layer
I'm trying to bring a code base that was left to me to a more modern architecture.
I'm at the point where I need to deal with the repositories because they are becoming a problem.
Creating new classes for manipulating data and re-reouting the flow of the code in the current architecture shouldn't be that much of a problem, but I have some difficulties in understading how to organize code for some common operations.
What I mean is: currently models have some common logic, let's take auditing for example. When a model is created or updated I need to set who did it and when. Stuff like:
I would set these fields once per operation (or say unit of work), seems the reasonable thing to do, but what would be a way to do it?
The only thing I could think of is having a class with specifically an isolated method for this that I call manually every time I touch a model that is audited.
Maybe I could get all the tracked models in the current context from ef and if any inherits from
AuditedEntity
I update its fields, but that's a little ugly. The other stuff I could come up with would be even uglier.
Am I looking at this the wrong way? The solutions I found searching around are either too old or for bigger projects (this is in the 100_000s of lines) and it would be probably too much to maintain,6 replies
✅ how do logging settings work
i'm trying to change logging settings for another issue, but they doesn't seem to be intuitive or really not even to work like the docs say
shouldn't this filter almost everything?
instead i see even debug logs
there are no other settings (like other appsettings or environment variables)
it would be really nice if for once i didn't have to look at the source code to understand how it works
9 replies
✅ powershell post MultipartContent weird behavior
simply put, i'm making a request and content is serialized with type name instead of real content
with wireshark i see in the request this is sending that content is serialized as
System.Net.Http.StringContent System.Net.Http.StringContent
and i've got no clue on how to solve this
maybe remove everything and just send the body as string
powershell is 5.1
on my machine it works™️, on the one i need to execute the script it doesn't
edit apparently it doesn't work on my machine either? im pretty sure it used to work11 replies