Want to become a “Great” Force.com Developer? One does not become a successful App developer just by training or mere experience. Many of our clients for whom we are developing the Appexchange Apps ask – “We want a Great Force.com Developer”. What makes a Force.com developer great? and other developer not so great. From our experience of over 100 person years of development we realized that to be successful or a great developer you have to learn from the best practices – and Force.com developers are no exception.
There are some best practice habits that we have seen in all successful Force.com developers. In this post we will be listing these habits that make a developer – “Great†Force.com developer.
- They check if they can use declarative methods before starting to write code.
- Successful Force.com developers keep the code simple by keeping it clean anc concise.
- Do not put the SOQL queries in the loop otherwise it will hit the Salesforce.com limits. Developers should use Maps or relationships to have one SOQL query outside the for loop.
- Use Maps to make SOQL queries, DML transactions, and Apex triggers more efficient
- Use the object relationships to optimize the queries.
- Avoid DML operations like insert, update, delete, undelete, merge inside the loop.
- Bulkify the code to making sure the code properly handles more than one record at a time
- Use utility or helper methods are efficiently written to handle collections of records. This will avoid unnecessarily executing inefficient queries and DML operations.
- Use collections and streamlining the SOQL queries that will result in efficient Apex code and will avoid governor limits.
- Use the Limits Apex Methods that can debug more effectively and Avoid Hitting Governor Limits.
- Use only one trigger per object.
- Keep the logic outside the trigger by calling the apex classes like a trigger handler. They use a Trigger Handler framework wherein the business logic is separated into a separate handler class.
- Aim for 100% code coverage.
- Write meaningful test classes and write them before you write the code and include all the conditions like null, boundary value etc.
- Write test methods to verify the large datasets.
- Do not hardcode Ids within the code.
- Always have a justified reason before creating a Visualforce page instead of Standard UI.
- Escape the URL parameters if they are present in code.
- Try to develop code “With Sharing†and have a justified reason if they are not doing so.
- Use Custom settings for non-dynamic variables in code.
- Clean any obsolete classes, properties or methods.
- Always do exception handling for SOQL Queries and DML statements.
- Follow Code & Naming standards.
- Use the helper classes in batch apex use framework for logging DML results
- When using Future methd (@future) they invoke it with a batch of records so that it is only invoked once for the records to process.
These habits may be hard to form – but once they become a habit when you are developing – you are sure to become become a “Great” Force.com Developer.