App Inventor 2
Article Index
App Inventor 2
Chapters 8 - 17
Chapters 18 - 24, Conclusion

Authors:  David Wolber, Hal Abelson, Ellen Spertus and Liz Looney

Publisher: O'Reilly
Pages: 360
ISBN: 9781491906842
Print: 1491906847
Kindle: B00OSKMODE
Audience: Beginner app developers
Rating: 5
Reviewer: Ian Stirk

 

Chapter 18 Programming Your app to Make Decisions: Conditional Blocks

This short chapter shows how decisions can be made using the various components, these include: If blocks, if/else blocks, and Boolean expression blocks (=, >, <, >=, <=, not, and, or). Helpful example usage is provided, including complex nesting of conditionals within conditionals.

 

Chapter 19 Programming Lists of Data

This chapter discusses how related data is often grouped in list structures. Various example code is provided showing: initializing a global variable to a ‘make a list’ block, adding list items, and selecting list items. You need to ensure you don’t go over the list’s maximum index entry – typically you’ll check the required value against the number of items in the list (via the ‘length of list’ property).

The chapter then moves on to discussing dynamic lists, these are typically created by initializing a global variable to ‘create empty list’, items are then added via ‘add items to list’. Finally the chapter then look at displaying a list, and removing an item from a list (via an index). Lists can themselves contain lists as entries, and thus get quite complex.

 

Chapter 20 Repeating Blocks

Code that repeats or is similar, are candidates for processing using loop blocks. This creates code that is typically simpler to understand and easier to maintain. The loop structures discussed are: ‘for each’(for lists) and ‘while’ (more general) blocks. There are some useful code examples for sending SMS text to phone numbers in list, and adding up a list of numbers.

 

Chapter 21 Defining Procedures and Reusing Blocks

This chapter discusses how to extend App Inventor’s functionality by creating your own reusable routines (procedures). These procedures execute a sequence of blocks, provide abstraction (so it’s easier to understand the code), have less code, and improve maintenance (only a single place to amend/test etc). It is possible to build up a library of reusable procedures, however currently you need to copy-and-paste it into each new project. Examples are provided to define and call procedures, and returning data – illustrated with a ‘distance between two points’ app.

 

Chapter 22 Working with Databases

App Inventor uses the TinyDB component to persist data for a single user, or TinyWebDB to persist data between users. In both cases the data is stored as tag/value pairs. Data is stored using the StoreValue block and retrieved using the GetValue block.

Instructions are provided on how to set up your own web database, rather than use the default shared one provided by App Inventor (where the data can be overwritten).

 

Chapter 23 Reading and Responding to Sensors

Smartphones can interact with their environment via sensors to do interesting things. This chapter discusses three sensors: LocationSensor, OrientationSensor, and the AccelerometerSensor.

LocationSensor: this component uses GPS to determine your position as longitude, latitude, and altitude – there are properties of each of these. The LocationChanged block can be used to extract the current values of longitude, latitude, and altitude. The HasLongitudeLatitude block can be used to determine if the device is reading the LocationSensor. Some interesting uses are discussed including: ensure parolees or kids keep within certain location bounds. For the LocationSensor to work you need a clear view of the skies, although Wi-Fi or Cell ID can be used - but are less accurate.

OrientationSensor: this component is useful for tilting, showing a compass, and directions. It has 5 properties (Roll [left/right], Pitch [up/back], Azimuth [compass], Magnitude [rolling ball speed], Angle [rolling ball angle]). An OrientationChanged event example is used to show these 5 properties. Another example shows the rolling of an image left and right by tilting the screen.

AccelerometerSensor: this component shows the rate of change of velocity, taking gravity into account (so dropping freefall gives value of 0). There is an AccelerationChanged event (often used when shaking the phone), having x, y, and z properties. Example code is given for detecting freefall.

This is a very useful and interesting chapter, with plenty of example code given. Including screenshots of the app in use would have been useful.

 

Chapter 24 Communicating with the Web

The web and mobiles have changed how we do things e.g. check bank account at night. It is possible to mix and mash ideas e.g. mix population data with Google maps via its web service. Although web sites can be awkward and slow to use on mobiles, dedicated apps often get around these limitations. This chapter shows how to use web pages within apps, together with the use of APIs.

The WebViewer component lets you embed a web page within an app, giving you more control over what user can do with web page. An alternative to the WebViewer component, is the Web component, this facilitates low level communication (via HTTP get, put, post) between your app and a web service. You can extract data from the web service and display/format accordingly. Example usage shows how to set the Web.URL property, and then call a HTTP method. The example provided accesses stock prices from Yahoo Finance. The Web.GotText event gets data from the web service.

The chapter ends with a brief look at the TinyWebDB and TinyWebDB-compliant APIs. The Web component is ok for accessing simple APIs, however for a more complex set up a TinyWebDB-compliant web service should be used. A useful link to http://appinventorapi.com/ is provided for more information.

 

Conclusion

This is a fun book, suitable for people with or without prior programming experience, for ages 10 to 70. It is easy to read, contains plenty of diagrams, good explanations of the underlying concepts, has useful links between chapters, and uses visually appealing colour throughout. Of course if you have some programming skills already, the book becomes even easier to progress through.

The first part of the book provides consistent step-by-step tutorials on how to develop various types of app (e.g. games, quizzes, location-aware apps), which increase in complexity as the book proceeds. Each chapter ends with helpful ideas on how to extend the app, together with a useful summary. The second part of the book consolidates what has been discussed in the tutorials and provides a more technical/reference/programming approach to what has been learnt.

A small number of the figures and code blocks were too small to read easily. It might have been useful to show screenshots of the apps running or being tested. Sometimes there was a problem with hyphenation (words break in awkward places, without hyphenation). A link to the MIT site for documentation would have been useful (i.e. http://ai2.appinventor.mit.edu/reference/)

If you have an idea for your own app, reading this book will help you create it. Following along with the book’s apps (and their extensions) will surely to give you further ideas. The ideas it contains should prove especially useful for teachers. And yes, I created a few apps for myself with this tool.

A free version of all the chapters in the book is available here: www.appinventor.org/book2, although the authors suggest you buy the book to support their work.

If you want to learn how to create Android mobile apps, and/or want a gentle introduction to programming, I highly recommend this book. Who knows, you might enjoy it so much that it will encourage you to take up a career in programming!

 

Banner
 


Seriously Good Software

Author: Marco Faella
Publisher: Manning
Date: March 2020
Pages: 328
ISBN: 978-1617296291
Print: 1617296295
Kindle: B09782DKN8
Audience: Relatively experienced Java programmers
Rating: 4.5
Reviewer: Mike James
Don't we all want to write seriously good software?



C++ Programming, 6th Ed (In Easy Steps)

Author: Mike McGrath
Publisher: In Easy Steps
Date: April 2022
Pages: 192
ISBN: 978-1840789713
Print: 1840789719
Kindle: B09V2T9SJD
Audience: Developers wanting to learn C++
Reviewer: Mike James
This is the 6th edition of a slim book on C++. Can you really learn C++ in easy steps?


More Reviews

 



Last Updated ( Sunday, 04 January 2015 )