Im kind of new to MVC. My question is how do you design an application and implement it with complex logic.
I'm using the Play framework, creating a java web app. Rather than just dealing with basic form based data being saved into the DB, imagine I send a file over to the server(maybe a spreadsheet) and want to break it up and cleanse it before saving it to the db etc.
Now I want to do this in the most practical and well thought out way. I dont want a really tightly coupled system. I may for instance want to upload a csv file in the future and expect the same outcome.
So basically just looking for some advice for building a complex model. Until now my models have been just one object. To me this problem of breaking the file up looks like Im going to write a seperate package with some utilities etc and a main service object to process the raw data.
Any advic开发者_Python百科e as always will be much appreciated.
The best way to deal with complex business logic is to break it out into separate objects + methods. This way you can build your complex calls with composition instead of coupling all of that functionality to one method in a model.
Your model is usually one object, but there is no rule saying that it can not talk to other objects.
You can continue using your models as simple objects and add an additional tire, with your "business logic", basically methods where you do what you need to do, still keeping your Models and Controllers clean.
http://en.wikipedia.org/wiki/Business_logic
精彩评论