Simple LessonsMay 12, 2011 at 10:33 am | Posted in Patterns | Leave a comment
Tags: algorithms, data structu, Programming
I am working in C from last 3 years and these two very simple lessons are based on my experience, these are not taken from any book but by my own understanding of programming. They may look very simple and short and don’t underestimate them. You may already know them (I did) and you may not be aware of them. Its like everyone knew that apple falls on the ground but only Newton became aware of it 🙂
Solving Problems: Programming is all about solving problems. I knew that (and I am sure you knew that too), every programmer know this but how many programmers translate business problems into code? May be you are working on the problem which is just your interpretation of the problem? What is the real business problem you are trying to solve on your job as a programmer? You are actually a translator between a business man and computer.
Diagrams: Before you even think about coding you must draw a digram on how you are going to split this business problem into some or lots of small ones and what will be the general idea behind solving this problem. That you can accomplish very effectively by drawing a diagram on paper using a pen (or pencil). Also known as DFDs (Data Flow Diagrams). You will see how much of your life has become easier with DFDs. DFDs follow some rules and you can make your own diagrams and your own rules but make sure you stick to some standard (whether your own or someone else). DFDs are designed to make your life easier, it will make you happy because once you start coding you will see how important they are.
Tools: What tools you are using to translate problems into code ? Whether you are solving business problems or you do it for joy of solving problems (in the world of Hackers), Algorithms and Data Structures are the first of the tools you need, programming language is 2nd tool. Majority of programmers do not focus on first tool. Why you need qsort() over other sorting techniques. Why AVL tree will be better than Red-Black tree or Binary-Search tree. Why you will use a circular linked list instead of a doubly-linked list implemented as a Stack ? Why there exist so many different kind of trees and linked lists. Even I, myself, know only few of them. Its hard work but surely simple and very rewarding. I think half of the bugs exist in software because programmers lack this tool or the intended use of it
Tools-2: Like I said, programming language you are using is 2nd tool. Don’t go to high level talk here or dig yourself into advanced programming before you understand the basics. I use C language, so before I go into advanced C book, I will make sure I have spent two years on comprehending C FAQs and comp.lang.c archives
Breaking a big problem into small problems: I am using C, which is a procedural programming language. Hence I break down a business problem into small procedures (also known as functions). I will make sure that when one procedure calls other then both of them are doing some specific work and that in a proper and structured way. Writing too many procedures or the ones which do not have a proper siginificance can (and will) cause semantic bugs which in turn cause headaches over time.
Copyright © 2011 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.