MangiaFuoco
This is a way to decouple application parts. It could be used to solve different use cases:
- Easily Collect metrics of your application
- Manipulate producer data multiple unknown modifiers
- Create Plug n Play components without altering already working codebase
Lets say you've a login
function that returns a Promise containing the user information if the login suceeds.
{ return userModel; }
Later you realize you need to add an extra field to the returned data so you modify your code accordingly:
{ return userModel ;}
Then you want to coherce the user to change the password if that wasn't modified for some months.
{ return userModel ;}
After 2 months. the boss gets to you and he says that he does not want to change it's password every month and you need to change your login function again adding even more complexity.
mangiafuoco to the rescue. What about having the login function doing something like:
{ return userModel }
Adding additional stuff shouldn't change your login function code (and tests). And adding your boss last requirement should be as easy as adding your code in a separate file that should be testable by its own.
boss_exception.js
{ if userObjuid == 'boss' userObjmustChangePassword = false; ;};
then registering your exception using something like this.
;projname;