What is Programming?


Programming - Writing a list of instructions that tells the computer, in very precise terms, how to do what you want it to do.

That is a good textbook definition of Programming. But it is more than that. Programming is problem solving. When you are given a programming assignment whether in a computer science course or as a software engineer working for a software development company you are being given a problem to solve. In the beginning the problems will be very simple as you are learning the programming language, but it will be to your advantage to start off thinking of your assignment as a problem to solve.

As a programmer you will be frequently called upon to develop algorithms which will then be implemented in code.

Algorithm - A step-by-step procedure for solving a problem in a finite amount of time.

When you are sitting at a computer writing code you are following an algorithm. But, where did that algorithm come from? In the problem solving phase of software development you are designing that algorithm. There are some problem solving techniques which you will find very useful as you work toward solving programming problems.

Problem Solving Techniques

  1. Ask questions
    When you get a programming assignment you must understand exactly what it is that your program should do, that is what problem do you have to solve. Read the programming assignment carefully and make note of any questions you may have. For example:

    • What data do I have to work with?
    • Where is that data coming from?
    • What is the format of that data?
    • How much data is there?
    • How will I access the data?
    • How will I know when I have all the data?
    • What processing must I do on the data?
    • What should the output look like?
    • How many times will I have to repeat the processing?
    • What special error conditions should I expect?
    • How will I handle those special error conditions?

  2. Look for things that are familiar

    As you get more experience designing software solutions to problems you will began to see similar situations. Ask yourself, how can I apply previous solutions to problems, that I developed, to this problem?
  3. Solve by analogy

    Too many programmers, when they are trying to solve a problem, get all wrapped around the axel trying to come up with a computer-oriented solution. Learn to think outside the computer box. How would you solve the problem if you didn’t have a computer. Can that solution then be adapted to a computer solution? One common type of programming problem you may have at some time in the future is what is called Modeling and Simulation in which you have to write a program to simulate some real life situation or event.
  4. Means-Ends Analysis

    Frequently in a problem solving situation you are told what your beginning state is, i.e. What is the form of the data and where is it. And you are told what your ending state is, i.e. What form must the data be in after processing and where must it be stored. Now it is up to you to decide how to get from the starting state to the ending state. And there may be many different ways to get there.
  5. Divide and Conquer

    This is probably one of the most important approaches. Frequently (especially in future courses) you will get programming assignments that may seem overwhelming. Just remember the problem: "How do you eat an elephant?" The answer is: One bite at a time. Break the large problem down into smaller pieces and find a solution to each piece of the problem. Then put all the pieces together.
  6. Building-Block Approach

    This is similar to Divide and Couquer. Look to see if there are already some solutions that might solve parts of your problem. Can you assembly these smaller pieces together to arrive at a solution to your problem.
  7. Merging Solutions

    Sometimes you may be able to take two solutions for simple problem and combine them into a larger solution to a bigger problem. For example, as illustrated in the diagram below, you may be able to merge the solutions to counting the number of values and summing a number of values to find the of a set of values average.