News for hackers. Stuff that matters.
Re:C++ Patterns: The Badge by cgrealy on Tuesday June 11, 2019 @10:14PM (#20161175)
While this is a clever little pattern, I'd argue that if you have a method of class X that can only be called from class Y, that is a code smell.
Re:C++ Patterns: The Badge by Toine on Wednesday June 12, 2019 @01:19AM (#20161973)
Sometimes, clever little patterns like that are useful to get stuff done in time. However, it that case it definitely smells a lot. Also, the global singleton stinks.

To me this is a violation of the Interface Segregation Principle. I think the author went the right way to fix it, but not far enough.

He added a parameter to segregate the device registration operations from other operations. It works, but the segregation is artificial : you still need a Device object (which seems to be used by a lot of classes, another smell, god object ?)

Instead of asking for an entire Device object, register_device should ask for a different type, specific to that operation, like « NewDevice », « UnregisteredDevice », etc. This object would depend on very specific information only available at the device creation. Now, if another developer tried to call register_device, he would need to create a weird object that he never heard of, with parameters he cannot even provide.

Thoughts ?

Re:C++ Patterns: The Badge by dkersten on Wednesday June 12, 2019 @04:07AM (#20162659)
Is an object really a god object if lots of people use it? I thought it was the opposite way around: a large object that contains too much functionality, but this device could be a tiny single purpose object for all we know, that a lot of clients need to use.
Re:C++ Patterns: The Badge by ksherlock on Tuesday June 11, 2019 @11:46PM (#20161618)
protected and friend are both smelly keywords?
Re:C++ Patterns: The Badge by dearrifling on Wednesday June 12, 2019 @12:56AM (#20161877)
Some people argue exactly that. I don't necessarily agree.