Enter your Email Address:

Delivered by FeedBurner

To get posts delivered to your Email

21 September 2013

OpenGyan - Becoming a Better Programmer

[Alert: Longer post, targeted for students community. Comments are welcome from seasoned software engineers]

Recently we had a couple of OpenGyan's workshops and i happen to scribble my ideas to the students. I hope i will be able to dedicate more time in writing posts like this. Hope this helps the students' community. Though software engineering is a very complex area (is it really that complex?), we are going to focus on the things that are very important for software development of any sort - may it be a lab exercise or a project. The readers are suggested to reflect upon the exercises given at the end of each article for better understanding.

I was reading and reflecting on the short article written by Badhri on Programming languages. Though it was short, it gave a general overview about the programming language. Any programming language is a tool to achieve your imagination. For example, if you are writing a simple program (similar to the ones that is given to you in lab), you do not need to think much. But in reality it isn't the case. To be a programmer, knowing a programming language is secondary because knowing the syntax of the programming language won't make you a good programmer. If knowing programming language is sufficient, then compiler would do the job. Software development is much more than knowing a programming language or few.

Any software is a solution to a given problem. And programming language is just a tool to solve the problem. The solution to the problem is more important than the tool (the programming language). In order to develop a better software one needs to follow certain basic principles in a specific order. The rest of the article discusses the basic principles of software development in a much simplified way.

First, one needs to understand what needs to be done. Because you cannot go on writing program simply for everything. You need to understand that you are writing a program for someone to use it. Remember that you will not always write program to improve your knowledge. So understanding the requirements - what needs to be done plays a crucial part. Understanding the requirements is the first step and if you do not understand the requirements, remember you do not have the second step.

As a second step to writing a program, you need to know how to solve the given problem without employing much of your knowledge on programming languages. For example, if you are writing a game, you need to understand and know how the game is played, how many players are involved, what are their roles etc. In this phase, you will least bother about whether you will use linked list or array. But you will solve the problem at an abstract level. This is called high level design. After high level design, you will decompose the high level design into modules and design each modules. For example, if you are writing a program to validate Palindrome, you need to have input module, processing module and output module. This ability to decompose the problems in sub-problems and solving them with sufficient data structures and algorithms is called low level design. While you are solving the problem, you should also keep in mind about the future problems that may crop up. Your design has to be flexible enough to accommodate future problems (which is quite challenging).

The third skill that is required is to convert the design into product and this is where the programming language comes in. Without the above two steps, the third skill is not worth and in fact not needed. Once you have understood the problem and solved it at a conceptual level, then implementation becomes pretty easier. You do not need to beat around the bush. During the implementation phase, you will implement the entire software module by module and finally integrate the modules to make it bigger whole. Apart from implementing the design, the coding is also about producing maintainable code. When you develop software, you are writing the software which is expected to live more than your lifetime. The program (aka code) can be written with a lot of grace and the code that is well written will live beyond ages (example Unix). The developer needs to understand about other developers who are working with him/her and the people who will be working in future. So programming is not merely following syntax but much more than that. As this point of time, we have discussed about three important qualities of a developer.

The final thing that you need to do as developer is to test your software. The primary focus of testing is to uncover hidden defects. As a developer, you are the best person to know about your code and it makes sense for others to bank on your certificate. So, it is the developers' responsibility to test the software and fix the defects. This is called as unit testing as the developer who develops it ensures that all the code that is written works as expected.

You need to evaluate how much percentage does a programming language play here. May be 40%. But please do not get me wrong. For writing a software, you need a language however for solving problems you need skills like understanding requirements, designing and most importantly testing it. Without these skills, you will not be able to excel as developer. Now would you understand why you have "Algorithm", "Flow Chart", "Hand Calculation" and "Output" section in your lab observation.

When you follow the above software development practices right from the beginning, you become a natural programmer/developer to solve any complex problems. You may want to evaluate your current way of writing programs. First solve the problem and then start writing the program. Though the exercise is short/simple, i am sure there is a lot to learn in terms of processes.

Exercise:
Take any simple program (Palindrome, Fibonacci series) and apply all the concepts you understood from this article (Duration: 3 Hours, Complexity: Medium)
  1. Clearly understand the requirement/problem. For example, what is palindrome or Fibonacci series
  2. Solve the problem by decomposing into modules
  3. Write the software
  4. Finally test

Happy Weekend

1 comment:

Suren said...

I kind of disagree to the importance given to the programming languages. Consider a case of developing a web based application. You can develop in any language, but Java / .Net/ Ruby kind of languages simplify your job. In my opinion choosing a wrong programming language will spoil the application.
In these a lot of frameworks available to solve many problems. So it's also sort of important to understand the programming languages.