Annotate Coding

More or less with new task assigned we have to face new challenges. Especially we start thinking about questions who, what, why, how to solve problems. Recently I have been assigned a new task and I was getting troubled with questions who, what, why, how. I tried on my writing pad to figure out the solution. Sometimes we have all the resuable functions written and we need to integrate new modules/ features. But if things are tricky you need to think 100 times to get possible workable solution. I figured out a way at the verge when my nerves get frayed is to write pseudo-code in comments form so, i started commenting the code which yet not conceived, and talking with myself now this now that and all that I got is below:
load_note: function(note_id){
// get selected node
// has sub_nodes
// IS node expanded
// select notes modules
// if notes is expanded{
// select specified note}
// else get_notes{
// select specified note}
// get submodules
//select notes
// get all notes
// select specified notes

and got the desired solution

select_and_expand_node: function(node){
if(node != null){
this.get_nodes_data(node, this);

load_note: function(note_id){
var notes_module_node = null;
var selected_node = tree_view_ctrl.get_selected_node();
if(selected_node != null){
notes_module_node = selected_node.search_node(‘Notes’);
if(notes_module_node != null){
now it gave me pretty much idea of how to accomplish the desired functionality. I added more comments, more checks and figured out some repetitive code and created another function and in the end I got my way to solve the problem in less time.
Adding comments is another sub-task of developing nice code, which I sometimes hate why not I make function-names and variables-names so understandable to avoid commenting code no doubts there be pieces of code where commenting is inevitable but we can avoid as much as possible.
Try it…

Creative Commons License
Annotate Coding by Rehan Munir is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.


Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: