I think most would agree that copy and paste as a solution to reusability is an anti-pattern, so isn't copying and modifying a "Gulp Recipe" the same thing or am I missing something?
2 Answers
No.
It is an anti-pattern if you don't understand what you are copying.
Gulp is a build process meant to process files using the stream pattern, it is ok to repeat code inside tasks most of the time, but not if you are doing lots of stream processing and repeating the code that does that processing.
Grunt, in other hand, is configuration based. Instead of repeating code you abstract them in the tasks and just configure them. That make custom tasks internal code repetitive, and you end up repeating a lot of boilerplate code in different tasks to do something slightly different.
I am not the best authority to answer regarding gulp, but at least I understand the concept and difference between the two build tools. In the end you can use any recipe, but you have to understand the meaning of it and how it works.
The anti-pattern is throw a recipe, manually test, test, test, if it works then let it be. A good pattern is read the code; if you can, implement your own; otherwise copy, understand, and modify what you have to; if it fails, go to the bottom of why it fails and understand it, so it won't happen again.
An anti-pattern is putting your gut over the reason, instead of the reason over your gut.

- 2,365
- 4
- 33
- 69
-
So if you do understand what's a good way to make it NOT an anti-pattern if say you frequently run into a situation where you would want to use that recipe? – Resist Design Oct 27 '14 at 15:09
-
I don't understand, can you elaborate? – Fagner Brack Oct 27 '14 at 18:23
-
That's basically what I was asking you to do :) – Resist Design Oct 28 '14 at 02:21
-
I did not understand what you meant by " if say you frequently run into a situation where you would want to use that recipe?". What exactly is the question? I edited the answer, hope it is clearer. – Fagner Brack Oct 28 '14 at 11:48
-
Makes some good sense, thanks for adding more. I guess it's an anti-pattern as much as copying and modifying a project config is an anti-pattern. So maybe a having them in a repo is good enough for now. :) – Resist Design Nov 02 '14 at 15:27
-
I added a sentence in the end of the answer about the gut that simplifies what I mean, hope it helps. – Fagner Brack Nov 02 '14 at 20:52
Recipes aren't a collection of tasks to be used as lego pieces for composing a gulpfile: doing so you'll end up loosing the "streaming" philosophy who drives the gulp creation because most of those tasks have their own gulp.src i.e. they are creating new streams reading their content from disk.
So I often start a new gulp file copying and pasting the Incremental rebuilding, including operating on full file sets recipe but then I end up changing it inserting ideas i read in other recipes not directly their code.

- 1,863
- 20
- 21