Session 1 - Programming Logic

Session 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 designing the software is the good ol' brainstorming. Brainstorming not only helps collect ideas but helps understand more what our goal for the software is. In this stage we should gather all the main thoughts about the software we are creating.
ie: Brainstorming for drinking coffee in the morning
- do we have coffee?
- how many cups of coffee do we want?
- how to make the coffee?
- is coffee ready?
- location of coffee
- do we have coffee mug?
- do we want hot coffee?
- cream and sugar?

After gathering as much ideas and data as we want/can,  we must organize the ideas in order to itemize and create a timeline.

- do we have coffee?
- do we have coffee mug?
- how to make the coffee?

- location of coffee
- is coffee ready?

- how many cups of coffee do we want?
- cream and sugar?

After we have our ideas more organize, the next step is to create a logical diagram, keeping in mind the goal of our software.


I.II - Diagrams

Diagrams is one of the most efficient methods to solve and plan any software. 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 beginning 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.


Exercise 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

Exercise 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.

Exercise 3 - Analyse the diagram below.



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  "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.

Solution to exercise 3 :

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 IV : Create at least 2 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.


Exercise V : Create the diagram for the next exercise

Step One - Define the main goal.

Goal : Go eat lunch to a restaurant from home:

Brainstorming - Brainstorm 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.

- Meal budget = $10

- Distance allowance = 12 Km

- Restaurant rating = 3 stars or higher

- Time allowance = 2 hours

· Lunch time?

· Hungriness

· Meal budget

· Restaurant rating

· Time allowance

· Distance allowance


Using ideas from the brain storming step, create a timeline or organize items, 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

Note : Diagram coming soon!

No comments:

Post a Comment