DateTimeExtensions icon indicating copy to clipboard operation
DateTimeExtensions copied to clipboard

Use IWorkingDayCultureInfo instead of WorkingDayCultureInfo in GetWorkingDays

Open dconsavi opened this issue 3 years ago • 1 comments

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

dconsavi avatar Jun 07 '21 14:06 dconsavi

I sorry for the late review. I need to check!

joaomatossilva avatar Oct 17 '21 23:10 joaomatossilva

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.

raxcodes avatar Oct 02 '23 12:10 raxcodes

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.

joaomatossilva avatar Oct 02 '23 13:10 joaomatossilva

got it!

raxcodes avatar Oct 02 '23 16:10 raxcodes

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 😄

joaomatossilva avatar Nov 06 '23 21:11 joaomatossilva

Maybe you want that I will build the interface? I can do this if you want

chavi362 avatar Jan 20 '24 18:01 chavi362

Will the code be provided?

Dvanni avatar Jan 27 '24 22:01 Dvanni

Fixed by #143

joaomatossilva avatar Jan 28 '24 10:01 joaomatossilva