This guide will ultimately teach you how to become the most popular person among your co-workers. You will be the hero of their chats during breaks and work hours. It may even help reduce your workload so you can get the most out of you. Generous help from colleagues who want to help you do your job. Because of your reputation!
1. Variable naming can show your creative potential. Don't bother yourself with notations and guidelines. These will limit your inspiration. If you use an unknown naming scheme, you will be praised and your colleagues will respect you.
bool rAgeaggainStmaShine = false;
int dd44 = 12;
bool dude = true;
2. Be a genius and give some intriguing names to methods and parameters.
public int ViriableInflationModusOperandi(int variable, int inflator)
{
return variable * inflator;
}
3. Comment your code with a very professional attitude. Comments help you understand your code correctly.
// This variable is named after my mom. Wyburga-Thomasia Flandrina. Remember it!
long wtf = 1;
4. Don’t write too many comments on your code. Too many comments make your colleagues nervous - because you think they don't understand? If you give them a chance to think, they will respect you.
code
/// <summary>
/// Perform image check.
/// </summary>
public static void ImageRoutine(Image image)
{
if ((image != null) && (imageInfoList != null))
{
bool isReaderLockHeld = rwImgListLock.IsReaderLockHeld;
LockCookie lockCookie = new LockCookie();
threadWriterLockWaitCount++;
try
{
if (isReaderLockHeld)
{
lockCookie = rwImgListLock.UpgradeToWriterLock(-1);
}
else
{
rwImgListLock.AcquireWriterLock(-1);
}
}
finally
{
threadWriterLockWaitCount--;
}
try
{
for (int i = 0; i < imageInfoList.Count; i++)
{
ImageInfo item = imageInfoList[i];
if (image == item.Image)
{
return;
}
}
}
finally
{
if (isReaderLockHeld)
{
rwImgListLock.DowngradeFromWriterLock(ref lockCookie);
}
else
{
rwImgListLock.ReleaseWriterLock();
}
}
}
//Everything is done. Return.
}
5. Use encapsulation. This is one of the key principles of object orientation. Compare these two examples:
Example #1:
public int AddTwo(int arg)
{
return arg + 2;
}
public int AddOne(int arg)
{
return arg + 1;
}
public void Main()
{
int calc = AddOne(AddTwo(5));
}
Example #2:
public void Main()
{
int calc = 5 + 2 + 1;
}
It's obvious that Example #1 looks more solid. It has more code, everything is encapsulated, and the code looks impressive.
6. Write less code. This will result in fewer bugs, less support time and more time having fun. Consider the following structure:
common.js:
code
function deleteUser(userId)
{
$.get("sqlengine.ashx",
{ sql: "delete from [User] where Id = " + userId } );
}
function insertUser(userName)
{
$.get("sqlengine.ashx",
{ sql: "insert into [User] values ('" + userName + "')" } );
}
sqlengine.ashx:
code
public void ProcessRequest(HttpContext context)
{
var con = new SqlConnection("connectionString");
con.Open();
var cmd = new SqlCommand(context.Request.QueryString["sql"]);
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
}
What you get: AJAX-focused pages, rapid development, multi-tier architecture.
7. Write genius code. Your colleagues will thank you for your insights.
write:
int year = 0x000007D9;
instead of:
int year = 2009;
write:
var sb = new StringBuilder();
sb.Append("Error:");
sb.Append(2001);
sb.Append(".");
return sb.ToString();
instead of:
return string.Format("Error: {0}.", 2001);
write:
code
/// <summary>
/// Does mysterious transformation of TRUE to FALSE and vice versa.
/// </summary>
public static bool TheGreatLifeTransformation(bool valueToTransform)
{
if (valueToTransform == true)
{
return false;
}
if (valueToTransform == false)
{
return true;
}
throw new ArgumentOutOfRangeException();
}
instead of:
!value
If you follow these simple steps, your name will be known to all your colleagues in no time. You will be a very popular person - your colleagues will offer you advice, chat and shake hands. Some of these colleagues may ask you about your secrets. If this happens, you can give them the following response (said in the instructor's voice):
"Writing code is a transcendental process of transformation of infinite chaos into finite reality with coherence, of course".
Reference original text: http://www.codeproject.com/KB/cs/Rumorous_Developer.aspx
Author: Zhu Qilin Source: http://zhuqil.cnblogs.com
The copyright of this article belongs to the author and the blog park. Reprinting is welcome, but this statement must be retained without the author's consent.