MVC Architecture Pattern

This architecture pattern will assign and separate the objects into responsibilities: Model, View and Controller

  • Model: will represent an object, such as a person.

  • View: The view will represent the model data.

  • Controller: It controls the data of the model object and controls the visualization.

Structures

Structures
└── src
    └── main
        └── java
            └── com.your_company_name.your_name_app
                └── model
                    └── Person
                └── view
                    └── HomeView
                └── controller
                    └── HomePresenter
package com.totalcross.mvc.model;

public class Person {
    private String name;
    private String gender;

    public Person(String name, String gender) {
        this.name = name;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return "n: " + name + " g: " + gender;
    }
}

Referencies

Last updated