ProFactor Software Limited

Home > Products > StyleManager > Code Formatting

Icon Free Trial

ProFactor StyleManager Your Code: Your Way.

What Is A Source Code Formatter?

Source code - just like any other document - can be well-formatted and easy to read. However, often the style and presentation of the code is the last thing on the programmer's mind when they write it. This can be something of a false economy - well-presented code is clearer and easier to read, which makes it much easier to understand and maintain.

Take for example this simple implementation of Euclid's greatest common divisor (GCD) algorithm.

Badly formatted codeStyleManager formatted code
int GCD(int a,int b)
{int r;while(b){r=a%b;
a=b;b=r;}return(a);}
int GCD(int a, int b)
{
    int r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return (a);
}

Clearly, the properly formatted routine is much easier to understand, and subsequently easier to modify and maintain.

Understandable, maintainable code saves time and money

If you work with a team with no set coding style, or if you deal with lots of third-party source code, then you've almost certainly had to work with code in varying styles. When you see code that's not in your own style, you have to spend longer understanding its meaning. If the code could be automatically reformatted into your style, you'd save time and save your concentration for more important things, and make your job easier.

There are an almost endless number of possible styles. Do you prefer to see the braces on their own line? Should they be on the same line as the keyword? Should the indent be four spaces or eight? Where should the asterisk and ampersand go when dealing with pointers? The number of choices just compounds the problem - rarely will you see the same style twice.

The solution: StyleManager

StyleManager is ProFactor Software's innovative tool for automatically formatting C and C++ source code. Choose from any of the standard coding styles or replicate your personal or company coding style using StyleManager's highly configurable reformatting engine.

Standard styles

StyleManager supports all the major coding styles - GNU, Stroustrup, Ellemtel, Indian Hill and more.

GNU styleEllemtelIndian Hill
int
GCD (int a, int b)
{
  int r;
  while (b)
    {
      r = a % b;
      a = b;
      b = r;
    }
  return(a);
}
int GCD(int a,
        int b)
{
   int r;
   while ( b )
   {
      r = a % b;
      a = b;
      b = r;
   }
   return( a );
}
int
GCD(int a, int b)
{
    int r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return(a);
}

StyleManager can reformat to these code styles and more

Check out StyleManager's key features.

< Home | Next >









(c) 2004-2017 - ProFactor Software Ltd.