Wednesday, August 24, 2005

10 Commandments for LV Programmers


Thou shalt try thy level best to banish ‘Build Array’ & ‘Coercion Dots’ from thy program for they are the incarnation of Satan and will then do their level best to make thy life miserable on the day of delivery.
Obviously these are necessary evils, which thou cannot banish from existence but thou can definitely cleanse thy code of such unnecessary souls. Countless is the number of programmers who have gone insane in attempting to rectify the evil action, namely memory leak, of these evil incarnations. Pray thy god to allow thou to declare the data types correctly lest if thou do not have thy god’s blessings in this regard, thy code will become a breeding ground for ‘Coercion Dots’ and after that even thy god can’t save thou. Always call upon the services of the angelical ‘Replace Array Subset’ instead of invoking the devil incarnate ‘Build Array’. If thou need any help in this thou shalt consult the second prophet from India on the hardships he had to endure in a project due to this sin.

Thou shalt promise on the apple of thy eye that thou will exhaust all other opportunities before deciding to use ‘Globals’ and ‘Locals’.
These words are straight from the mouth of the first prophet from India. He had to face the wrath of the ‘Globals’ and had spent countless sleepless nights in attempting to unravel the evil web they had created around one of his early projects. The evil web will be in various forms like impossibility of debug, too much consumption of memory. Thou shalt reserve a seat for thyself and thy team members in an institute of mental health before declaring ‘Globals’ for this was an option that the first pharaoh himself contemplated after committing the blasphemy of declaring too much globals. So the same fate will befall mortals like thou.

Thou shalt not commit the heinous crime of not knowing thy library for thy brethren for this will scorn thou and thou will have to hang thy head in shame.
Thou should understand thoroughly what thy libraries promise and attempt to use them as often as possible. Libraries are special angels from the almighty and thou shalt use them to produce code that is bug free. Also these angels will greatly assist in reducing the development time and they are angels who are known to all of thy brethren. Thou will be blessed always by thy brethren for using the libraries coz it will make their job easy when they try to debug thy code in thy absence.

Before opening LabVIEW thou shalt understand that ‘Error in’ and ‘Error Out’ are like the dress on thy body. Thou shalt not venture out without thy dress; similarly thou shalt not create even a single VI without ‘Error in’ and ‘Error out’.
If thy dare for even a second to scorn the importance of ‘Error in’ and ‘Error out’ this will be noted down by thy code and they will take their revenge at the most opportune moment and will crash thy party in no time. While thou might think this VI is not going to generate error the devils will be conspiring against thou and hit thou where thou least expect to be hit. They will induce racing conditions in thy code and they will induce it in such a fashion that the racing will NOT occur in thy PC but in thy customers’ PC. So never forget to give ‘Error in’ and ‘Error out’ and never ever forget to wire them, as then the angels will bless thou so that all error conditions will pop out and no racing will occur.

Thou shalt commit right now to thyself not to fall prey to the ultimate weapon of Satan, temptation to use parallel constructs.
Satan managed to tempt Eve to eat the forbidden apple but thou, a warrior of god, shall always watch for this weapon of Satan. If it was the forbidden apple for Eve, it is parallelism for thou. It is very easy to fall prey to the temptation coz it is very easy to do so and seems to provide good answers immediately but remember these are the hallmarks of a good temptation. If thou fall pray to this, it will allow Satan to cause maximum damage to thy structure in the form of racing. This racing will give thou many sleepless nights and painful work days that thou will feel like bashing up thy PC for no fault of its. But relief is available for the discerning. If utilized with extreme circumspection thy can master parallelism in thy code and close all doors to racing, the most tormenting creation of Satan. Listen to the third pharaoh from India on the difficulties he had to endure in a couple of projects in his formative years on account of a mild form of this sin

At the outset thou shall master the art of using ‘Simulation’. Another of god’s creation that will relieve thou of the headache of testing the software with the hardware.
If ever there were a double-edged sword then this would be it. If used carefully can be such a good domestic pet but if thou, in all thy haughtiness, decide to abuse this gentle angel, thou shall face its wrath during testing. It will transform itself into a Jurassic beast and will cause untold harm to thy project estimates. If the fate of countless programmers does not convince thou not to abuse this angel then even thy prayer of repentance in the last moment will fail thou.

Be it an ‘Enumeration’ or a ‘Cluster’, even if it is used only once, thou shall save that as a type definition.
If thou do not adhere to this commandment thou will have to repent it later when thou are forced to change the structure of the cluster or add elements to the ‘Enumeration’. Though might think I will leave this project before any modifications come but thou will have to endure being abused with the choicest expletives from the person who had the misfortune of modifying thy horrible creation. Thou will be labeled a fool if thy fail to use such a simple god provided tool which will prevent survival from becoming hell in the later stages of thy project coz as by then thy LabVIEW application bereft of type definitions would have become so convoluted that it will start resembling the Gordian knot more than a Virtual Instrumentation application and thou art no Alexander.

If thou categorize inputs as ‘Recommended’ and ‘Required’ then truly thou and thy brethren are blessed else great misfortune will befall thou.
The creators of LabVIEW in all their wisdom had decided to make the inputs ‘Recommended’ by default. Though this might appear innocuous at first look, ask the poor programmer who had to wonder why his data in a ‘LV-2 global’ is getting initialized all of a sudden in the middle of an application before thou decide on the importance of this. If thy god had decided that he would endow thou with the wisdom to use this feature then thou art a truly blessed programmer. If thy god has failed to do so then thou shall try to put this into thy brain coz this is for thy own benefit. If thou decide to ignore this then let thy god help thou.

Thou shalt understand that thou are not creating a piece of art while coding for it to be abstract and thereby pose all sorts of problems to mortals from comprehending thy creation. So thou shalt create code that is clean and well commented.
If thou become too arrogant and claim that thy code is supremely self-documenting and hence does not require commenting, then thou art the biggest fool on earth coz though thou might be the pharaoh of pharaohs in LabVIEW thou brethren might not be the same. So thou shalt make thy code clean and explain all thy intelligent algorithms and the reason for following the data structure that thou have followed. Also remember comments are also part of the software, so when thou changeth the code thou shall changeth the comment. Also thou should not display thy arrogance and comment very simple operations. If thou doeth such things then thou will be scorned to no extent by thou brethren and will be banished from thy company coz thy nuisance value will far exceed thy utility.

Thou should remember coding standards like thou remember thy name. Coz any deviation from it, intentional or not, will coz thy brethren not to understand this and thou should cease to call thyself a programmer.
Thy creativity is better used in solving the problem than in finding new ways of doing simple things for which standards have already been established. While thou might think that thy idea is better than the standard thou successors might not think so. They will not thank thou for thy crime of playing with the sacrosanct standards. On the contrary, they will revile thou. If thou still feel that the standard is the creation of some useless fellow, think again. There have been pharaohs before thou who have created this in all their wisdom. If thou still think thou have to change the standard then thy god help thou in this perilous adventure. Thou have to perform the Herculean task of convincing the living pharaoh of the need of such a misadventure.


Creation of
The third pharaoh of LabVIEW in India

Parthasarathy



By
The third pharaoh of LabVIEW in India
Parthasarathy


PS:
1.) This is heavly inspired by
‘The Ten Commandments for C programmers’ by Henry Spencer
http://www.lysator.liu.se/c/ten-commandments.html
Check that link to get an annotated version of the above

2.) This was written by me less than a year ago while I was working in LabVIEW in Soliton Technologies www.solitontech.com .

3.) LabVIEW is proprietary software of National Instruments. To know more about LabVIEW, check out www.ni.com

2 comments:

Partha said...

The three pharaohs are the first three people in India to become Certified LabVIEW Developers.

1.) A.Senthilnathan - Project Leader at Soliton Technologies
2.) K.T.Kumar - Project Leader at Soliton Technologies
3.) Yours truly

pagala'k' said...

Cool man...sorry Cool Pharoh