Am I correct in saying that each object that instantiates objects of another class should (ideally) have a factory for that object as a dependency?
Let me clarify it with an example. I have a class Shipment whose method Shipment::plan instantiates a new Graph object. So Shipment depends on a factory that creates a Graph. Therefore I should make this dependency explicit, for example by passing a Graph factory to the Shipment constructor.
As Pieter, I also wondering how to instantiate a new object graph when I'm in a business object method. Note that instantiation is based on data of the method and so I cannot inject it from the constructor (like the Shipment class I have a db mapper that returns a new Collection class and so depends on this concrete class).
Excellent questions about how to construct (what I call value objects) It is not something I can explain as a comment, so my next blog will cover that topic.
I've been a fan of the Google Testing blog for a good while now, and I frequently encourage others to add it to their feed reader. While the quality of the *message* has generally remained high, I'm bummed to see the quality of the *writing* take such a dip lately. And I'm not the only one that's noticed:
- https://www.blogger.com/comment.g?blogID=15045980&postID=3023874871164884317 - Arun says, "If you get past a number of typos and the non-working links, it looks like a hastily written, non-proofed copy."
- https://www.blogger.com/comment.g?blogID=15045980&postID=1997301458069663637 - Michael says, "3v1L fails the spellchecker unit test"
- https://www.blogger.com/comment.g?blogID=15045980&postID=3023874871164884317 - John Webber asks, "Miško, in the paragraph about static methods you refer to 'seems' - do you mean 'seams?' Otherwise I'm not sure what you mean."
As a grammar geek, it pains me to see the influential Google brand giving its stamp of approval to substandard writing. Good news: It's easily solved by having a peer proofread the post before publishing it. Peer reviews are just for code after all. ;-)
Does this technique coupled with minimal constructors inhibit const-correctness?
ReplyDeleteAm I correct in saying that each object that instantiates objects of another class should (ideally) have a factory for that object as a dependency?
ReplyDeleteLet me clarify it with an example. I have a class Shipment whose method Shipment::plan instantiates a new Graph object. So Shipment depends on a factory that creates a Graph. Therefore I should make this dependency explicit, for example by passing a Graph factory to the Shipment constructor.
As Pieter, I also wondering how to instantiate a new object graph when I'm in a business object method. Note that instantiation is based on data of the method and so I cannot inject it from the constructor (like the Shipment class I have a db mapper that returns a new Collection class and so depends on this concrete class).
ReplyDelete@ Peter & @giorgio
ReplyDeleteExcellent questions about how to construct (what I call value objects) It is not something I can explain as a comment, so my next blog will cover that topic.
I've been a fan of the Google Testing blog for a good while now, and I frequently encourage others to add it to their feed reader. While the quality of the *message* has generally remained high, I'm bummed to see the quality of the *writing* take such a dip lately. And I'm not the only one that's noticed:
ReplyDelete- https://www.blogger.com/comment.g?blogID=15045980&postID=3023874871164884317 - Arun says, "If you get past a number of typos and the non-working links, it looks like a hastily written, non-proofed copy."
- https://www.blogger.com/comment.g?blogID=15045980&postID=1997301458069663637 - Michael says, "3v1L fails the spellchecker unit test"
- https://www.blogger.com/comment.g?blogID=15045980&postID=3023874871164884317 - John Webber asks, "Miško, in the paragraph about static methods you refer to 'seems' - do you mean 'seams?' Otherwise I'm not sure what you mean."
As a grammar geek, it pains me to see the influential Google brand giving its stamp of approval to substandard writing. Good news: It's easily solved by having a peer proofread the post before publishing it. Peer reviews are just for code after all. ;-)
It’s klear that we can do better on spell and grammer cheeking.
ReplyDelete-- editor