DateTimeExtensions
DateTimeExtensions copied to clipboard
Use IWorkingDayCultureInfo instead of WorkingDayCultureInfo in GetWorkingDays
Hi,
Is it possible to use the interface IWorkingDayCultureInfo instead of the WorkingDayCultureInfo concrete class in the GetWorkingDays method? Or is there a reason why the interface is not used in this case? I noticed that the interface is used for the AddWorkingDays and AllYearHolidays methods.
Many thanks for this great job! Dylan
I sorry for the late review. I need to check!
It seems like you're referring to a specific piece of code or framework that involves a GetWorkingDays
method, a WorkingDayCultureInfo
concrete class, and an IWorkingDayCultureInfo
interface. Unfortunately, you haven't provided the actual code snippet, so I can only provide a general answer.
Using interfaces in favor of concrete classes often provides more flexibility, as it allows for greater abstraction and loose coupling in your code. This is particularly useful when you want to support multiple implementations or when you want to mock objects for testing purposes.
If GetWorkingDays
is a method that could work with any implementation of working day culture info, then it might make sense to use the IWorkingDayCultureInfo
interface in its signature. This would allow different implementations to be passed in without modifying the method itself.
Without seeing the actual code, it's challenging to give a more specific answer. If you can provide the relevant code snippet or more context, I'd be happy to help you further.
Thank you for your insight @raxcodes , but you're totally missing the point. This issue is to fix something on a code. No one asked to discuss either the advantages or disadvantages of calling an interface or a concrete class object.
got it!
I'll even point down the line of code
https://github.com/joaomatossilva/DateTimeExtensions/blob/84040b64addf860650644f35d9ac3cbd1548cef3/src/DateTimeExtensions/WorkingDaysExtensions.cs#L83
It doesn't get much easier than this 😄
Maybe you want that I will build the interface? I can do this if you want
Will the code be provided?
Fixed by #143