Tag Info

New answers tagged


Replace the case with two if statements, and you can avoid the duplication without requiring the internal methods. if (e.Action == NotifyCollectionChangedAction.Remove || e.action == NotifyCollectionChangedAction.Replace) { if(e.OldItems != null) { foreach(string item in e.OldItems) { // Do something } } ...


Ideally, you would override the decode method for each packet type. But the decode method isn't part of the specific subclass. That is why the switch, or a map that returns the packet-specific factory is justified. It smells because you have to repeat the same code over and over and the method has dependencies on all 40 subclasses. But if the code is ...


What you have described, in one way or another, is exactly how anyone would do it and I don't see any problem with this method. On a side note: you don't have to use lambda functions in your map/array. A simple interface bound method would be cleaner.

Top 50 recent answers are included