Source code documentation Flashcards
Why Source code documentation is important?
There are several reasons why code documentation is crucial for any project.
It is good for knowledge transfer. Not all code is equally obvious. There might be some complex algorithms or custom workarounds that are not clear enough for other developers.
It helps to troubleshoot production issues. If there are any problems with the product after it’s released, having proper documentation can speed up the resolution time. Finding out product details and architecture specifics is a time-consuming task, which results in the waste of your money.
It may help you better manage any additional integrations and product add-ons. Product documentation describes dependencies between system modules and third-party tools. Thus, it may be needed for integration purposes.
What is Source code documentation?
It is place where you can find info about code. It is doc about code: properties, methods ect.
Class Comments
@author the author of the class
@date the date the class was first implemented
@group a group to display this class under, in the menu hierarchy
@group-content a relative path to a static html file that provides content about the group
@description one or more lines that provide an overview of the class
___________________________________________________________________
* @author Salesforce.com Foundation
* @date 2014
*
* @group Accounts
* @group-content ../../ApexDocContent/Accounts.htm
*
* @description Trigger Handler on Accounts that handles ensuring the correct system flags are set on
* our special accounts (Household, One-to-One), and also detects changes on Household Account that requires
* name updating.
*/
public with sharing class ACCT_Accounts_TDTM extends TDTM_Runnable {
Property Comments
@description one or more lines that describe the property \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ /******************************************************************************************************* * @description specifies whether state and country picklists are enabled in this org. * returns true if enabled. */ public static Boolean isStateCountryPicklistsEnabled { get {
Method Comments
@description one or more lines that provide an overview of the method
@param param name a description of what the parameter does
@return a description of the return value from the method
@example Example code usage. This will be wrapped in tags to preserve whitespace
_________________________________________________________________
Example
/***********************
* @description Returns field describe data
* @param objectName the name of the object to look up
* @param fieldName the name of the field to look up
* @return the describe field result for the given field
* @example
* Account a = new Account();
*/
public static Schema.DescribeFieldResult getFieldDescribe(String objectName, String fieldName) {
Annotation for source code documentation:
Annotation is a special text in comments to help understand code. Also, it is crucial for documentation generator.