Classy headings in your code with ASCII art

Sometimes source code modules get very big. You can argue that this should never be the case, if you modularize your code properly, but the fact is that they do. And when they do, they sometimes become difficult to read.To make the code more readable, we add headings. There are numerous conventions to add comments to code so that you can easily see where a new section begins. In ABAP, it is common to use a line of dashes or asterisks, and sometimes a block of comments will be surrounded by such lines so they are easily spotted. (In fact, if you type “*–” or “***” in an ABAP editor at the beginning of a line, the keyword completion will offer to complete the line with such comments).

However, sometimes pieces of code get very long so that you end up having sections and subsections, all of which can be difficult to tell apart, especially once you end up lining your comments with rows of asterisks or dashes.

Here though, is a very nice way, if you have enormous blocks of code, to make them really stand out. You can generate a piece of ASCII art using an extremely handy site that lets you input a piece of text and select a font (really a style), amongst other settings, and then spits out your words in ASCII art. The site is hosted here: http://www.network-science.de/ascii/

The following code, for example, is adorned with the “ogre” font from the given site:

Using this technique, you can separate long sections of code with such attractive comment headings that are easy to find.

You may also be interested in:

Tags: , ,

  • Ken Kirby

    We do seem to think along the same lines. I’ve been using http://patorjk.com/software/taag/ to generate ascii art comments – I especially like the font “ANSI Shadow” – really stands out.

    Also – sorry I never got back with you regarding your Solr source code search – your solution was brilliant – but my client didn’t want an instance of Solr. I mashed up indexing on TREX with your front end and now the other developers are searching away. I’m going to move that to HANA to get a bit of experience with text indexing there.

    Ken