52 likes
·
2.1K reads
6 comments
From all the beasts, helpers and utils are the most uncouth.
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?
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
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.
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?
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) beuser
.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)