Sure. Even just using pure functions can change the way you write things.
Whenever I get to write a function from scratch I end up with something like this.
functionbig_function(){constdata=get_data();consterrors=validate(data);if(errors.length){show_errors(errors);return;}constclean_data=some_process(data);constsaved=save_stuff(clean_data);if(saved==false){show_errors(['oops, something went wrong']);return;}show_message('we good');}
I have a 'big function' that coordinates a bunch of 'little functions.'
The things that can have an effect on the outside world get their own functions and most of the time don't process anything, they just show/save/send whatever you throw at them.
Almost everything ends up being a two step process, handle the data and using the data.
The most important thing is to make the little functions as predictable as possible. Given the same inputs should always give you the same result.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sounds awesome! I've shied away from functional programming in the past, so will definitely check this out. Is it something that you use a lot?
Sure. Even just using pure functions can change the way you write things.
Whenever I get to write a function from scratch I end up with something like this.
I have a 'big function' that coordinates a bunch of 'little functions.'
The things that can have an effect on the outside world get their own functions and most of the time don't process anything, they just show/save/send whatever you throw at them.
Almost everything ends up being a two step process, handle the data and using the data.
The most important thing is to make the little functions as predictable as possible. Given the same inputs should always give you the same result.