DEV Community

loading...

Discussion on: Do you have a process for naming things?

Collapse
itachiuchiha profile image
Itachi Uchiha

I was working on a project.

Our ex-developers created a stored procedure called "getAllUsersByInvoiceAndNonZeroInvoicesWithNonNullCustomerNamesAndBalanceBiggerThanZero".

It was in the Turkish language. I only translated into English.

Is this kind of naming good? Because there was also a method with this name in the backend project.

Collapse
adam_cyclones profile image
Adam Crockett

And the award for the longest most descriptive name goes too... Seriously though, there are situations where names like this cannot be reduced, perhaps at that point get another opinion. Perhaps a set of more generic things composed to do whatever that did would have worked better, but who knows.

Collapse
matmooredev profile image
Mat

This reminded me of a talk I saw recently where the presenter suggested that if a method name has words like "And" or "Or" in it, that tells you that the method has too many responsibilities.

I think in this case the long name tells me that the procedure is not working as an abstraction. The implementation is leaking into the name, so you may as well inline the implementation into the calling code.

To put it another way, the name tells me how the procedure does what it does, but not what the result represents or why I should call it.

It's also quite inflexible because if I added another condition I would have to change the name as well, even if the overall purpose of retrieving this data hasn't changed. The change would impact all of the code that calls the procedure.

If these users actually represent something meaningful to the domain you're working in (maybe something like "customersWithOutstandingInvoices") then renaming it would make the procedure more useful, because the calling code can describe a business process at a high level and the stored procedure has the responsibility of ensuring the correct set is returned.