Model View Controller (MVC) : Model & Data Types
Suppose you have an N-Tier, MVC architecture of your (java or *) application. You chose MVC for its logical, manageable partitioning of the application code. Suppose you are into Java, since there are many frameworks or tools out there, you don't want to tie a Layer (M or V or C) to a specific technology, and would like to maintain the freedom for later upgrades or even integration with other parts.
Now, in every scenario, a Model may contain primitive data types (like Int, String..etc), or more advanced ones in the form of classes (OO features for max complexity). How would you deal with that:
- keep your Model as POJO as you can, and implement the typing at the V or C layer, since it is mostly about data input and validation . This way, you don't have to worry about your Model being used elsewhere, almost nothing will change at the DAL as well, but you have to do extra effort to convert your model to a rich-model (rich in types); when you transfer it from the storage to the view
- enable your Model to support types as other nested Models, and implement V or C layer tricks to deal with it, each Layer will 开发者_StackOverflowhave to process the model-complex, instead of just using getters and setters. However this way, you keep the model-complex in other technological settings, which should be adapted accordingly.
- [none of the above or else]
I think the technology is irrelevant if you wanna go fully distributed. I would create separate apps for each layer, which you can easily cluster and then choose a standardized communication format like JSON over HTTP(s).
JSON can be as simple or complex as you like and pretty much every language out there has support for it built in.
HTTP is fast and simple, and very easy to scale.
Just my two cents.
精彩评论