Answer the question
In order to leave comments, you need to log in
MVC. Can anything be public?
As a language, the path will be Java , because now I'm developing mob. app.
Let's fantasize...
Let there be some entity, Man:
public class Human {
int id;
String name;
Date birthday;
// getters and setters
}
public class Model {
public Human[] getHumans() { /* тут куда-то лезет и что-то отдаёт */ }
public Human getHumanById(int id) { /* тут тоже */ }
}
public class View {
public void showHumans(Human[] humans) { /* тут как-то отображает */ }
}
Answer the question
In order to leave comments, you need to log in
Nothing collapses, Human is an entity (POJO). In MVC, she can participate in all 3 parts. Or it may not participate if, for example, at the Model level you operate with some entities, and in the View you pass others, for example, composite ones.
You can, as an option, take data as a string from the model (or an array of strings), parse, call View methods by passing the appropriate parameters. But it's not OOP, and it doesn't look nice either.OOP is not only MVC, but a programming approach in general. In addition to MVC, there is also MVP, MVVM, etc.
Use an interface instead of a concrete class if you feel like it:
public interface IHuman{
String getName();
void setName(String name);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question