Wednesday, 2 March 2011

Golden Rule

I contacted a few people who are into the core IT industry and asked them for a few tips to write a good program.Most of them gave the same tip and I found it really interesting.But before I tell you guys about the tip I would like to share with you guys some of my tips.

  • Keep the logic of the program "Simple".
  • Before you write down the program or a section of a huge code always "visualize" your output.
  • Start "Indenting" your programs.
Let me explain you what Indenting is.It a very simple method
by means of which you shall never forget your closing brace or any other brace.It will also help you to understand your program better.
eg:
Without Indentation
class Demo
{
public static void main(String args[])
{

int x=0;
if(x>0)
{
System.out.println("Hello World");
}
else
{
System.out.println("This is a demo program");
System.out.println("Hello World");
}
}
}


With Indentation


class Demo
{
     public static void main(String args[])
     {
           int x=0;

           if(x>0)
           {

                 System.out.println("Hello World");
           }

            else
            {

                  System.out.println("This is a demo program");
                  System.out.println("Hello World");           
            }
     }
}





I think you all must have understood what I mean by indentation.All you have to do is leave some space after you open a bracket and continue writing leaving that much space till you close that particular brace.Once I shall start posting programs you shall understand better.


AND now the GOLDEN RULE:


  • ALWAYS DEVELOP YOUR CODE CONSIDERING THAT YOU ARE THE CONSUMER.
  • DEVELOP IT THE WAY IN WHICH EVEN A PERSON WHO DOES NOT NOW MUCH ABOUT COMPUTERS IS ABLE TO USE IT WITHOUT ANY PROBLEMS.

No comments:

Post a Comment