Question

I am currently learing the MVP design pattern and have a question as to where the simple logic should go.

I am under the impression that all business logic should go into the model, does this include simple methods such as:

public int Add(int a, int b){
    return a + b;
}

or is it only logic that deals with the database that is in the model? Im slightly confused as to where the line is drawn regarding Presenter logic and Model logic.

EDIT:

If the method i wanted to add was this instead:

public double GetConvertedCurrency(double ammountInDollars, double exchangeRate){
    return ammountInDollars * exchangeRate;
}

and the ammountInDollars was input by the user and the exchangeRate was fixed (example purposes only) would this also be in the Model?

I only want to display the return value on screen and not store it in a database.

Était-ce utile?

La solution

If by "business logic" you mean all the rules that apply to your data domain regardless of your application behavior, then yes, you should put it in the model.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top