4 ms·
I felt that your comment speaks to me - I had a similar understanding a couple of years ago. In their book "Growing Object Oriented Software, Guided by Tests",
by cessor 12y ago
I felt that your comment speaks to me - I had a similar understanding a couple of years ago. In their book "Growing Object Oriented Software, Guided by Tests", Nat Pryce and Steve Freeman describe values and objects, *(Values in the sense of Value Objects in Evans' DDD)
> The confusion is, that both concepts are implemented by the same language construct: Classes
This made me think. In C# this statement is somewhat untrue, since you have structs that have value semantics (value equality). But why are there no other concepts within the language that help you from reinventing the pattern wheel?
For example, I had seen the singleton pattern quite frequently in a codebase I worked on, with the label leaking into the class name. But why is it that you have to write:
public class DatabaseConnectionSingleton { ... }
and then deal with all the static stuff (i.e. x.Instance()) rather than
public singleton DatabaseConnection { ... }
Like this, you could easliy use standard stuff:
new DatabaseConnection()
and the runtime would simply return the same instance. This would keep people from reinventing the mechanism. Like IoC / DI built into your language...
[1] http://www.amazon.co.uk/Growing-Object-Oriented-Software-Guided-Signature/dp/0321503627 http://www.amazon.co.uk/Growing-Object-Oriented-Software-Gui...