One of the most powerful and useful patterns I have come across is one we will call rinse and repeat.  It may also be seen as copy and paste or templates.  However, the result is a way to rapidly generate a lot of similar solutions within an architecture or system.

The Rinse And Repeat Pattern Defined

The essential piece of the rinse and repeat pattern is a similarity in approaching a series of problems.  This pattern becomes apparent when we solve a problem and then move on to another very close in its structure. For example, the classic almost anti-pattern of a class full of getters and setters can use this pattern.  You build a list of attributes, build out the getters and setters, then rinse and repeat across the other container objects.

That is an elementary example of this pattern.  We re-use the similarities from solution to solution as a starting point, then customize.  The best part of this pattern is using a senior developer to solve the problem and then pass on the rinse and repeat portion to junior developers.  Thus, we get a high-quality solution quickly and cheaply. 

Applying The Pattern

The way to use this pattern is to isolate the areas that are the same from iteration to iteration.  Then set up a pattern for implementing the differences.  This may be a very rudimentary bit of work or could be something more complex like data mapping requiring business analysis.  The goal is to make the work easy to estimate and repeatable.  That allows us to tightly define the rinse and repeat actions while also understanding the effort typically involved.  We then can do the work or farm it out with our detailed requirements and deliverables easily shared.

Challenges

Similar but not equal can be a trap.  It is not uncommon for a rinse and repeat process to stumble across an outlier of some sort.  That outlier can cause a substantial change to the approach or solution and break the ability for someone to quickly produce another iteration of the solution.  The good news is that we still are not likely to do more work than would normally be required.  We just need to adjust our estimates for an unforeseen chuck of extra work.

Rob Broadhead

Rob is a founder of, and frequent contributor to, Develpreneur. This includes the Building Better Developers podcast. He is also a longtime student of technology as a developer, designer, and manager of software solutions. Rob is the founder of RB Consulting and has managed to author a book about his family experiences as well as a few about becoming a better developer. In his free time, he stays busy raising five children (although a few have grown into adults). When he has a chance to breathe, he is on the ice playing hockey to relax.

Leave a Reply