質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top