You must Sign In to post a response.
  • Category: General

    How to do quality code check

    Hi There,

    I am in need to do quality code check. Can anyone please let me know what steps should i follow or is there any tool which can do quality code check and provide us issue along with possible solutions?
  • #760791
    There are few things you can do for the quality of code, i am not sure about any tools for that.

    According to me Quality of a Code means two types,
    a) How a Programmer can understand the code
    b) How fast is your codes execution

    for the first point do the steps
    1. Format the document so that you can understand each blocks fully
    a. Ctlr+E , Ctrl +D for C#
    b. Ctrl+k, Ctrl+D for html, asp.net , CSHTML
    2. Use Comments where ever needed.
    3. Use easily understandable names for classes and objects
    4. If you can give obj<ClassName> (objStudent) for objects and lst<ClassName> for lists; then it is easily understandable.
    5. if string variable is starting with str<someName> then it is more good. Make a common strategy for commonly used datatypes.
    6. if it is asp.net, use txt<name>,lbl<name> for the controls. Make a common strategy for the grid, radio button etc.
    7. in C# and VB.Net, there is something called Regions. Use that.
    8. Try to give good and meaningfull names for the functions/methods
    9. it is better to give a one line comment for a function to understand why that function is created.


    for the second point, do the following steps
    1. Try to Declare all the variables in the starting of a method but initilize only in the place where you need it.
    2. Use try / catch/ finally blocks and dispose all the variables other than the return variable in finally block
    3. Dont Declare a variable inside a for loop, as it will allocate more memory.
    4.Better declare a variable outside the loop and initilize it inside the loop.
    5. try to avoid multiple if, use switch
    6.try to avoid multiple for loops.
    7. try to use linq
    8. Assigning the object variable like this is also good
    UserRoleVM obj UserRoleVM = new UserRoleVM()
    {
    UserRoleName=objRole.Name,
    UserRoleDescription=objRole.Description
    };

    i think this will help you

    Do Good... Enjoy your life.....


  • Sign In to post your comments