Programming Basics



Chapter I : Programming Basics.

I.I - Brainstorming
What is software? Software is a collection of instructions that enable the user to interact with a computer or have it perform specific tasks. In other words software is any computer program. Therefore in order for us to create a software we must collect all data possible that we might need. Including ideas, formulas, etc.. One of the first steps I like to do before getting into deisnging the softweare is the good ol' brainstorming. Brainstorming not only helps collect ideas but helps understand more what our goal for the software is.


I.II - Diagrams

Diagrams: Before we start programming to create our own software. First we must learn one of the most efficient methods to solve and plan any software, diagrams. This simple strategy will be the organization and orientation for your software. Therefore we need to learn this basic concept in order to successfully learn how to program.

The logic of diagrams, will teach you the side of the computer language you are required to know, Take in consideration that computer language is simple, always be mindful that, the computer will do what you tell it to do and nothing else. Just like teaching a kid to tie his/her shoes, a computer behaves the same way, you must teach it step by step. This is where diagrams come really handy.

First we need to know how to crate this diagrams or flowcharts. There are many symbols to represent all the components in a program but now we are learning the basic and most useful ones. In the image below you can see three of the most used shapes.






The End-point: this circle will mark the begginning and end of the program.

The Step; this square/rectangle will represent one of the many steps in the program.

The Decision; this diamond shape will be a decision mark in your program.


1- List the known steps that might be needed to execute the program from beginning to end.

- Start
- Go to the kitchen
- Check for coffee to be ready
- Grab coffee mug
- Pour coffee
- Get out of the kitchen

2- Create the diagram for such steps, be mindful that this needs to be often updated.




As you can see this diagram show simple steps to follow, but what if there is not coffee at the kitchen? Obviously you are not going to give up and go back to sleep. A program should behave in the same way, the program must be able to direct the user step by step, until an outcome satisfactory to the user is reached. As the diagram above shows if the coffee is not ready, the user just goes back to the room without coffee, let's make a more realistic solution.

Analyse the diagram below.




Now in the diagram above we found to it to be more useful than the first diagram. We can also see that there is a new shape(half-ellipse) in the flowchart, this new shape is called a 'delay'. A delay is basically a "wait on time or on a task to be completed".

Now write the steps that you think were required for this flowchart, and when you are done, compare them to the list below. Remember that there is always more than one solution, so your solution does not have to look like mine, but it should follow the structure.

Step 1: Start program.

Step 2: Go to the kitchen

Step 3: Is coffee ready?

          3a- If Step 3's answer is Yes, go to step 9.

         3b- If Step 3's answer is No, go to step 5.

Step 5: Prepare your coffee.

Step 6: Is coffee ready?

        6a- If Step 6's answer is Yes, go to Step 9.

        6b- If Step 6's answer is No, go to Step 7.

Step 7: Wait for coffee to be ready.

Step 8: Go to Step 6.

Step 9: Grab coffee mug.

Step 10: Pour coffee.

Step 11: Get out of the kitchen.

Step 12: End program.


Exercice I : Create at least 4 diagrams of any process that you do in a typical day, like making coffee or driving back home. Make sure there are at least 5 or more steps including decisions.


Example I

Goal : Go eat lunch to a restaurant from home, using the next restrictions :

Restrictions:

- Meal budget = $10

- Distance allowance = 12 Km

- Restaurant rating = 3 stars or higher

- Time allowance = 2 hours


Brain storm arguments and variables that might be needed to create the process, remember that brain-storming is highly desired in order to obtain a good solution, this method might help to find issues before they are present. Remember to use as many ideas and conditions as you might believe necessary in order to accomplish your goal, do not worry about efficiency at the moment.

· Lunch time?

· Hungriness

· Meal budget

· Restaurant rating

· Time allowance

· Distance allowance


Using ideas from the brain storming step, start planning the steps to follow in a order, i.e :

· Check for user hungriness

· Check what time is it

· Start time count

· Leave home

· Check for restaurants in a 12 km ratio

· Check for restaurants within 12km ration that have a 3 star rating or higher

· Meal price

· Start eating

· Finish eating

· Time alarm

· Return home


Exercise II : Design the diagram for this process. And in this exercise I dare you to use your imagination to come up with a clever solution.


No comments:

Post a Comment