I'm wondering if this sort of design pattern is bad practice or if there are side effects I'm not seeing.
A single object is modified by a series of functions.
Something like this...
let someObject = {
alpha: 0,
bravo: 0,
charlie: 0,
};
function changeA(obj) {
obj['alpha'] = 1;
return obj;
}
function changeB(obj) {
changeA(obj);
obj['bravo'] = 2;
return obj;
}
function changeC(obj) {
changeB(obj);
obj['charlie'] = 3;
return obj;
}
changeC(someObject);
Aucun commentaire:
Enregistrer un commentaire