Modern & Effective C++ design ideas
Posted: June 1st, 2014, 7:37 am
QuoteOriginally posted by: outrunThat's why you need to make functions/algorithms non-member. Indeed, like visitors. Separate data and operations. The solution is beginning to look like a pre-GOF era visitor.And print() = 0 in a class is very bad design. I did this a while ago and then we rediscovered Visitor by migrating oprint to its own driver class(es). We need a devive context for print(Context& context) such as Console, AutioCAD etc.QuoteBtw they're pure virtual, no vtable.Fair enough, This is marginal. The real issue is Shape becomes a monolith, as I already mentioned. It flies in the face of SRP Summary: the main issue is how to maintain the explosion in the number of ops. like move() etc. 50 ops. is not unusual. Maybe a performance hit? then an option is buy a bigger machine. It's cheaper.