DEV Community

Cover image for Top 5 DEV Comments from the Past Week
Jess Lee for The DEV Team

Posted on

Top 5 DEV Comments from the Past Week

This is a weekly roundup of awesome DEV comments that you may have missed. You are welcome and encouraged to boost posts and comments yourself using the #bestofdev tag.

@sunnysingh shared a story from their college days in the What is the most overworked you've ever been? discussion:

I had a client as a freelancer that kept changing the scope of a project. This was when I was still in college, so I was also overloaded with class projects and my own side development projects.

Worked 2 all-nighters to finish the project, which still ended up being not what they wanted, and worst of all I did not get paid for the 3 months of work.

Obviously it was my fault in not setting up a contract and requesting half payment up front. Lesson learned the hard way πŸ˜…

@aminnairi added an example of what makes currying so powerful to the post, Currying in JS 🀠:

Hi there and thanks for your article!

In my opinion, this article deserves a little bit more explanations, especially the usefulness of using curried functions.

If I start from your example.

const isDivisible = divider => number => !(number % divider);

console.log(isDivisible(2)(40)); // true
console.log(isDivisible(2)(33)); // false
console.log(isDivisible(3)(40)); // false
console.log(isDivisible(3)(33)); // true
Enter fullscreen mode Exit fullscreen mode
Enter fullscreen mode Exit fullscreen mode

Enter fullscreen mode Exit fullscreen mode

Even though you have successfully curried your function, we can see that the 2 & 3 parameters could have been reused. Now if I take this example.

const isDivisible = divider => number => !(number % divider);

console.log(isDivisible(2)(40)); // true
console.log(isDivisible(2)(33)); // false
console.log(isDivisible(2)(29)); // false
console.log(isDivisible(2)(26)); // true
Enter fullscreen mode Exit fullscreen mode
Enter fullscreen mode Exit fullscreen mode

Enter fullscreen mode Exit fullscreen mode

We can see that I'm repeating the 2 a lot. What is great about curried functions is that they can be used to compose higher order functions (a higher order function is a function that either takes a function as parameter or returns a new one), and so helping us reuse some parameters that are commons accross function calls.

const isDivisible = divider => number => !(number % divider);
const isDivisibleByTwo = isDivisible(2);

console.log(isDivisibleByTwo(40)); // true
console.log(isDivisibleByTwo(33)); // false
console.log(isDivisibleByTwo(26)); // true
console.log(isDivisibleByTwo(39)); // false
Enter fullscreen mode Exit fullscreen mode
Enter fullscreen mode Exit fullscreen mode

Enter fullscreen mode Exit fullscreen mode

And this is, in my opinion, what makes currying so powerful. Composing functions helps you decrease the needs for repeating common parts of your application.

</div>
Enter fullscreen mode Exit fullscreen mode

@emma chimed in on the discussions, What's your personal productivity software stack?, to share the most important software they have installed on their machine:

The number one most important software for me is Cold Turkey, which is a website/application blocker to stop me from mindlessly browsing the internet all day. I only wish there was a mobile version!

For programming I use VSCode and Firefox, for to-do lists and reminders I use TickTick and for all my bigger thoughts I put them into Trello (I love Trello!)

I've also just recently picked up Dropbox Paper for writing blog post drafts. I've tried Notion in the past but I wasn't too big of a fan of their content blocks system.

@ryansmith listed five top frameworks to consider in response to: What's the Node framework landscape like?:

I recently researched Node frameworks for a project and there are a ton of options to choose from.

  • Express - Still the most widely used by a large margin. It is a barebones framework, so much of the setup for routes/views is done manually. To extend Express, you would use Express middlewares to take action on the incoming requests or outgoing response.
  • Koa - The successor to Express from the same initial development team, but has not gained as much traction as Express.
  • Sails - A framework that is based on Express, but provides some MVC conventions and ways to generate routes.
  • Hapi - This one has been rising in popularity. It provides more features out of the box than Express and there are plugins to extend it. It differs from Express because these plugins run together with Hapi to provide that functionality, as opposed to middleware that operates on requests and responses.
  • Adonis - This is more of a full-featured framework that was inspired by Laravel. It has been gaining popularity and looks pretty slick.

Those were the top 5 I considered, but there is also Meteor, Fastify, Nest, Keystone, Hasura, Vulcan, Hammer.js, Prisma, LoopBack, and others.

When in doubt, follow the saying of "Nobody ever got fired for choosing IBM" but replace that with "Express". It gets the job done and has the community support to back it up. A lot of the newer frameworks look very cool and include more features to provide a better developer experience, but it can be hard to choose and hard to predict long-term support for them.

@andeemarks kicks off a thoughtful discussion about refactoring in Keeping your code clean by sweeping out "if" statements:

Comment Not Found

See you next week for more great comments ✌

Top comments (4)

Collapse
 
jess profile image
Jess Lee

Congrats @sunnysingh , @aminnairi , @emma , @ryansmith , and @andeemarks for making the list today!

Collapse
 
ryansmith profile image
Ryan Smith

Thank you!

Collapse
 
emma profile image
Emma Goto πŸ™

Thanks Jess!

Collapse
 
aminnairi profile image
Amin

Thank you Jess!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.