Blogs

Quality code development, what can go wrong without it?
- June 3, 2019
 - Owen Hughes
 
Without quality code development, it becomes more difficult to expand your product as your requirements build, not to mention it won’t pass Salesforce stringent checks.

If we take our working example that we mentioned in the first of this series of blogs, we decided to build an additional batch process to handle large Opportunities. This is great because now you will be able to target those big clients. However, you realise that the batch process is failing when working with large Opportunities. You identify there are several problems, first of which, the developer has added a SOQL within a loop in each execute of the batch and sometimes it is failing.
Moreover, there are other smaller issues such as no error handling using try catch blocks. There are a number of potential consequences of these points:
- the code needs to be structured better because the developer has added over 1,000 lines of code into the batch class;
 - the database transactions are not tested to ensure the running user has correct permissions to update records;
 - a dynamic SOQL is not being checked for SOQL injection security issues;
 - there is no check to ensure the batch process is not being called by a previous future or batch process before the batch is launched which would cause an exception.
 

All of these issues are code quality improvements. Although these issues would be poor development and sometimes cause failures for an app built to work internally in a company, the external ramifications can be greater with Salesforce preventing you from launching your app on their marketplace.
To find out more about the challenges and the potential Pot Holes have a read of this article or contact us to find out how we would approach different challenges. Or if you want to find out how we can help email Steven.Fouracre@metacube.com