Sign in
Log inSign up
Maxi Contieri⭐⭐⭐

52 likes

·

2.1K reads

6 comments

Rodion Borisov
Rodion Borisov
Nov 12, 2020

From all the beasts, helpers and utils are the most uncouth.

2
·
Sy Hung Doan
Sy Hung Doan
Nov 12, 2020

Hi, just stumbled across this post. A question came to mind after I read this post.

Why not just single functions, instead of creating new instances?

1
·
·3 replies
Maxi Contieri⭐⭐⭐
Maxi Contieri⭐⭐⭐
Author
·Nov 12, 2020

Hy Sy Hung Doan. Thanks for asking.

That would be another smell

Single functions are harder to unit test, to read, to reuse and to compose. They may be the first option, but once system gets serious they should be reified

·
Sy Hung Doan
Sy Hung Doan
Nov 13, 2020

Hi Maxi Contieri, Thanks for the prompt response. However, I am still on the fence. In my current project (React & Redux), we exclusively use (anonymous) functions as they are small and writing unit tests are just a breeze. I just feel like they've been convenient enough.

The code is well maintained from time to time, but no one talked about switching to use Class helpers.

I doubt if it's just a matter of preference or the scope of the projects. Mind if I ask for some more examples for the Problems you mentioned in the Code-smell-21? I'd be very glad to have a better view and understanding.

·
Maxi Contieri⭐⭐⭐
Maxi Contieri⭐⭐⭐
Author
·Nov 13, 2020

hi Sy Hung Doan

Some quick questions

  • How many functions are?

  • How large is the team?

  • How do you unit test it?

  • Do you have good coding names?

Can you embed an example?

·
Yonatan Karp-Rudin
Yonatan Karp-Rudin
Dec 13, 2022

Great article! a few small typos:

-the function getCategory() gets the user's score, but in its usage, you're passing the entire user object.

  • In the right example, the naming function gets userscore as the paramer, while it should (for the best of my understanding) be user.

  • Same goes for the score that in the right approach accepts userscore1 as parameter (which for me also feels a bit like a code smell as there is only 1 parameter)

·