4 ms·
I’m a big fan of closeness in code. I prefer defining things as closely to where it’s used as possible. This is a big pet peeve for me! Do not put regex at the
by preg_match 4mo ago
I’m a big fan of closeness in code. I prefer defining things as closely to where it’s used as possible. This is a big pet peeve for me!
Do not put regex at the top of the file either! Put it where you use it. Languages are smart, they’ll probably be able to tell that it’s constant anyway.
Also for tiny functions just use a lambda. Please don’t make a one line function a million miles away that you use once or twice.
- robotresearcher 4mo agoAmen! The existence of 'helpers.js', 'utils.cc', makes me twitch.
- deleted 4mo ago[deleted]
- what 4mo agoIf multiple things use the same regex, which one should it be close to? Or do you propose duplicating it?
- preg_match 4mo agoMy go-to is actually wrapping it in a lambda. The reason being you get nice syntax highlighting you don’t get with string literals! (In PHPStorm the string part of preg_match gets regex highlighting)