No Compromises artwork

No Compromises · Joel Clermont and Aaron Saray

Stop doing math in your config files

Ever feel the urge to write out calculations in your code to make them "self-documenting"? In the latest episode of the No Compromises podcast, we discuss why inline math in configuration values is a habit worth breaking. Aaron argues that if a value never changes, there's no reason to calculate it every time. A well-placed comment can explain how you got the number without the unnecessary overhead. We also cover how comments can clarify units like seconds versus milliseconds, why this thinking applies beyond config files, and how questioning small habits can improve your code overall. (00:00) - How many seconds is five minutes? (01:45) - The problem with inline config math (03:45) - Using comments instead of runtime calculations (05:30) - Why questioning habits improves code (07:00) - Silly bit Want a second set of eyes on your Laravel project?

Jan 312026
9 minlength
70transcript lines
Publishertranscript source

Transcript first 15 of 70 lines

0:00JoelWelcome to No Compromises. A peek into the mind of two old web devs who have seen some things. This is Joel.

0:08AaronAnd this is Aaron. I might go on a little bit of a rant here, Joel. But I want to talk about something that bothers me, but I think that there's an actual good thing behind that we can pull out and make our projects better.

0:28JoelOkay.

0:30AaronAnd it is that... well, let me phrase it a different way. How many seconds is 5 minutes?

0:37JoelWhat? I didn't know there'd be a test here. 300 seconds in 5 minutes. I'm a math genius.

0:44AaronAwesome. So, let's just say you wanted to set a timeout for 300 seconds inside of a config in Laravel, or something like that. You want to set it 300. And it accepts its values in seconds, and you want it to be 5 minutes, and that's what the business has said.

1:01Like, "We want a 5-minute timeout," or whatever. So, you need to put number of seconds in there. How would you do it? Would you put 300 seconds, or would you put-

1:12JoelOh, okay.

1:14Aaron... 5 times 60.

1:16JoelOh. I would definitely do 300, but I see where you're going with this. I might change my answer if it was something more bizarre, like the number of seconds in a year.

1:28AaronExcellent. Cool. I started out really simple, just because it should seem pretty obvious when we're doing 5 times 60. It should be just 300. Just put 300 there.

1:36But if you're talking about the number of seconds in a year, again, why would I need to calculate that if I've already done it once? So, let me get to the basis of my point here. I hate math inside of config values.

1:49JoelOh.

1:51AaronInside of config files, inside of config values, all that stuff. There is absolutely no reason to do that if that value never changes. Just because it's easier for you to understand when you write it doesn't mean that we necessarily have to have this logic happen every single time that we run it.

2:03So, when I look at something like that, even the number of seconds in a year, no idea how many there is. But I know one way I can figure it out, I can use my calculator and figure it out. It'd be like, I don't know, 60 seconds times, I don't know, how many minutes, how many days, years, whatever.

More No Compromises episodes →