Is it time to abstract this?

You spot two things in your app that are mostly the same. Is that an automatic refactor?

Joel Clermont
Joel Clermont

It is so tempting to try to abstract something earlier than necessary. I catch myself doing it all the time.

For example, we had a Vue component that showed a list of records, allowing multi-selection, and then some commands on the selected items like export, archive, etc. We had two different types of records to show in this way. It seemed like a good thing to abstract, but instead we kept them separate for now.

We knew we could always revisit and combine later when we need a third record type, or maintenance becomes a chore.

Looking back, these particular components have been kept separate for almost 6 months now, and we're just starting to reconsider if it's time to refactor. If we do decide to abstract into a common component now, did we waste all that time?

Not really. Sure, it might have been a little more maintenance friction these months as the app evolved, but we also gained deeper insight into what users need from this component and more intricacies of how the data differs between these two record types.

Next time you're building something new, and get that itch to abstract, take a second and think it through.

Here to help,


P.S. Do you have an architectural question you're wrestling with? An outside perspective can help you get unstuck.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.