开发者

I/O communication in Java - to what part of MVC does it belong?

I have divided my project into three packages: model, controller, view. But I am still confused where to put the classes which deal with I/O communication in my application - in my case the I/O communication is done by network sockets reading incoming messages which have an effect to the model.

I've been told three things now:

  • it belongs to the controller, since it deals with transferring the data
  • it belongs to the model, since every aspect of the domain model should be part of the model
  • none if it, put it in a separate package or the default package

Currently I am going with the third advice, however I am still thinking it might be the second point. Could someone clarify what is meant i开发者_开发技巧n this context?


Usually there's a service package that is services the controller makes use of. It would fit nicely there.


IMHO I would make it its own seperate package and call it/use it from the controlller. The controller is the section that will access this information and give it to the model etc...


I'd put it in the model class, or, possibly in another class which in turn updates the model.

I'd definitely not put it in the controller, since the controller in MVC is all about bridging the view to the model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜