DEV Community

Discussion on: Code snippets or nah?

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I never use snippets. I prefer to invest time in avoiding repetition rather than making it easier. Not to say I never do anything repetitive. @alephnaught2tog mentioned snippets for common HTML combinations, which could save time. But I also try to avoid getting too invested in my tools.

Collapse
 
andrewchou profile image
Andrew Chou

That's how I generally feel about it. Though I can see how avoiding repetition could be difficult to avoid when working on something all day every day

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I think this is somewhat of a personality preference, too. I am a builder rather than a maintainer, so I would never be happy in the long term working on something where snippets were the right tool for the job.

Although I guess you could say helper functions are like snippets. They streamline common combinations of code. A lot of the infrastructure code I've made reads like a DSL and uses helpers for common things. However, they are just reusable code rather than something in an outside tool.

Collapse
 
alephnaught2tog profile image
Max Cerrina

Yeah, as I think about it more too, I feel like the vaaaaaaaaaaaaaaast majority of snippets I actually use are either hyperspecific and temporally bound (ie a formatting thing for a specific class requirement) or HTML hunks where there is pretty little there in terms of flexibility anyways.