Presentation is loading. Please wait.

Presentation is loading. Please wait.

Loops, Databases, Procedures, and Lists

Similar presentations


Presentation on theme: "Loops, Databases, Procedures, and Lists"— Presentation transcript:

1 Loops, Databases, Procedures, and Lists
Dr. José M. Reyes Álamo

2 Outline Loops Databases Procedures Lists

3 Loops

4 Some times you need to repeat…
While the test is TRUE do

5

6 Some times you need to repeat…
For each element in the list do

7

8 Some times you need to repeat…
For each value of i in the range of start to end on steps of step do

9

10 Databases

11 Permanent Storage TinyDB TinyWebDB Persistent storage in your device
Persistent storage in the Web

12 TinyDB Grocery List Item (tag) Quantity (valueToStore) Pasta 1 Box
Sauce 1 Jar

13

14

15 Procedures

16 What is a procedure? A procedure is a named sequence of blocks that encapsulate some functionality and can be called from any place in your app.

17 More about procedures Procedures are an abstraction since they represent a recognizable name for a sequence of lower-lever instructions. In other programming languages procedures are called functions or subprograms.

18 Why are procedures useful?
Procedures can be a good tool to develop large apps. You create new functionality by using procedures. You can use them to break down a large problem or project into more manageable sub problems. While designing the app, you can define a procedure ignoring the details of how it works and refer to the empty procedure. When your finish your design, you can add code to the empty procedures to complete the functionality of your app. You can put chunks of code in one place and call it from various places in your app.

19 Two blocks to define procedures
The procedure block collects a sequence of blocks together. When you create a procedure, AppInventor automatically generates a call block and places it in the My Definitions drawer. You use the call block to invoke the procedure. The procedureWithResults block works similarly to procedure but also returns a result. After the procedure executes, the result is returned to the block connected to the return socket.

20 Refactoring

21 Refactoring Refactoring is programming technique that consist on reorganizing the code, for example create a procedure to substitute redundant code, to make it easier to maintain and easier for the programmers to work with.

22 Lists

23 What is a list? They are variables that instead of holding a single value, they hold several values distinguished by an index. Simple variables score = 100 phoneNumber = Lists bestScores = [100, 98, 89] myContactsPhoneNumbers = [ , , ]

24 What is a list? Simple variables Lists score = 100
phoneNumber = Lists bestScores = [100, 98, 89] myContactsPhoneNumbers = [ , , ]

25 List operations

26 OpenLab and Blackboard
Finish your labs and post them in OpenLab. Finish quizzes on Blackboard. Work on your Project. Study for the Final Exam.


Download ppt "Loops, Databases, Procedures, and Lists"

Similar presentations


Ads by Google