Computer programming is explaining a solution to a problem.
On a human level, we look at a problem and identify what we have and what we want. Then we figure out how to get from one to the other.
Programming a computer to solve a problem always requires defining data to represent the things in your problem; this is called modeling. It also requires explaining unambiguously what process to follow in order to solve the problem. This process of explaining is where different paradigms of programming come in:
- Evaluation and substitution. These are the basic algebra skills that programs are built on, and that programmers mentally fall back on when trying to figure out why a program isn't behaving as expected.
- Modeling. Information is complex; solving problems with the computer (or with math) always somehow involves defining and using data to represent information from the problem.
- Managing complexity: Breaking problems and solutions down into chunks that can be understood easily. Abstraction is the main tool for this.
- Communication. In at least two ways, this is important: (1) Determining what your clients want, so you are solving the right problems. (2) Organizing and documenting your work so that you (or the next programmer to touch it) will be able to understand it, months or years later.
- Patience and perseveration. When things aren't working right, there's usually something you haven't noticed. Learning what that something is often requires mentally retracing your steps, and manually re-running code on different inputs, until you see what you've been missing. This may take a while.
- Discipline. Writing tests and specifying what work must be done are both decidedly unsexy tasks, but they both make your work easier and give you confidence that you've done your work correctly.
Steps involved in Computer Programming -
- Definition of the problem (involves definition of the input/output data associated with the problem, what sort of input shall be provided and what would be the expected output)
- Planning of the solution (developing flow charts / algorithms to solve the problem)
- Coding the program (Expressing the solution through instructions, written in a programming language)
- Testing the program (Translation of the source program into executable form and debugging, which involves locating and correcting errors)
- Documentation (It is a written detailed description of the programming cycle and specific facts about the program. Typical program documentation materials include the origin and nature of the problem, a brief narrative description of the program, logic tools such as flowcharts, algorithms, data-record descriptions, program listings, and testing results. Comments in the program itself are also considered an essential part of documentation.)
STEPS IN WRITING A PROGRAM
1. Understand the specific reason to write a program So, before we embark on our programming journey, we should understand what is the reason behind writing a program. Is it to calculate the area of a rectangle, or convert fahrenheit to celsius, or place a rocket at a particular orbit, or predict the weather for a particular day. Understand clearly the reason for writing the program. There should not be any ambiguity at all.
2. Know what are the inputs I have already told you that, every program takes some input, processes the input and produces some output. Understand what the inputs are for the program you are writing. For example, if a program is written to calculate the area of a rectangle, length and breadth would be the input. If it is a program inside a robotic vacuum cleaner, it could be the input given from the sensors about the presence of some dirt in the vicinity. So, depending on how complex the program is, the inputs also could differ.
3. Identify the process The process is used to convert the input to output in a program. Some times, the process could be very simple, as simple as just using a formula to calculate the answer. For example, we write a program to calculate the area of a rectangle. Multiplying length and breadth would give me the area of the rectangle, and that’s all is the process. But, if I want to write a computer program, which has to play Jeopardy, against a human opponent, then the process would not be that simple. So, depending on the need of the question, the process to convert input data to output information would differ. When you decide to write a program, be clear on what is the very very clear about that. Crystal clear!!!.
4. Know what is the output Last but not the least, is, you should know what is the output of your program. The output data which is generated or calculated or predicted needs to be presented to the user in a very user friendly manner, which is clear and makes sense. So, it is never about getting the correct output, it is always about presenting it well to the user.
5. Example So, let us take a simple example and try to identify the input, process and output for the same. For example, if the question is to write a program to find the area of a rectangle.
Input – Length and breadth
Process – Area = length X breadth
Output – Print Area
May be another example is to calculate the simple interest using a program
Input – Principal, rate, period
Process – (Principal X rate X period)/100
Output – Print Principal
So, I think all of you have would have got some idea of programming and how to identify input, process and output before starting to writing any program.
Comments
Post a Comment