Do extension methods violate software development principles?

I tend to shy away from extension methods (in C #) as this violates the principle of software coherence.

Then why is he there? or is my understanding wrong?

+3
source share
3 answers

On the contrary, I believe that the wise use of extension methods improves code cohesion, since you can share methods and classes that perform related tasks. The situation is no different from the free (static) methods and searching for Koenig in C ++, accessing the extension with help .is just syntactic sugar.

+11
source

. , , . , , .

, , - , . , , .

+8

, , . - . # VB.Net .

People create static utility methods for classes that they have not controlled for quite some time, and they fit into well-established engineering practices.

+1
source

Source: https://habr.com/ru/post/1707028/


All Articles