News for hackers. Stuff that matters.
Re:Why you should never ever ever have Managers in your clas... by chris_wot on Sunday March 31, 2013 @08:07PM (#5470741)
Hopefully this doesn't sound too dense, but what if whole point of the class is to manage connections? What exactly is meant to take it's place?

It seems to me that the issue is that they named the class ConnectionManager when it should have been Connection. But then if you are doing connection pooling, and you need specific control over the Connection objects, then what would the harm be in delegating this to a ConnectionManager class, which manages a bunch of Connection objects?

Re:Why you should never ever ever have Managers in your clas... by BIackSwan on Sunday March 31, 2013 @08:11PM (#5470759)
You can create a ConnectionPool class with the relevant logic to manage Connections. If you want multiple pools (which you might connect to different servers ;) ) you just instantiate multiple ConnectionPools.

ConnectionPool makes you think of it as an actual object. ConnectionManager makes you think of this all encompassing thing that handles/manages anything that is Connection related.

Re:Why you should never ever ever have Managers in your clas... by joe_the_user on Sunday March 31, 2013 @08:28PM (#5470799)
The Connection Manager in QT, for example, is not a Connection Pool. It's more of an interface to get at all the classes that represent real things within a connection process (requests, responses, active connections, etc). There is no information in the Connection Manager except system/process defaults. The Connection Manager would create connection pools if that is what's needed but it isn't Connection Pool any more than it is a connection.

That said, I sympathize with the impulse that the term "manager" says there's something wrong in your OO design. It is simply that determining how to get around the problem is hard.

Re:Why you should never ever ever have Managers in your clas... by neeharc on Sunday March 31, 2013 @08:35PM (#5470820)
The point that is being made is to make sure that the name of the class makes its responsibilities clear. The problem with the term "manager" or "handler" is that it leaves things ambiguous.
Re:Why you should never ever ever have Managers in your clas... by mkmkmmmmm on Sunday March 31, 2013 @08:52PM (#5470860)
ConnectionPool makes me think of a collection of reusable connections that I can borrow from to talk to a server without the overhead of creating an object and opening a socket, it doesn't make me think of managing at all. Maybe I am doing it wrong?

I'm just hoping for a discussion, this is an important topic for me as a developer.

Re:Why you should never ever ever have Managers in your clas... by BIackSwan on Sunday March 31, 2013 @08:57PM (#5470875)
You got it right. Thats exactly what it should be doing. If you have additional requirements you might want to create another class for that requirement or rename it to something else.
Re:Why you should never ever ever have Managers in your clas... by mkmkmmmmm on Monday April 01, 2013 @01:13AM (#5471575)
That seems like an incredibly appropriate class name, then. I'm glad I wasn't missing something :)
Re:Why you should never ever ever have Managers in your clas... by robryan on Sunday March 31, 2013 @08:24PM (#5470793)
You still might want a connection manager to contain your connection pools. Or even call it a messages or something, so at the relevant point in the code you just call a send function and aren't exposed to any underlying details of connections.
Re:Why you should never ever ever have Managers in your clas... by Evbn on Sunday March 31, 2013 @10:56PM (#5471198)
Specifically, what is the class doing with those pools? "Managing" is vague.
Re:Why you should never ever ever have Managers in your clas... by drivebyacct2 on Sunday March 31, 2013 @08:35PM (#5470822)
Exactly, it's description of the name of the object, rather than trying to be descriptive of what it does. AutomaticallyRetryingConnectionManager or ConnectionPool{.ConnectWithRetry,etc}
Re:Why you should never ever ever have Managers in your clas... by Evbn on Sunday March 31, 2013 @10:54PM (#5471191)
You mean "pool connections" not "manage connections".
Re:Why you should never ever ever have Managers in your clas... by gav on Sunday March 31, 2013 @08:42PM (#5470830)
Exactly. Maybe a better name would be ConnectionFactory? This could then have multiple ConnectionPools internally for sync vs. async if needed. It's certainly better than polluting the whole code base with the logic required to instantiate an individual connection.

The counter-example given is bad in another way, if you have the max retries on a per-connection basis, you're going to be blocking trying to make connections to an end point that's down. If this state is per-end point, handled by a Manager/Factory/Pool, then you can make the retry logic global.

The main key with rules in software engineering is that it takes experience to know when it makes sense to break them. There's few things that fall in the "never ever" category.