Law of Demeter: Principle of Least Knowledge. The Law of Demeter(LoD) is a simple style rule for designing object-oriented systems. "Only talk to your friends" is the motto.
High Cohesion: degree to which the elements of a module belong together
Loose Coupling: the manner and degree of interdependence between software modules
const moduleOfCode = {
store: {},
getData() {
return fetch('/some-data/123').then((result) => {
store['data'] = result;
});
},
renderView() {
console.log(store);
}
};
moduleOfCode.getData().then(() => {
moduleOfCode.renderView();
});
const getData() {
return fetch('/some-data/123');
}
, renderView(result) {
console.log(result);
};
getData().then((result) => {
renderView(result);
});