My Tips to Become a Better Softare Developer just after the "Newbie" State
Today, at the line of retiring programming, i have tips to store for myself and should be helpful for new programmers and open minded (developers with the high improvement ability on work), these are formed in five steps;
Tip 1. Methodize... don't memorize
A programmer friend of mine use to always tell me how his memorization of over 200 function in C++ helped him greatly. "I never have too look up function definitions , therefore I can code 50% faster then the average coder!" he would brag. So what happened? Intellisense for one, two when C# came out all his diligence in memorizing functions went to waste. Of course in coding some memorization is a necessity but you should spend more time learning the method of doing things, i.e. creating a db connection, consuming a RSS feed, etc. then memorizing the code on how to do them. Learn the correct methods of doing thing, don't memorize.
Tip 2. Create your own Resource library
We all have a block of code that for some reason or another we have to look up. I can never remember the exact sequence of code to connect to a database. So every time I had to do this I would spend 10 minutes finding the book, looking up the link, etc. To combat this I created a word document that has snippets of code that I have trouble remembering for some reason or another. One of my colleagues creates a bookmarks of links, another stores all his in a email. What ever your method is its a good habit to keep that file close by . The point is that you should be building you knowledge base and you will find that it will greatly help you in coding better and faster.
Tip 3. Learn WHAT not HOW
A lot of junior programmers ask me "How do I do this, or How do I do that?" and I always ask them "What do you want to do?" and they stare at me like I am dating their mothers or somethings. This brings me to my next point, never learn How always know What you want to do. Example, lets say a programmer wanted to search a text file to see if it contains a certain word. This is HOW you would do it in C#:string fileContent;
System.IO.FileStream myStream = new FileStream("c:\\aa.txt", FileMode.Open);
System.IO.StreamReader myStreamReader = new StreamReader(myStream);
fileContent = myStreamReader.ReadToEnd();
myStreamReader.Close();
int idx = fileContent.IndexOf("string");
if (idx)
{
return true
}
Now sure I could give him the code to do this but its more important to understand WHAT you are trying to do. In this example WHAT you want to do is:
1) Open a file
2) Read the file contents
3) Close the file
4) Search for string
5) If found output success message.
Breaking down the task in the manner does two things
1) it makes it language independent
2) it gives you a focus on WHAT needs to be done.
3) It makes your code more readable and usefull
Know WHAT you are trying to do makes the language you are trying to code it in inconsequential. Now it should be easy to create this code in C++, PHP, VB.NET, Ruby on Rails because you understand WHAT you need to do instead of HOW to do it.
Tip 4. Comment to match your style
Everybody coder hates commenting but in order to write quality/readable code every coder must comment. The problem most coders have is that they are always TOLD how to comment. Some companies want a comment on every line, others want a block of comment before every functions, others wants comments on difficult code blocks. I disagree with the policy and say that as long as the comments are usable, readable and useful then a coder should be able to comment in a format that works for him/her.For me commenting on every line breaks up my coding rhythm. I prefer to comment at the beginning of a functions listing step by step what I am going to do, then I referencing the steps as comment inside the functions. This works for me because it helps me organize my plan before I starting coding, its keeps me in rhythm as I don't have to stop coding to comment, and its help other readers read my code. Heres a example of how I comment:
/* 1. Open File
* 2. Read file into string
* 3. Close file
* 4. Search for key word
* 5. If fond return true;
*/
string fileContent;
//1.
System.IO.FileStream myStream = new FileStream("c:\\aa.txt", FileMode.Open);
System.IO.StreamReader myStreamReader = new StreamReader(myStream);
//2.
fileContent = myStreamReader.ReadToEnd();
//3.
myStreamReader.Close(); //4.
int idx = fileContent.IndexOf("string");
if (idx)
{
//5.
return true;
}
My point here is that this commenting style works for me and most programmers can read it with ease. Find a commenting style that works for you.
No comments:
Post a Comment