Wednesday, October 6, 2010

Understand Source Code by Reading Code and Refactoring for Maintaining Large Projects

This list consists of one-liner tips to be used for easy lookup and reference.

Rewriting Code for Better Understanding (Coding Horror)

  • What I cannot create, I do not understand. [Richard Feynman]
  • "What I do not create, I do not understand."[Chris]
  • "It's easier to understand 600 tables than 100,000 lines of code." [PaulC on comp.databases.theory/2005]
  • Create a new project with blocks of code copied from old code. Refactor to reduce "old code smell"
  • Start refactoring by adding small tests to better understand code and act as regression tests.
  • Just scan through huge amounts of code till it starts making sense - "understand by constant exposure".
  • Create a text file to capture your understanding - briefly describe how the component works, realtions to other components, what it persists, its states, and source browsing/debugging tips you found useful.
  • Manually reformat a copy of the code - white space, and indented as per your personal style.
References:
  1. Working Effectively with Legacy Code
  2. Object Oriented Reengineering Patterns
  3. Refactoring: Improving the Design of Existing Code

Howto Start a Blog, Get Useful Blogging Ideas, Add Good Content, Reduce Effort with Tools and Keep Blogging


Avoid Bloggers-Block:
After the initial burst you can't think of what to say - so the blog languishes.
A blog is short form for web-log i.e. a kind of "A log entry in your Personal Diary".
It is not meant to be a book which you publish after many many rewrites and deep thought.
Some people even have one-liners or even other peoples blogs as blog-entries.
Find an Idea/Topic:
Your idea becomes self sustaining if it's useful or matters to you or your friends.
You can organise your self-learning or teaching notes as blogs. Collect questions from people around you or from forum newbies.  This way you create more knowledge for yourself and write excellent blog-posts that are useful to others.
Publish or Perish:
Publish as soon as you have a line of text on your blogs.
Drafts are the best way to kill blogs.
Use them only when you require to do some basic tidying before posting.
Even this can be done later followed by a republish.
Blog Incrementally:
Paste your current state into the blog (like saving a session of your mind a.k.a. brain-dump).
Every time some find some new useful information you just paste that into your blog-post.
Use a multiple clips clipboard manager to copy all the info you need.
The post should be written in logical manner with least gaps in the reasoning or steps
Any good links that you open in Firefox tabs can be saved for:
    a) Further investigation
    b) Future use
Reduce Blogging Effort:
Ideally follow 80-20% rule.
Spend 80% time spent on gathering material.
Spend 20% time spent on filling in gaps and reordering/rewriting post.
See Tools section for more details
Tools:
Currently I'm trying to reduce editing/formatting effort/time by using the following tools:
Blog Upload: Evaluating desktop client s/w's for editing and posting to blog (like ScribeFire, Windows Live Writer, SeMagic)
        I've used 2-3 good desktop blogging clients:
      
1) ScribeFire to handle blog-editing, upload and managing of multiple accounts/blogs.
           Looks to be the best option for now.
        2) Kompozer is good for a basic HTML whysiwyg editor.
        3) Windows Live Writer - not really used it but looks good enough for basic blog maintainence.
Blog Composing: Kompozer, CSS Stylesheets (TODO)
MindMaps: XMind with Freemind (for mindmaps and concept maps with collaboration respectively)
Pictures: Paintbrush Digicam for Photos, MediaWiki Free Photos
Video: InstantDemo, Jing ScreenCapture software for Demonstration Videos.
        Diagrams: Diagramming s/w (To-Do)
Uploading: To-Do
See Also:Basic Format  for a Technical Blog