Apex Code Best Practices
Apex Code is the Force.com programming language used to write custom, robust business logic. As with any programming language, there are key coding principles and best practices that will help you write efficient, scalable code. This article illustrates many of the key best practices for writing and designing Apex Code solutions on the Force.com platform.
1: Bulkify your Code
2: Avoid SOQL Queries or DML statements inside FOR Loops
3: Bulkify your Helper Methods
4: Using Collections, Streamlining Queries, and Efficient For Loops
5: Streamlining Multiple Triggers on the Same Object
6: Querying Large Data Sets
7: Use of the Limits Apex Methods to Avoid Hitting Governor Limits
8: Use @future Appropriately
9: Writing Test Methods to Verify Large Datasets
10: Avoid Hardcoding IDs
for reference please go through this link.