Best Practices to Write Visualforce Pages:
Ø
Do not hardcode picklist in Visualforce Page, include them in the Controller instead.
Ø
Javascript & CSS should be included as Static Resources allowing the browser to Cache them.
Ø
Reference CSS at the top and Javascript at the bottom of the Visualforce Page as this provides faster page loads.
Ø
Mark Controller Variable as Transient if they are not needed between server calls. This will make your page load faster as it reduces the size of View State.
Ø
Use <apex:repeat> to iterate over large collections.
Ø
Use the Cache attribute with the <apex:page> component to take advantage of CDN Caching when appropriate.
Best Practices to Write Test Classes:
Ø
Use a consistent Naming convention using Test and the name of the class being tested.
Ø
Should use the @isTest annotation.
Ø
Test method should create all the Test Data needed for the method.
Ø
Use System.assert liberally to prove that the code behaves as expected.
Ø
Write Test Methods for both Pass & Fail for certain conditions and test for Boundary conditions.
Ø
When testing for Governor Limits, use Test.startTest and Test.stopTest and the Limit Class instead of hardcoding Governor Limits.