When to Create a Template in C++ - dummies

By John Paul Mueller, Jeff Cogswell

The first step in creating a template is deciding whether your idea will generate a useful template. Most developers have thousands of creative thoughts that translate into ideas during their careers; however, only a few of these ideas are exceptionally useful.

By determining whether the template you want to create is a good idea at the outset, you waste less time on bad ideas and have more time to create that truly useful idea that will help you ascend to the pinnacle of development notoriety (and the astronomical amount of cash that such as position tends to generate).

Before you begin creating the next template to awe and inspire developers everywhere, consider the following questions:

  • Is there a generic template that is close enough to meet your needs? A good template idea is unique — it does something more than perform a useful task; it performs a new kind of useful task. Template ideas that fail the uniqueness test usually consume many resources for a small payoff.

  • Will you use the template more than once? Some template ideas are so tuned to a particular project that the developer ends up using them precisely once, which means that the template never provides a payback on the investment to create it.

  • Will the template save more time than you use to create it? Templates can become complex. In fact, some templates are complex enough that you’d save time by not writing them at all. The reason to use templates is to save time and effort, so a complex template tends to require a larger payback period than a simple one.

  • Is there a third-party template you can buy (or, better yet, obtain free) that nearly meets your need? Someone else may have already had your good idea. Before you invest time in creating a template, you should spend time researching online.

    Someone else may have created a template that nearly matches your idea. Obtaining a third-party template that’s close to what you want is always more time efficient than creating a custom template on your own.

  • How generic is the template you want to create? Many good template ideas are simply too specific, which limits their adaptability to other situations. You want to create a unique template, but a unique template that can meet a range of organizational needs.

  • Is your template concept complete? Developers often envision only a piece of a template. For example, if you create a math template, you should actually create a library that contains all the equations you plan to use with your applications. Designing a template that contains a single equation is never worthwhile because other developers will have to finish the work you started.

  • Do you have the skills to create the template? Not everyone is a good template designer. A template designer must define a template that goes beyond the original expectations because someone will almost certainly use the template in unexpected ways. The best templates adapt to new situations that the originator never considered. Consequently, creating a template requires a different sort of mindset than creating an application.

A little research at the outset can save significant time, effort, and replicated development. C++ has been around for a long time (at least in computer terms) so you can choose from a wealth of existing code. Always determine in advance whether the template you want to create is worth the effort and will make life easier for other developers.