Functions and Top-Down Design

Slides:



Advertisements
Similar presentations
Modular Design Using Subroutines (functions later)
Advertisements

Chapter 3: Modularization
Chapter 2: Modularization
GRAMMAR SCHOOL 1567 RAMILIA TIKHONOVA MOSCOW 1. 2.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Top-Down Design and Modular Development
Program Design CMSC 201. Motivation We’ve talked a lot about certain ‘good habits’ we’d like you guys to get in while writing code. There are two main.
AP Computer Science Principles Data Abstraction and Procedural Abstraction Curriculum Module.
Protocols for Mathematics Performance Tasks PD Protocol: Preparing for the Performance Task Classroom Protocol: Scaffolding Performance Tasks PD Protocol:
Patterns and Reuse. Patterns Reuse of Analysis and Design.
Top-Down Design and Modular Development. The process of developing methods for objects is mostly a process of developing algorithms; each method is an.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
JavaScript: API’s, Parameters and Creating Functions with Parameters
AP CSP: Pixelation – B&W/Color Images
AP CSP: Creating Functions & Top-Down Design
JavaScript/ App Lab Programming:
Vocabulary byte - The technical term for 8 bits of data.
AP CSP: Sending Binary Messages with the Internet Simulator
HTTP and Abstraction on the Internet
HTTP AND ABSTRACTION ON THE INTERNET
THE INTERNET IS FOR EVERYONE
UNIT 2 – LESSON 3 Encoding B&W Images.
Lesson 2-3 AP Computer Science Principles
AP CSP: Encode an Experience
HTTP and Abstraction on the Internet
PRACTICE PERFORMANCE TASK (PT) FLASH TALK : THE INTERNET AND SOCIETY
Literacy Coach Top 10 Beliefs
THE NEED FOR ADDRESSING
THE NEED FOR DNS DOMAIN NAME SYSTEM
Lesson 2-9 AP Computer Science Principles
Vocabulary Prototype: A preliminary sketch of an idea or model for something new. It’s the original drawing from which something real might be built or.
UNIT 2 – LESSON 4 Encoding Color Images.
Functions and Top-Down Design
UNIT 2 – LESSON 6 ENCODE AN EXPERIENCE.
Unit 3 lesson 2&3 The Need For Algorithms- Creativity in Algorithms
UNIT 3 – LESSON 5 Creating Functions.
UNIT 1 – LESSON 6 SENDING NUMBERS.
CS Principles U2L3 Encoding B&W Images.
The Need for Programming Languages
Welcome Back 11x1b If you could put your homework tasks (completed over the Easter holidays) in a neat pile in the middle of your tables- I will collect.
The Need for Algorithms 2 days
Good and Bad Data Visualizations
APIs and Function Parameters
Vocabulary Prototype: A preliminary sketch of an idea or model for something new. It’s the original drawing from which something real might be built or.
AP CSP: Bytes, File Sizes, and Text Compression
Vocabulary byte - The technical term for 8 bits of data.
Sending Bits on the Internet
Practice PT - Design a Digital Scene 3 days
Measuring Polygon Side Lengths
DAY 1 – CREATE PERFORMANCE TASK
Teaching Computing to GCSE
Decomposition.
Creativity in Algorithms
SENDING BINARY MESSAGES WITH THE INTERNET SIMULATOR
Lesson 16: Functions with Return Values
Lesson 15: Processing Arrays
UNIT 3 CHAPTER 1 LESSON 4 Using Simple Commands.
LearnZillion Notes: --This is your hook. Start with a question to draw the student in. We want that student saying, “huh, how do you do X?” Try to be specific.
Creating Functions with Parameters
LearnZillion Notes: --This is your hook. Start with a question to draw the student in. We want that student saying, “huh, how do you do X?” Try to be specific.
Unit 3: Lesson 6 & 7- Functions and Top-Down Design / APIs and Function Parameters Day 27.
HTTP and Abstraction on the Internet / The Need for DNS
LearnZillion Notes: --This is your hook. Start with a question to draw the student in. We want that student saying, “huh, how do you do X?” Try to be specific.
Rapid Research - Format Showdown
Text Structure English 7 & 8.
Vocabulary Algorithm - A precise sequence of instructions for processes that can be executed by a computer Low level programming language: A programming.
Computational Thinking
Text Structure English 7 & 8.
Top-Down Design & JSP Skill Area Part D
Modules, Subroutines, Procedures, Functions, or Methods
Presentation transcript:

Functions and Top-Down Design UNIT 3 – LESSON 6 Functions and Top-Down Design

VOCABULARY ALERT! Abstraction - Pulling out specific differences to make one solution work for multiple problems. Function - A piece of code that you can easily call over and over again. Top Down Design - a problem solving approach (also known as stepwise design) in which you break down a system to gain insight into the sub-systems that make it up.

WHY ARE WE LEARNING THIS?  The AP Performance Task called “CREATE” requires students to "develop an abstraction to manage complexity of your program.“ CSP framework is: "2.2.1 Develop an abstraction when writing a program...“ Developing abstractions starts with writing reusable functions (or procedures) in your code that encapsulate and give a name to multi-line segments of code that other parts of your code calls upon.

TOP DOWN DESIGN A technique for deciding what functions you should write is to look at the problem with a "top-down design" perspective.  process of creating software begins long before the first lines of code are written Breaking a problem down into layers of sub-tasks, and writing well-named functions that solve those tasks is a creative act of abstraction It also leads to good code that is more efficient, easier to read, and therefore easier to debug when problems arise.

TEAM WORK In professional settings, teams of people first identify the problems and sub-problems the particular software will be addressing and how it will be used. This approach to designing software is critical when facing large- scale programming tasks. Once the problem is well understood, it can be broken into parts that teams or individual programmers can begin to work on solving at the same time. Full software systems take advantage of the power of abstraction; each programmer in a team can write code, assuming the sub- problems will be solved and written by other teammates.

What Does Efficiency Mean? It could mean the total number of primitive operations performed by the turtle. It could mean number of lines of code. It could hinge on the ability to reuse code within your own code. It could be about the speed and clarity with which you can write the program.

Efficiency is an interesting thing to think about, but functions also introduce the ability to leverage the power of abstraction: when we write a function, it solves a small piece of a bigger problem. Having the small problem solved allows us to ignore its details and focus on bigger problems or tasks. Today we’ll get more practice with thinking about how to break problems down into useful functions.

Everyone get into pairs Everyone gets  Top-Down Design – Worksheet Code Studio is NOT turned on yet!

Come up with descriptive function names that give insight to your thinking. A high-level function named something like drawThing is not that great. Something like snowflake or crosshairs or antenna is better because it lets the reader see what the programmer is thinking.

Work in pairs, but fill out your own sheet Work in pairs, but fill out your own sheet. Read the first page of the worksheet that describes the top-down problem solving process. Design a solution to the problem on the second page by writing down the functions you would write to solve the problem. After a pair has come up with a solution on paper, compare with another group to see similarities and differences.

Remember: The functions you design can call one another Remember: The functions you design can call one another. This is how you create layers of abstraction. Functions should be given names that are descriptive and meaningful. Your program should be kicked off with a single call to a function that makes calls to subsequent functions.

Open up Code Studio Each partner follows the plan you made to make this image:

Next, make the grid, but use functions – your code should be much, much shorter!

Some points about functions and abstraction: When we layer functions - with functions that call other functions - we are creating layers of abstraction. In programming, writing functions helps us create layers of abstraction that allow us to design and create increasingly complex systems. We’ve seen layers of abstraction before in the design of Internet protocols, or in the binary encoding of information. Solving a fundamental piece of a problem that can be reliably reused in a different context frees us to think about more complex problems because we can trust the piece that has been solved and don’t have to worry about its details. Solving small problems - like how to send a single bit from one place to another - allows us to think about bigger problems, like sending numbers, or text, or images, to multiple people, over networks, in packets...etc., etc., etc.

Check in your snowflake and grid programs showing functions for a grade Reflections and Assessments in Code Studio You have Homework!