DEV Community

loading...

Discussion on: Write better code and be a better programmer by NEVER USING ELSE statements

Collapse
mcsee profile image
Maxi Contieri

Wow !

Nice article!

I think we should avoid ELSE and also IFS

I like the extract you made on your function. I don't know why you call them helper. Who are they helping ?

Thank you for your article

Collapse
dglsparsons profile image
Douglas Parsons Author

Hi, thanks for reading - I'm glad you enjoyed the article. I'll definitely give yours a read too :).

You're right about calling them helper functions - I think it's a kind of industry standard term (or at least it is here), for separating out pieces of logic into plain functions. As for who they help... I'm not sure either. Probably us developers :D

Collapse
mcsee profile image
Maxi Contieri

Yes. I'm aware of that

But I think we are wrong. Calling something a 'Helper' is a code smell of a real world entity we are too lazy to find.

Here are some reasons not to use that name.

Thread Thread
dglsparsons profile image
Douglas Parsons Author

Arguing with standards or convention is a difficult line to take though.
e.g. why are most keyboards in a QWERTY layout? - it's an outdated convention from when typewriters would jam, but that doesn't mean keyboard or laptop manufacturers should deviate.

I've not come across a different terminology for a helper function personally. Calling it just a function could suffice but doesn't make a succinct point. As long as it's widely understood, I think it's okay - coming up with a different term could just cause more confusion.

Thread Thread
mcsee profile image
Maxi Contieri

Agreed with the standard part

I'm not suggesting replacing Helper with another standard.
I'm suggesting to change every helper to an intention revealing name according to the domain

in your case I think charitiesByCampaignAndCountry(campaign, country) is a very good name related to domain. But it is not a helper :)

Thread Thread
dglsparsons profile image
Douglas Parsons Author

I'm absolutely agreed with the names of the functions. Although I'd argue that as a concept, the function is still a helper 😜 (insofar as it's separating out the logical act of getting charities from the specific invocation of it).