I'am the only one in my team who advocates for adding a little implicitness in favor of codebase reduction and decreasing repetition. Yet I don't want to be a biased 'Bad apple' playing against working design which was created prior my arrival at this job. Attempts to change the approach can be taken too personal by some teammates and just saying 'mine is better than yours' promisses the opposite result.
Trials to find cons of the proposed and pros of existing solution are the best way to fight against biases - so called 'devil's advocate' game. Unfortunately, it's quite diffcult sometimes.
The broad question sounds like this:
Are there any clear (measurable?) guidelines (besides "it depends") for setting the degree of explicitness/inderection.
The narrow question is quite local, nonetheless I dare to ask for the list of pros and cons of both approaches.
Our server application has several layers: Service, Business Logic, DAL.
For any data modification (create+update, no deletes) we also save authenticated user stamp thus havig the history who did what.
Current implementation gets user name from framework MVC/WCF and passes it across the layers as an additional argument to the methods just to pass the value to the next layer until it reaches the session object which manages the transaction. (DAL)
I offer to use AmbientContext approach: Userstamp is set once at the very beginning of the request processing pipeline and then implicitly flows with execution workflow (respecting async) and is accessible by any layer if required. Very similar to Thread.CurrentPrincipal
.
username
parameter should be encapsulated in one of the other parameters, so you don't have to deal with it visually all the time.