richardtallent / RT.Comb

Creating sequential GUIDs in C# for MSSQL or PostgreSql
203 stars 35 forks source link

Add zero configuration support #7

Closed dotnetchris closed 7 years ago

dotnetchris commented 7 years ago
ICombProvider myCombProvider = new SqlCombProvider(new SqlDateTimeStrategy());

This is too much work and totally leaks all kinds of implementation details.

You really should have a class that behaves something like

public class Comb

public static ICombProvider Sql { get; } = new SqlCombProvider(new SqlDateTimeStrategy());
public static ICombProvider Unix  { get; } = new whatever;

etc.

There's probably almost never a reason a person needs to actually touch your construction. Just give people the defaults in a statically available manner.

richardtallent commented 7 years ago

A fair point! I started out with some static classes, but then got wrapped up in making everything configurable. I built the library originally for a ASP.NET Core project and have been using DI to create a single instance for my entire application, so there wasn't much pain in having a more verbose constructor.

I'll add a static class with some sensible default providers in the next revision. Leaving this open until then...

richardtallent commented 7 years ago

Version 2.3.0, just released, includes a static RT.Comb.Provider class with three options for zero-configuration use:

Thanks for the feedback! Closing.