DEV Community

Cover image for Don't Write Utils: how to become an amazing programmer by naming carefully

Don't Write Utils: how to become an amazing programmer by naming carefully

Douglas Parsons on December 01, 2020

I hate the word ‘utility’. It says absolutely nothing. And yet, I come across it in so often when programming. It can take different guises too: ‘c...
Collapse
 
scroung720 profile image
scroung720

I have read multiple articles of this kind, where colleagues are blaming specific practices. I believe that the root problem here is that engineers do not work as owners of their projects. Every time a programmer touch a code base is an opportunity to improve code quality which is a hint for spotting junior developers.

A real senior developer should detect when the garbage is piling up and fix it. Even if management does not want to allocate time doing refactor. I would prefer to get fire for doing the correct things than blindly accepting all requests from management pretending that our codebase is healthy.

The rule of the boy scouts is: “Always leave the campground cleaner than you found it”.

Collapse
 
alvarezgarcia profile image
Alvarez García

Good luck with that if you have a family.
Be real, sometimes you will have time and sometimes no.
Part of the seniority is based on social skills that will convince management.

Collapse
 
scroung720 profile image
scroung720

That is our duty as professionals. The best programmer I've ever worked with once told me every time product/management/client is taking the wrong decision and you let that happen, you are failing as a professional programmer.

Many colleagues do not think in this way but we should start to see this like a patient saying to the doctor they do not want this or that treatment because they do not like it. It is our responsibility to inform the people that pay our checks that they are going against their self-interests.

Thread Thread
 
dglsparsons profile image
Douglas Parsons

I think it's a nice ideal.

In practice, though, sometimes it takes too much time to achieve this.
Sometimes it's a battle that can't be won.
Sometimes you need the job more than you need to fight this fight.

And also, some people don't like having these kinds of conversations too, and that's fine.

Collapse
 
mcsee profile image
Maxi Contieri

Be a boy scout like Bob Martin

It is our code base, even tough we inherieted it

Collapse
 
dglsparsons profile image
Douglas Parsons

This is absolutely true. I just feel utils or shared code is a particular flavour of garbage I feel people are often blind to, or unaware of.

Collapse
 
alainvanhout profile image
Alain Van Hout • Edited

My question would be: say you hadn't added that single directory. Would the code have been in perfect shape a year later? From what you describe, I doubt it.

Collapse
 
dglsparsons profile image
Douglas Parsons

It absolutely wouldn't be. You're right. There's far more factors to it than I've put into this article - it's more than this one thing was an accelerant of sorts. A nasty trap I opened that all the engineers fell into.

Was it the only trap? No.
Will I be more aware of it in the future? Absolutely.

Collapse
 
jennrmillerdev profile image
Jen Miller

ahhh...yes... the util package. It's like the 'everything' drawer.

Collapse
 
dglsparsons profile image
Douglas Parsons

It really is. You look away for two minutes and it's full of flat batteries, pens that don't work and random scraps of paper.

Collapse
 
mcsee profile image
Maxi Contieri

Lovit !

I can almost see the shared floodgates

Here is my own opinion on "utils"

Collapse
 
dglsparsons profile image
Douglas Parsons

This is a great post. Thanks for sharing. Absolutely hits the same notes.

I've used the comparison to a standard library before when arguing against helpers or utils.

If you look at a programming languages standard library (e.g. golang.org/pkg/), everything has a clear point and purpose, there's no helpers or utils, and yet the code there is for the most reuse possible.

Collapse
 
graystrider profile image
GrayStrider • Edited

I don't see a problem with having a utils auxiliary package, as long as it's contents are properly organized and documented.