I remember learning about Extension methods and thinking that they were amazing, and in practice I find them to do more harm than good. It's the definition of syntactical sugar and gives you the clean appearance that everyone wants, but the problem with it is that it breaks encapsulation. I understand why you used it in this instance, but I think a basic static helper class would be a cleaner implementation. Good Post 👍🏻
A big drawback of a static method is testability. Mocking static method or extension method is hard, so most of the time developers avoid spreading the business logic into static method or extension method and also there is no much difference between static helper method and extension method:
var a = customer.CreateDate.ToACustomFormat();
var b = DateTimeHelper.ToACustomFormat(customer.CreateDate);
I remember learning about Extension methods and thinking that they were amazing, and in practice I find them to do more harm than good. It's the definition of syntactical sugar and gives you the clean appearance that everyone wants, but the problem with it is that it breaks encapsulation. I understand why you used it in this instance, but I think a basic static helper class would be a cleaner implementation. Good Post 👍🏻
A big drawback of a static method is testability. Mocking static method or extension method is hard, so most of the time developers avoid spreading the business logic into static method or extension method and also there is no much difference between static helper method and extension method:
Here is some useful link about extension method:
Extension Methods Guidelines in C# .NET
Extension Methods General Guidelines