2
pda87
7y

We have this C# class which is like the core of our entire business logic. If you are in another class and it doesn't contain an argument in the constructor and/or property of that core class you're gonna have a bad time.
That core class has lots of useful business logic bools, "IsSomething", "HasSomething" etc. However that core class has a parameterless constructor which is sprinkled dangerously throughout our app, meaning the object is often not initialised properly and it's a 2 day mindfuck to make sure your "IsSomething" bool is actually false and not just false because the other business logic that bool relies on wasn't initialised and the bool has never had a chance to be true.
It's difficult to trust even a simple "if' statement. And if you're somewhere were you've had a list of that core class passed in, you need to trace how the list was initialised to make sure all your bools have been set 😴

Comments
  • 0
    @oneinazillion13
    No, no inheritance.
    So like:

    public class MyOtherClass
    {
    public MainClass { get; set; }

    public MyOtherClass(MainClass mc)
    {
    this.MainClass = mc;
    }
    }
  • 0
    @zickig I guess, idk maybe it's too complex to put down in a rant without massive code examples.
  • 1
    @zickig Why is that a weird architecture? 🤔 I don‘t know C# but that looks like normal dependency injection through a constructor which is considered a good practice in other languages.
  • 0
    @zickig Cheers but I'm not looking for help with it, I was just ranting about it 😉
Add Comment