Recently joined a new job. And one developer write this code… Cannot give the full source code because of confidentiality but can show 1 method. Based on it you can imagine there are hundreds of similarly composed classes and thousands similar methods.
More details about the project: it is .NET Framework 4.7 C#. Uses EF 6, and DI also set up, but in some project Ninject in others a custom written version (in 2020!!!!) with minimal feature set. Despite of any DI used all injected objects are
Helper, etc. OR even all combined together!!!! And the reason is to “hide” data layer instantiation and “control” instance creations…. In my understanding this is what DI does for you! EF 6 also implement “unit of work” with a default transaction on each
SaveChangesAsync() so no need any extra hassle to make it transactional and instantiate many context per request, etc…
And finally here is a “simple” method.
var ds should be and EF 6 instance but as you can see the code is so huge “trash” it is breaking Visual Studio since in a strongly typed language VS cannot decide what is type of an object…
Please post your honest opinion here. It might help my case to stop this madness.. Thanks.