Yup. You read right. Over the years, we have experienced that many programmers struggle to communicate the code they have written to other people. Especially designers and managers. So we took on some creative glasses and gave the feature a second look. After a thorough review of the Pascal parser and a structured review of how we communicate program snippets during lectures, we came up with something brand new and spectacular. An Object Pascal to Human readable documentation compiler. Codename OP-2-HRD-C++. (We added the ++ in the compiler part of the abbreviation to get more google hits).
“Show me the code!”, you say? OK, Here we go:
In (almost) every project you have ever written, you have some custom data types. Right? Well, describing this to someone non-technical can be tedious, difficult and boring. With this new feature, you can just compile to “human readable documentation” and hand over the generated pdf-file.
TPerson = record
TPersonArray = Array[0..9] of TPerson;
is compiled into:
[quote]In this project we have two data-types. We have a record named TPerson, and an array that can hold 10 elements of TPerson. The array is named TPersonArray. The TPerson record holds Name in a string field (unicode characters are supported), and Age in an integer field, which means that you can register values from -2147483648 to 2147483647 in this field.
Isn’t that just brilliant?
We actually have some output options with this compiler feature, so it’s possible to specify if the target is “to designer”, “to programmer” or “to manager”. If you, in this case, choose “compile to programmer”, you will get some useful additional information about that array:
[quote][…]The array is named TPersonArray and it’s zero-based – so be careful with any off-by-one mistakes![…]
We’ll give you another example with a control statements:
if (Person.Name = ”) and (Person.Age = 0) then
ShowMessage(‘The record is empty.’);
Is compiled to:
[quote]The program will then show a message saying “The record is empty.” if, and only if, the Name field of the Person record is empty and the Age field of the Person record is 0.[/quote]
Now, for a loop like this:
for x := PersonArray.Low to PersonArray.High do
Console.WriteLn(‘The name is ‘ + PersonArray[x].Name);
you will generally get an output like this:
[quote]The program will then enter a loop that iterates trough each items in the PersonArray variable. For each iteration, the text “The name is ” will be written to the console along with the Name field of the record that is contained it the current array element.
But! We have actually added some nice compiler magic to the OP-2-HRD-C++ compiler.
So, if you try to compile this snippet:
for x := PersonArray.Low to PersonArray.High-1 do
for y := PersonArray.Low+1 to PersonArray.High do
if PersonArray[x].Name < PersonArray[y].Name then
You will actually get this “to manager” output:
[quote]The program will perform a bubble sort on PersonArray. The bubble sort algorithm is very simple and not very efficient. The management should add a few hours of refinement and optimization to this method…
Pay particularly attention to the request for more time to programming. We strongly believe that the management will allocate more budget to the programming task if they are faced with serious computer-generated concerns like this!
If, however, the documentation is intended for programmers (i.e. yourself), then we’ve added a friendly reminder:
[quote]The program will perform a bubble sort on PersonArray. WTF!? A bubble sort algorithm?! Is this a school project or something? You’d better clean this up before someone else sees it. What if Nick Hodges will review this code in the future?
We hope this new feature will make the everyday life of a programmer better.
The Smart Mobile Studio Team