This guide will eventually teach you how to be the most popular person among your colleagues, and you will be the hero of their chats during breaks and work hours, it can even be said that this guidance can help reduce your work, you can get generous help from your colleagues, they want to help you do your work. Because of your reputation!
1. variable naming can show your creative potential. Don't bother yourself with the identifiers and guidelines. All of 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. Become a genius and give methods and parameters some intriguing names
Public int viriableinflationmodusoperandi (INT variable, int inflator)
{
Return variable * inflator;
}
3. Comment out your code with a very professional attitude. Annotations help you understand your code correctly.
// This variable is named after my mom. wyburga-thomasia flandrina. Remember it!
Long WTF = 1;
4. Do not write too many comments in your code. Too many comments make your colleagues feel nervous-because you think they don't understand? If you give them the opportunity to think, they will respect you.
Code
/// <Summary>
/// Perform image check.
/// </Summary>
Public static void imageroutine (image)
{
If (image! = NULL) & (imageinfolist! = NULL ))
{
Bool isreaderlockheld = rwimglistlock. isreaderlockheld;
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-oriented. Compare the 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;
}
Obviously, example #1 looks more stable. It has more code, everything is encapsulated, and the code looks impressive.
6. Write less code. This will lead to fewer errors, less support time and more entertainment time. 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 ();
}
You get: Ajax-oriented pages, rapid development, and multi-layer architecture.
7. Compile the genius code. Your colleagues will thank you for your insights.
Write:
Int year = 0x000007d9;
Instead:
Int year = 2009;
Write:
VaR sb = new stringbuilder ();
SB. append ("error :");
SB. append (2001 );
SB. append (".");
Return sb. tostring ();
Instead:
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:
! Value
If you follow these simple steps, your name will soon be known to all your colleagues. You will be a very popular person-your colleagues will provide you with suggestions, chats, and handshakes. Some colleagues may ask you the secret. If this happens, you can give them the following answer (in the voice of a mentor ):
"Writing code is a transcendental process of transformation of infinite chaos into finite reality with coherence,Course".
Http://www.codeproject.com/KB/cs/Rumorous_Developer.aspx ()