Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • The is mainly about C++. Lets assume A, B, and C are stateless and they all have multiple public methods. I just happen to need to create an app that will use some of the methods from them. Interesting that you like option 1 better, if you go with option 1 I think building objects A, B, and C in main is a bad idea, because the main advantage of the abstraction to ABC is there is no need to include A.h B.h and C.h. I came across this stackoverflow.com/a/4668400/3667089 which seems to support option 2. What do you think? Commented May 13, 2017 at 5:13
  • I think you're free to suck all the details into ABC if you like. But I still argue that mixing construction and use together is a bad idea. You've already mentioned a reason why. It reduces the re-usability of ABC. If ABC hard codes a b and c then that particular combo will be all it's ever good for. Not all construction has to be done in main. But it'd be nice if main didn't only have one kind of construction to pick from before using ABC. You can still separate these without doing the work in main. That's what construction patterns are for. Commented May 13, 2017 at 5:27