I don't chain everything in JavaScript anymore
allthingssmitty.com
I don't chain everything in JavaScript anymore
1–10 of 54 posts
Re: I don't chain everything in JavaScript anymore
#2Re: I don't chain everything in JavaScript anymore
#3Re: I don't chain everything in JavaScript anymore
#4Re: I don't chain everything in JavaScript anymore
#5I agree that debugging these pipelines are a nightmare sometimes. It's something that frustrates me sometimes because even though in OOP it won't be terse the action would be clearer. OOP can at times also introduce less cognitive load as well. I wonder if the issue is the mixing of paradigms. Although I don't think everything should follow purity boundaries: functional must always be functional and OOP languages sho…
Re: I don't chain everything in JavaScript anymore
#6It's the same reason I don't like this style of function:
.map(var => var.toUpperCase())
Sure, it's great today but but I want to debug it I need to add `{}` in and/or if I need to add a second operations I need to add the curly braces as well. That's I prefer explicit: .map((var) => {
return var.toUpperCase();
})
Since it's much easier to drop in a debug line or similar without re-writing surrounding code. It also makes the git diff nicer in the future when you decided to do another operation within the `.map()` call.I've asked many people to re-write perfectly functioning code for this same reason. "Yes, I know you can do it all in 1 line but let's create variables for each step so the code is self-documenting".
Re: I don't chain everything in JavaScript anymore
#7Agreed, while chaining can look very pretty, it's a pain to re-parse and a pain to modify. It's the same reason I don't like this style of function: .map(var => var.toUpperCase()) Sure, it's great today but but I want to debug it I need to add `{}` in and/or if I need to add a second operations I need to add the curly braces as well. That's I prefer explicit: .map((var) => { return var.toUpperCase(); }) Since it's mu…
Re: I don't chain everything in JavaScript anymore
#8Re: I don't chain everything in JavaScript anymore
#9Re: I don't chain everything in JavaScript anymore
#10This is a solution that people fixed 25 years ago with detailedReturnObjectNames.