Differentiating Between CSS Boilerplate, Template, and Frameworks

You often see the terms boilerplate, template, and framework uses almost interchangeably online when people discuss CSS. In fact, some readers are confused about these terms and have written me about them. There are distinct differences between the three terms and you really do need to know what they are.

Boilerplate is code that you can simply cut and paste to use in an application. As an alternative, you can simply import the file that contains the boilerplate code. However, boilerplate code is designed to perform a specific task without modification in your application. Someone else has written code that performs a common task and you simply borrow it for your application (assuming they make it publicly available). It would be nearly impossible to create a complete application using just boilerplate code because it’s inflexible. Developers often stitch multiple sources of boilerplate code together to perform specific tasks, but then add custom code to the mix to customize the output.

Templates, like boilerplate, provide a means to reuse code, but the implication is that the code is modified in some way and that it’s also incomplete as presented. Yes, the template may provide a default presentation, but the default is usually bland and simplistic. Using templates makes it possible to create a customized appearance without writing a lot of code. Of all the readily available code categories, templates are the most common. Template makers also commonly create wizards to reduce the time a developer needs to employ a template even further. The downside to templates is that they do require some level of skill and more time to use than boilerplate.

Frameworks can be viewed as a container for holding other sorts of code and presenting it in an organized manner. However, a framework still consists of modifiable code. The difference is that a framework will commonly control the layout of a page, rather than the appearance of content it contains. Developers commonly combine frameworks with both templates and boilerplate to create a finished site. In general, frameworks always rely on a wizard to make creating the site easier.

Using the correct term for the kind of code that you’ve created makes it easier for others to know whether your solution will help them. In many cases, developers don’t want to be bothered with details, so boilerplate is precisely the solution needed. At other times, management has decided that a site with a perfectly usable framework needs a new look, so the developer may want a template to create a customized appearance within the existing framework. There are still other times where a new layout will better address the needs of site users, so a new framework is required.

Precise terminology makes it possible for people to communicate with each other. The creation and use of jargon is essential to any craft because precision takes on new importance when describing a process or technique. Developers need to use precise terms to ensure they can communicate effectively. Do you find that there is any ambiguous use of terminology in my books? If so, I always want to know about it and will take time to define the terms better in my blog. Let me know about your terminology concerns at John@JohnMuellerBooks.com.

 

Using CodeBlocks 10.05 – Part 6

This post is a continuation of the series that began with Using CodeBlocks 10.05 – Part 1. The purpose is to help people use CodeBlocks 10.05 with C++ All-In-One Desk Reference For Dummies, which is currently written to rely on CodeBlocks 8.02 (which is actually the previous edition, despite the odd numbering disparity). You can find a complete list of these posts in the C++ All-in-One for Dummies category archive. This post starts with a review of the updates for the source code found in Book IV Chapter 5.

There is a section entitled, “Templatizing a Function” that begins on page 528. You can see the code for this example in \Author\BookIV\Chapter05\FunctionOverloadingAndTemplates. The initial example is designed to fail, as explained on page 531. You’ll see the same error message and recommendations for both versions of CodeBlocks. In order to see this example work, you must comment out the line that reads:

cout << AbsoluteValue(10.5) << endl;

by highlighting the line of code and pressing Ctrl+Shift+C or by choosing Edit > Comment. Of course, you can simply add the comment manually by typing // at the beginning of the line. You must also comment these two functions out:

int AbsoluteValue(int x)
{
    if (x >= 0)
        return x;
    else
        return -x;
}
 
float AbsoluteValue(float x)
{
    if (x >= 0)
        return x;
    else
        return -x;
}

After you comment these lines out, you can uncomment the templated version of the function:

template <typename T> T AbsoluteValue(T x)
{
    if (x >= 0)
        return x;
    else
        return -x;
}

by highlighting the required lines of code and pressing Ctrl+Shift+X or choosing Edit > Uncomment. In addition, you must uncomment these lines of code to exercise the template:

cout << AbsoluteValue<int>(10) << endl;
cout << AbsoluteValue<float>(10.5) << endl;

At this point, the example will compile and run as expected. You’ll receive the same results in both CodeBlocks 8.02 and 10.05. Because so many people have complained about this particular example, I plan to provide two completely different source code files for the next edition of the book (so it won’t be necessary to comment/uncomment anything). Even so, the lines you must uncomment are clearly marked in the current source code file. The example found in the \Author\BookIV\Chapter05\ImFree folder requires similar commenting and uncommenting to see the full potential of the example, but this example doesn’t produce an error at the outset. The other examples in this chapter should work precisely as expected.

On to Book IV Chapter 6 (the last chapter in this mini-book). On page 555 you see Listing 6-8, which contains the code for \Author\BookIV\Chapter06\Sets2. This example won’t currently compile properly and you’ll find the explanation on page 557. In order to run, you must add another library, algorithm, to the group so that the list of includes looks like this:

#include <iostream>
#include <set>
#include <algorithm>

All of the other examples in this chapter run in CodeBlocks 10.05 without a problem on my system (let me know if you experience any problems on your system). In the next post I’ll start
with Book V Chapter 1. In the meantime, let me know if you have any
questions about the CodeBlocks 10.05 updates for this book at John@JohnMuellerBooks.com.