Believe it or not, context is king
I honestly don’t know about anyone else's feeds lately, but mine are chuck full of “Don’t do this, do that!” or “ You are doing X wrong ! Stop it !!!” and after going through some of them, I realised something, that from the simplistic view usually presented in those kind of articles, this makes sense, a lot of sense, but unfortunately life is a bit more messy than that.
In order to make a point, let’s pick something totally random, the usage of repositories…. okay not random but now that you mentioned it, let’s roll with it…
What is the deal with repositories ? Should you use them ? Should you not ?
I mean, are you using Entity Framework or (n)Hibernate ? Really ? You want to put a repository over a repository (actually active records, but takes from the drama…) ? What is wrong with you !?! What ? Infrastructure project ? the 2000 have called, they want they're project structure back ! It’s all about feature “freaking” folders now! Also, who uses OOP anymore ? Pfff …🥺
This sounds familiar ? No ? Than I should be a bit more careful about who I follow nowadays, but nonetheless, I digress, back to the serious part.
Nobody knows actually better than you do. I can talk 30 mins straight for each side of the argument without giving you anything to work with, and at the end you will end up being more confused that being closer to a decision. Hack, I think this could even be a series on it’s own … oh wait … there are a lot of them … So what should you do then ?
Well, this article is not about repositories, or if you should use them or not, …. no, I will not say anything about that, but what I will say, is something about what you should consider when you are in the midsts making architectural decisions, or better yet decision on things that very hard or costly, if not impossible to reverse ( see what I did here ? 🤓).
So, what should you look into ?
Well, context, that is what ! I know, I know … the title kinda spoiled the surprise… But in the end, what is this context anyway ? Bounded or other wise …
So, when in doubt, let’s ask google:
the circumstances that form the setting for an event, statement, or idea, and in terms of which it can be fully understood.
“the proposals need to be considered in the context of new European directives”
So… this basically means everything, not really helpful … is it ?
Well, maybe than we could use a more simple alternative to context, one that is a bit more “in the moment”. Let us use … Circumstance.
Really now ? Swap it for a sinonim ?
Well… yeah… I do not want to transform this in a wall of text, and also not rant for hours. So, the main takeaway from this is that all patterns and designs, even a lot of frameworks and tools, should always be considered from a current circumstance, and not from a “historical” perspective, like “I used this in my last project and it worked!”, because, first, this is a new project ( with most likely different requirements ), maybe a new team composition, maybe a slightly different domain.
So, to cut this short, before taking any more (technical) dept, take a moment and think about the circumstances, the context, the team, and only then, pick and choose what makes sense for the specific scenario. There are no cookie cutter solutions!
Best!