lundi 26 décembre 2016

Domain Model pattern example

I'm just trying to find some examples of Domain Model pattern and I can't.

From what I found on the Internet Domain Model is just adding some "logic" methods to classes. For example

public class Income {
    private String title;
    private String comment;
    private String date;
    private Double amount;
    private Integer category;

    public ExIn(String title, String comment, Double amount, Integer category, String date) {
        this.title = title;
        this.comment = comment;
        this.date = date;
        this.amount = amount;
        this.category = category;
    }

    public Integer getCategory() {
        return category;
    }

    public void setCategory(Integer category) {
        this.category = category;
    }

    // more getters and setters
    // Domain Model part starts
    public boolean isPositive()
    {
        return amount > 0 ? true : false;
    }
    // more methods like that 
}

Did I understand it correctly? If not, I'd be grateful for a little example.

Aucun commentaire:

Enregistrer un commentaire