Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming Concepts & Logic

Similar presentations


Presentation on theme: "Introduction to Programming Concepts & Logic"— Presentation transcript:

1 Introduction to Programming Concepts & Logic
COP1000 4/22/2017 Introduction to Programming Concepts & Logic COP1000 Professor: Dr. Meg McManus McManus COP1000 COP1000_01

2 Introduction Course Outline Open Lab Asthma & Allergies Food
Course Website Tests Assignments McManus COP1000

3 Puzzles, anyone? Do you Suduku? McManus COP1000 COP1000 4/22/2017
Research shows that doing puzzles (or games) improves significantly your ability to be a successful programmer. Why? Because by solving a puzzle, you are solving a problem, and that’s what programming is all about…solving a problem using a computer-assisted solution. So, game on! McManus COP1000 COP1000_01

4 Why Programming? We encounter problems every day.
COP1000 4/22/2017 Why Programming? We encounter problems every day. Programs are simply solutions to problems. Puzzles are simply a solution to a problem To create programs We have to learn to think a different way… The way computers think. Every day we encounter all sorts of problems. What am I going to wear today? Where am I going to go to lunch? Am I going to get up enough nerve to ask the cute girl in the 2nd row out on a date? These are all problems we encounter, but organizations are faced with different sets of problems. These problems take the form of solving payroll problems. Ex. What is the Net Pay for Employee X based on Hours Worked and Pay Rate? To solve these kinds of problems, we have to learn to think not the way we’re used to thinking, but, instead, we have to learn to think the way the computer thinks. We cannot skip steps in our solutions, because the computer would not understand. McManus COP1000 COP1000_01

5 General Problem-Solving Concepts
COP1000 4/22/2017 General Problem-Solving Concepts Lesson 1 The following are general problem-solving concepts that all programming students should understand and follow when developing programs. McManus COP1000 COP1000_01

6 6 Steps in Problem Solving
COP1000 4/22/2017 6 Steps in Problem Solving 1. Identify the problem If you don’t know what the problem is, you can’t create a solution for it. Ex. Calculate Payroll for 10 Employees Ex. Provide directions Identifying the problem (or the Requirements part of the Software Life Cycle) is where we learn about the problem from the client’s perspective. If you can’t restate the problem, how are you ever going to build a program to solve the client’s problem? It’s kind of like Algebra problems. Solve for X…when presented with an equation, if you don’t know how to go through the steps to solve the problem, how are you going to come up with the correct answer? An all to obvious example is giving someone directions. If you give the person the instruction Go North 1 mile and the person doesn’t know which direction North is, how effective are your instructions going to be for that person? Likewise, if you tell the person to go to Beal Parkway and turn left, and the person doesn’t know where Beal Parkway is, you have not helped the person. McManus COP1000 COP1000_01

7 6 Steps in Problem Solving
COP1000 4/22/2017 6 Steps in Problem Solving 2. Understand the problem Clients rarely completely understand what they want let alone how to tell you. Perform Research - to form your own knowledge base Observations by Watching current activity Reviewing past activities Ex. Giving instructions to someone on how to find an address. Understanding the problem is next… Being able to restate is one way you can verify that you understand the “what” you will be doing, but you have to understand the problem, too. One way to figure out the problem is to perform research on the problem. Another method is through observing the client do what they do without the computer-assisted solution that you’re going to develop for them. By observing what they are doing, you can better understand the problem and thus, create a better designed solution that will serve the client’s needs. Another method is to review past activities of the client. This will give you a historical perspective of what the client has been doing and what they want to change about the way they are doing things. McManus COP1000 COP1000_01

8 6 Steps in Problem Solving
COP1000 4/22/2017 6 Steps in Problem Solving 3. Identify alternative ways to solve the problem. Rarely does a problem have only one solution. Look at Efficiency Speed Accuracy Acceptability Next comes solving the problem, but not just solve it one way and you’re done. This is usually called doing the “down and dirty” method and usually results in bad code. By creating multiple solutions to your problem, you can evaluate the different solutions to find the one best for your particular problem. Different aspects to look at include efficiency of the code, the speed of the code (not always the most important aspect), obviously the accuracy of the code (it should work correctly) and the acceptability of the code (by the client/user). Other factors to consider include the maintainability and reusability of the code—factors that have become more important in programming in the large environments. Don’t just find one solution and stop there. Rarely is it the best solution…especially for novice programmers… McManus COP1000 COP1000_01

9 6 Steps in Problem Solving
COP1000 4/22/2017 6 Steps in Problem Solving 4. Select the best way to solve the problem from the list of alternative solutions. Establish criteria to help when performing evaluations on each alternative Include pros and cons for each solution Select the best solution based on the research Next, you need to select the best solution from the alternatives by establishing the criteria by which you’re going to evaluate your solutions. Create a list of pros and cons for each solution and evaluate how pro or how con is each. The select the best solution based upon your research. McManus COP1000 COP1000_01

10 6 Steps in Problem Solving
COP1000 4/22/2017 6 Steps in Problem Solving List instructions that enable you to solve the problem using the selected solution. Create a numbered, step-by-step set of instructions Instructions must be included in the knowledge base… So, what’s a knowledge base? Next, you need to list the instructions that will solve your problem. But, it’s not just about the list of instructions. You also have to know what your users will know. This is the knowledge base. So…what’s a knowledge base? A knowledge base is a list of what the user needs to know before the user can complete the instructions you’ve created in your computer-aided solution. In other words, if I create a program that give directions to find a location for users using North, South, East and West, and they don’t know where they are with relation to the compass, my program will be worthless to them. Similarly, if I give them street addresses and they don’t know the name of the streets, again the program will be useless to them. You have to be aware of your users knowledge base or establish one for them, before they can successfully use your program. McManus COP1000 COP1000_01

11 6 Steps in Problem Solving
COP1000 4/22/2017 6 Steps in Problem Solving 6. Evaluate the solution. Test the solution Are the results accurate? Does it satisfy the needs of the client? Is it acceptable to the client? Does the solution solve the original problem? Finally, evaluate the solution. Make sure the solution Is accurate Solves the right problem Satisfies the needs of the client/user Is acceptable to the user Comes in under budge and within the time constraints of the contract with the client Solves the original problem without embellishments McManus COP1000 COP1000_01

12 2 Types of Problems Algorithmic Solutions
COP1000 4/22/2017 2 Types of Problems Algorithmic Solutions Steps involved in following a set of instructions. Ex. Calculating your checkbook balance The solution will be the same each time the algorithm is followed. Most computers use algorithmic types of problems. So what types of problems do we deal with “usually”? Most of the problems that we create for computers are algorithmic solutions. Algorithmic Solutions are a set of instructions that will be followed each time the program is run. Calculating a payroll problem is an example of an algorithmic solution. McManus COP1000 COP1000_01

13 2 Types of Problems Heuristic Solutions
COP1000 4/22/2017 2 Types of Problems Heuristic Solutions Solutions that can’t be reached by following a direct set of steps. Created by using reasoning built upon knowledge and experience…and by trial and error. Ex. Determining which stock is the best value The results may not produce the same results each time the algorithm is executed. Artificial intelligence deals with heuristic types of problems. Heuristic Solutions, on the other hand, create different solutions each time the program is run. Calculating an appropriate stock to purchase is an example of a heuristic problem because what is appropriate one minute may not be in the next minute. Artificial Intelligence programs use heuristic computer-aided solutions. McManus COP1000 COP1000_01

14 Solutions The instructions that will result in the best solution.
COP1000 4/22/2017 Solutions The instructions that will result in the best solution. Again, the result may Be more Efficient Be Faster Be more Understandable Be more Maintainable Be Reusable Solutions, then, are the result of our research and coding creating the best solution for the particular problem being solved. Each solution may be: More efficient More or less faster than another solution More understandable More maintainable (a definite plus) More reusable (preferred) McManus COP1000 COP1000_01

15 Results The outcome of the program May take any form:
COP1000 4/22/2017 Results The outcome of the program Or the completed computer-assisted answer… May take any form: Printout Updated files Output to monitor, speakers, etc. The results of the process is the computer-aided (or assisted) solution to the problem. Results may take the form of: Printouts Updated files or databases Outputs sent to monitors, speakers, hard drives, etc. McManus COP1000 COP1000_01

16 COP1000 4/22/2017 The Program The set of instructions that make up the solution after they have been coded into a particular computer language. Although we won’t be actually writing programs, at least not in any specific language, this is what we will be working toward throughout this course! The program is the set of instructions that make up the solution after they have been coded into a particular computer language. Although we won’t be actually writing programs, at least not in any specific language, we will be researching the problems, designing the solutions, creating the algorithms, and writing out the solution in pseudocode! McManus COP1000 COP1000_01

17 Steps in Building a Program
COP1000 4/22/2017 Steps in Building a Program Understanding the problem (What does it mean?) Developing an algorithm (what is the solution to the problem) Writing the program (by the programmer, including internal commenting) Documenting (external) the program (for the user/system administrator) Testing and debugging the program Testing - by anyone other than the programmer Debugging - by the programmer So the basic steps in building a program include: Understanding the problem Developing the algorithms to solve the different components of the problem Writing the program (in a particular language appropriate to the problem) Writing the documentation for both other programmers/maintainers/testers (internal documentation) and the users/system administrators (external documentation) Debugging the solution by the programmer Testing the solution—preferably by anyone other than the programmer McManus COP1000 COP1000_01

18 So? What are the Problems?
Humans! McManus COP1000

19 Difficulties in Problem Solving?
COP1000 4/22/2017 Difficulties in Problem Solving? Humans must Change the way we think Work through the problem completely Follow a logical sequence of steps Not make hasty decisions Not make haphazard evaluations of potential solutions Finally, are there difficulties that humans have in creating computer programs? Of course! We’re used to thinking quickly and heuristically. Computers can’t think that way. So, humans have to learn to think differently to create programs that will be useful to their users. These changes include: Changing the way we think Working through the problem completely Following a logical sequence of steps Not making hasty decisions Not making haphazard evaluations of potential solutions McManus COP1000 COP1000_01

20 Next? Lesson 2! McManus COP1000


Download ppt "Introduction to Programming Concepts & Logic"

Similar presentations


Ads by Google