1 / 26

Loops, Databases, Procedures, and Lists

Dr. José M. Reyes Álamo. Loops, Databases, Procedures, and Lists. Outline. Loops Databases Procedures Lists. Loops. Some times you need to repeat…. While the test is TRUE do. Some times you need to repeat…. For each element in the list do. Some times you need to repeat….

vanna-petty
Download Presentation

Loops, Databases, Procedures, and Lists

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. Dr. José M. Reyes Álamo Loops, Databases, Procedures, and Lists

  2. Outline • Loops • Databases • Procedures • Lists

  3. Loops

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

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

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

  7. Databases

  8. Permanent Storage • TinyDB • Persistent storage in your device • TinyWebDB • Persistent storage in the Web

  9. TinyDB Grocery List

  10. Procedures

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

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

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

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

  15. Refactoring

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

  17. Lists

  18. 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 = 201-122-4322 Lists bestScores = [100, 98, 89] myContactsPhoneNumbers = [201-122-4322, 803-234-3293, 977-121-5383]

  19. What is a list? Simple variables score = 100 phoneNumber = 201-122-4322 Lists bestScores = [100, 98, 89] myContactsPhoneNumbers = [201-122-4322, 803-234-3293, 977-121-5383]

  20. List operations

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

More Related