526Part IIIAdvanced Features and TechniquesIndenting, whitespace, and line (Affordable web design)
526Part IIIAdvanced Features and TechniquesIndenting, whitespace, and line lengthCode is much easier to read if you use indentation to indicate the relationship among lines ofcode that are tied together in a common functional block, as well as whitespace to logicallygroup elements. The following code is hard to read, though it will run perfectly fine. switch ($flag) { case 1: doWork(); break; case 2: doOtherWork(); break; default: doNothing(); break; } On the other hand, this code: switch ($flag) { case 1: doWork(); break; case 2: doOtherWork(); break; default: doNothing(); break; } is both functional and more easily understood. Spotting syntax errors is hard enough; don tmake the job harder by clumping your code together sloppily. One of the big religious arguments in programming is the number of spaces to indent eachnew code block some people insist that two saves space, others swear by four, and someoutliers actually employ eight-space indents (the horror!). Over time and in groups, four hascome to be a standard compromise position, adopted by many open source projects including PEAR. If you want your code to be accepted into PEAR, it must use four-spaceindents. Because different editors on different platforms interpret tab characters differently, it s rec- ommended that you use groups of four space characters in all places you would, under othercircumstances, use a tab character. Formatting control structuresControl structures like if, if/else, if/elseif, and switchstatements can be confusingif not properly formatted. PEAR has recommended styles for all of these language constructs.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision j2ee hosting services