1 / 14

Getting Help

Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County. Getting Help. CSEE Help Center ITE 201E – hours TBA but usually M-F 10-5, plus evening hours on some days

patia
Download Presentation

Getting Help

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AbstractionIS 101Y/CMSC 101Computational Thinking and DesignTuesday, September 17, 2013Marie desJardinsUniversity of Maryland, Baltimore County

  2. Getting Help • CSEE Help Center • ITE 201E – hours TBA but usually M-F 10-5, plus evening hours on some days • http://www.csee.umbc.edu/resources/computer-science-help-center/ • Tutors may not know Processing, but all know Java (which is similar) and are very helpful! • IS Java Lab (?)

  3. Abstraction • Abstraction is the process of generalizing away from the details of a problem to simplify and focus on its key aspects • We use abstraction for problem solving, design, organization, and simplification • Examples from everyday life: • Smart thermostats • Steering wheels • Email folders and labels • Schedules and calendars • Language!!

  4. Abstraction in Computing • Abstraction is ubiquitous in all computing disciplines • “It’s All Just Bits” • The interpretation (meaning) of data depends on how it is used • The same bit sequence can represent an integer, a decimal number, a sequence of characters, or anything else you might decide it means • Layers of computing hardware, including gates, chips, and components • Programming languages are abstractions of machine language • Functional decomposition == layers of abstraction • Models and simulations: abstractions of real-world phenomena • We can study, analyze, and experiment with models more easily than experimenting on the real world

  5. Programming Enables Problem Solving, Expression, andKnowledge Creation • Programs are written to execute algorithms • Requires an understanding of how instructions are processed • Programs are executed to automate processes • A single program can be run multiple times, on many machines • Executable programs increase the scale of solvable problems • Programming is facilitated by appropriate abstractions • Functions are re-usable programming abstractions • Parameterization can be used to generalize a specific solution • Data abstraction can separate behavior from implementation • APIs and libraries simplify complex programming tasks • Programs are developed and used by people • Developing programs is an iterative process • Finding and eliminating errors is part of the process • Documentation isneeded for maintainable programs

  6. Big Idea:Design • Problem solving often produces multiple possible solutions • Or multiple ways to implement the solution • Designis the process of making those decisions and choices • Design at a high level • Is it cost-effective to automate kidney exchange? • Should we use a relational or object-oriented database? • Design at a low level • How do I structure this function? • What do I call this variable?

  7. Design Processfor Programs • First, understand the problem clearly • Second, write the solution in English • Testits correctness by manually applying it to some simple – and then more complex -- examples • Optionally, “translate” the solution into pseudocode • Advanced programmers will use this step as an abstraction to avoid the syntactic details of a particular programming language • Next, translate the solution into a programming language • Finally, implement (type) and test (carefully!) your solution

  8. Example: Counting • Print the numbers from one to N • N is a variable that can change each time the program is called [an abstraction!!] • For example, “printNumbers (7)” should print:1 2 3 4 5 6 7

  9. Counting in English:Attempt #1 • First attempt at English: Count from one to N Print out each number • Not really an algorithm – just a restatement (what is the primitive action “count”??)

  10. Counting in English:Attempt #2 • Next attempt:Set the variable “current” to 1 Print the value of “current” Add one to “current” If “current” is greater than N, stop Otherwise, go back to “print” step • Turns out that “go to” statements are bad design (for reasons we’ll talk about later) • Let’s try it again, using something that looks more like a loop with a condition

  11. Counting in English:Attempt #3 (almost right!) Set the variable “current” to 1 While “current” is less than N: Print the value of “current” Add one to “current” • Test by hand: what if N = 3? • Boundary cases: what if N = 0? N = -4? • Possible error cases: what if N = 8.73? what if N = “this isn’t a number”?

  12. Counting in English:Processing Version void printNumber (int N) { int current = 1; while (current <= N) {println (current); current = current + 1; } }

  13. Exercise #1: Multiplication • Work in your team – OK to split into smaller groups of 2 or 3 when you’re at the implementation step • How would you multiply two numbers, using only the addition operator? • Understand the problem – state some examples • Write the solution in English • Test the English solution! • Write the solution in Processing • Test the program! • Concepts: iterations, efficiency

  14. Exercise #2: Guessing • With your team, write Processing code to guess a number between 1 and 100 • Remember the algorithmic design process: • Understand the problem – work through some examples by hand! • Write a solution in English and test it – then get a TF or instructor to OK your solution before moving on! • Translate your solution into Processing • Implement, test, and show a TF or instructor! • Be prepared to explain why your approach is a good way to solve the problem

More Related