16/12/2013: 10 Best Practices of programming from CodeSpread

bestpractice
bestpractice

16/12/2013: 10 Best Practices of programming from CodeSpread

We love programming and having a knowledge of best practices always helps in writing beautiful code. Here, we have few best practices shared by professionals.

Best Practice#1, Use foreach loop instead of for loop wherever required.*

Best Practice#2, To make your file compact, right click on namespaces and select remove unused strings. It will remove all the unused namespaces, which are not used in your code anytime.

namespaces-best-practice

namespaces

Best Practice#3, Create a separate config for connection strings and include it in web.config.

Best Practice#4 , Dispose unmanaged objects explicitly for ex: COM Objects

Best Practice #5, Create automatic properties and use either get or set, try to avoid both get and set together, if not required.*

Best Practice #6, Never append your stored procedure with ‘sp_’ as it might be treated as a system stored procedure and will lose its scope.

Best Practice #7, Please write each SQL verb on a new line as shown in the image.

sql-verb

sql-verb

 

Best Practice #8, During Exception Handling, Always use finally block to clear the objects while using try catch blocks.

Best Practice #9, Streaming interfaces, like XmlTextReader, give better performance and scalability, compared to loading large XML documents into the XmlDocument or XPathDocument classes and then using DOM manipulation

Best Practice #10, Keep EnableViewState Property as false for the page and enable it only for the required controls. It will minimize the page size.

*Conditions Apply

Author: hershey

A passion for knowledge drives me to do programming, A passion for programming drives me to create something different, A passion for creation drives me to spread the knowledge.

Share This Post On

1 Comment

  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

More from CodeSpread:

  • 18/12/2013: 10 Best Practices of programming from CodeSpread(21-30)18/12/2013: 10 Best Practices of programming from CodeSpread(21-30)We love programming and having a knowledge of best practices always helps in writing beautiful code. We have shared first 20 random best practice in our previous articles 1-10, 11-20. More best pra...
  • 17/12/2013: 10 Best Practices of programming from CodeSpread(11-20)17/12/2013: 10 Best Practices of programming from CodeSpread(11-20)We love programming and having a knowledge of best practices always helps in writing beautiful code. We have shared first 10 random best practice in our previous article here, now we are sharing fe...
  • 24/12/2013: 10 Best Practices of programming from CodeSpread(31-40)24/12/2013: 10 Best Practices of programming from CodeSpread(31-40)We love programming and having a knowledge of best practices always helps in writing beautiful code. We have shared first 20 random best practice in our previous articles 1-10, 11-20, 21-30. More b...
  • Tip : Code Structure C#Tip : Code Structure C#As a developer, I always stress on developing a habit of following the best practices to structure the code. It helps me to easily navigate through the code and also saves a lot of effort in search...
  • 23 Dec: Must Read Codes [11-15]23 Dec: Must Read Codes [11-15]We are sharing few must read codes/concepts which are required now and then. Each of these codereads doesn’t require a full length descriptive article so combining them into groups of five. CodeRe...
  • Concepts: S O L I DConcepts: S O L I DSOLID - Object oriented programming principles. May be its easy to forget these principles  but for creating a reusable code or maintainable code, people will always have to come back and check ...
  • Asp.Net: More about CookiesAsp.Net: More about CookiesWe have seen, how our cookies looks in our last article Cookies Part 1. In this article, we will talk about their properties,limitations and technical part. Properties and Limitations Cook...
  • Agile Encounters UnpredictabilityAgile Encounters UnpredictabilityWhat is Agile? Wikipedia says “Agile software development is a group of software development methods based on iterative and incremental development, where requirements and solutions evolve through...