DEV Community

Discussion on: What every ASP.NET Core Web API project needs - Part 6 - IServiceCollection Extension

Collapse
 
moesmp profile image
Mohsen Esmailpour • Edited

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);
Enter fullscreen mode Exit fullscreen mode

Here is some useful link about extension method:
Extension Methods Guidelines in C# .NET
Extension Methods General Guidelines