When code review uncovers a lot of small problems, this can often bring larger problems to the surface. "Code Smell" refers to small problems that may reveal bigger concerns in code. I previously gave an example of code that uses a 'poltergeist' object to pass data from an external system into a custom Salesforce object before creating the data in the required Salesforce object. The same code also uses 'hard coded' values that are not named constants. And that "Code Smell" reveals the use of a database field for interprocess communications, setting a field value to 'success' when the record is created rather than relying on more direct means of communication.
Using the Apex Database class, as shown in the second code block, provides a direct means of communication that would make Auntie Pat Tern proud.
No comments:
Post a Comment