Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
To use static classes instead of structs for storing template GUIDs #458
Hi. Is there a certain reason why structs were chosen to hold GUIDs of Sitecore templates and fields instead of static classes?
Furthermore, it can also be controversial that structures are used to hold constants only, according to this discussion on SO. In some other programming languages it could be true (like C/C++), but in C#, structures can have properties, methods and even implement interfaces.
Do you think that indeed it will be better to use static classes to hold template GUIDs, instead of structs? Should I create a pull request for this?
Thank you for the commentary Sergey. I would agree that -- if I were creating a solution like Habitat from scratch and needed to store ID references to fields/templates -- I would likely use static classes too. I can't speak to if there is a specific reason it was implemented this way or not -- I'll leave the discussion open for others to comment.
Where I do see for certain that this can be improved is in the linked documentation on the Helix docsite -- the docs should reference static classes (or even ORM solutions) as optionally viable ways to achieve the same end goal. The docs read today as if structs are the only option -- which they are certainly not. I've tagged it so we can get around to changing that in the next doc rev.
I'd be fine with instantiating a PR, but I'd suggest waiting to see if anyone else has any thoughts/objections first that I'm just not aware of.