Open devigned opened 7 years ago
I would have loved to have created abstract factories for the profiles, but alas, that would, at worst, prevent us from providing strongly typed clients, and at best, only provide back an abstract base representation of the client. That means, we would not have strong typing and IDE support for specialization of the types and operations across profiles.
If we feel strong typing is not a concern, we can be much more flexible in our implementation.
As for producing the profile specific clients, I would not expect this to be done by hand, but by a code generator. With that said, it's not a ton of code to write (see https://github.com/devigned/profile-playground/blob/master/dotnet/src/Azure/Mgmt/Profiles/2017_01_31/Client.cs).
Don't let idioms get left out of this conversation! For strongly typed languages, I agree that factories in this shape don't make sense. We can't guarantee much about the similarity of clients across API Versions, so it would be hard to strongly type their relationship. However, in dynamic languages this seems like a fairly convenient and intuitive way of handling this.
IMO, the idea and names of profiles should be consistent across languages, but the way you access them should be somewhat flexible.
If a client application has the means to change its behavior based on profiles supported on the server (i.e. using the DLR and/or the dynamic keyword in C#), we should make that possible. So, yeah, there is a sliding scale of strongly typed:ness in many languages/runtimes.
@johanste That's a great idea. Provide an abstract factory for profiles, but also keep the static ones around.
What do you think about this:
// Given a Profile version enum, construct and return the profile
dynamic ProfileFactory(ProfileVersion.2017_01_31) {...};
// Given a Profile definition (set of resource types and api versions) return a
// dynamically constructed profile
dynamic ProfileFactory(ProfileDefinition definition) {...};