How to Answer: Describe how you would document your code?
Advice and answer examples written specifically for a C# Beginner job interview.
2. Describe how you would document your code?
It will always be important to document your code for your fellow team members. This becomes extremely important when your team provides a software solution for clients to use. In C#, there are many documentation <tags> that you can use in your code:
<summary>, <remarks>, <returns>, <value>,<example>,<code>,<param> are just a few.
/// <summary>
/// Describe what your method does
/// </summary>
/// <remarks>
/// Provide additional information regarding your method
/// </remarks>
/// <returns>The sum of two input parameters</returns>
/// <param name="a">The first integer parameter to provide</param>
/// <param name="b">The second integer paramter to provide</param>
///
/// ---- The example tag is used in conjunction with the code tag to provide
/// an example of how this method would be used
/// <example>
/// <code>
///
/// int a = 1, int b =2
///
/// SummaryDocumentation(1,2)
///
/// -- returns 3
///
/// </code>
/// </example>
public static int SummaryDocumentation(int a, int b) {
return a + b;
}
public int SomeProperty
{
/// The value tag provides information of a class property
///<value>Returns the value of some property</value>
get
{
return 1;
}
}
/** You can then use the command line or visual studio to generate an XML document, which you can use internally or provide to your customers. In the above example, the document will look like this: **/
<?xml version="1.0"?>
<doc>
<assembly>
<name>ConsoleApp1</name>
</assembly>
<members>
<member name="M:ConsoleApp1.Program.SummaryDocumentation(System.Int32,System.Int32)">
<summary>
Describe what your method does
</summary>
<remarks>
Provide additional information regarding your method
</remarks>
<returns>The sum of two input parameters</returns>
<param name="a">The first integer parameter to provide</param>
<param name="b">The second integer paramter to provide</param>
---- The example tag is used in conjunction with the code tag to provide
an example of how this method would be used
<example>
<code>
int a = 1, int b =2
SummaryDocumentation(1,2)
-- returns 3
</code>
</example>
</member>
</members>
</doc>
Written by Edward Danganan on May 10th, 2021