Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Concrete classes considered harmful Date: Sun, 12 Jul 2015 09:17:05 +1200 Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 7jNnOayyTliNWCdlt8iDLwyZx5uhugNHEYsbUBkdHy8WV8ihXv Cancel-Lock: sha1:d5Hsqd6leHRYbaD4vIZNFO5Q1ss= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Xref: csiph.com comp.lang.c++:37025 Mr Flibble wrote: > On 11/07/2015 04:09, Ian Collins wrote: >> Mr Flibble wrote: >>> Dependencies on concrete classes are considered harmful and should be >>> replaced with dependencies on abstractions. >> >> By whom? > > Go learn the SOLID principles; anyone who does not know and/or follow > SOLID is not a very good engineer IMO. Well I certainly know about them and consider them guidelines, not hard and fast rules. If you follow any set of guidelines as if they were gospel, you'll end up like the religious zealots who pop up here from time to time. Oh by the way, I also use int in my code, so I guess by your standards I'm already not a very good engineer. >>> A class should not new its >>> member objects for example but rather should use a factory passed into >>> its constructor. >> >> Why? > > Good luck unit testing a class that has lots of dependencies on concretions. I've been unit testing everything I write for over a decade now and I've yet to encounter problems with non-abstract base classes. Go and and learn about mock objects. -- Ian Collins