I am working on a simple problem to represent several types having a hierarchical structure. There is a data row containing some data, and the data can vary from row type type to another. A simple line can only contain a title and a date, and an extended line can contain a title, description, date and image. I'm not new to Javascript, but don't understand it well enough to move forward. To give a simplified example, here is how I will write it in Java:
interface Row {
View getView();
}
class BasicRow implements Row {
private String title;
private String description;
public BasicRow(String title, String description) {
this.title = title;
this.description = description;
}
public View getView() {
}
}
class ExtendedRow implements Row {
private String title;
private String description;
private Date date;
private Image image;
public ExtendedRow(String title, String description, Date date, Image image) {
this.title = title;
this.description = description;
this.date = date;
this.image = image;
}
public View getView() {
}
}
There are several OO improvements that can be made here, for example, extending the ExtendedRow from BasicRow and defining only new fields plus overriding the getView method.
Javascript , , . , - , Javascript, , , , .
.