Hot answers tagged

4

This is going to be a frame challenge answer. It is possible to design base class in a way that I have to pass connection string only once and not for each of the 4 concrete classes? You shouldn't try to achieve what you want to with a base class. Why not? Basically, if you use a base class for this, it might work fine now. Over time, your code will ...


3

SRP is a principle, not a Law. You follow it because generally it leads to better code. Code that breaks it, is not by definition bad. In fact there is a lot of code out there that is arguably good, that does not follow this principle. To put this into context: it is a Law that code must compile. Code that does not compile is by definition very bad code. ...


2

Avoid adding generic type constraints where possible since these have to be repeated in every generic function that references your type even if the constraint is not relevant to the operation e.g. public IEnumerable<T> Leaves<T>(BST<T> tree) where T : IComparable<T> { ... } Using IComparer<T> also allows different comparison ...


1

It all depends on how far you are willing to go, without breaking YAGNI principle. Personally, I do not really like having the logic of GetStatistics method in this class and strictly speaking, I think it does break SRP. I would rather have a separate class that reads the data, interprets it, and stores it in the Statistics class, and then inject it into ...


Only top voted, non community-wiki answers of a minimum length are eligible