Chat Server with Java & Netty
I want to implement a Chat Server with Java and Netty. My question is: should I make all the work in Netty's connection handler? For "all the work" I mean for example: to do the login 开发者_如何学Python( so with mysql connection ), eventually to send message, to log informations..
I think a more robust design would be to make a system that works without Netty and then use Netty's connection handler to go between the two. This way, if you decide to move away from Netty in the future, you can do so with minimal rewiring.
If you put all that functionality into interface-based POJOs, rather than a Netty connection handler, you'll find it easier to test it without having to fire up Netty.
Once you have all those objects working and tested, then give them to a connection handler and let them do the work. The connection handler just orchestrates your POJOs to fulfill its requests.
精彩评论