event-drive programming & mobile app...

19
Mobile & Pervasive Computing CSC 332 - Spring 2016 Event-Drive Programming & Mobile App Frameworks

Upload: others

Post on 16-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Mobile & Pervasive ComputingCSC 332 - Spring 2016

Event-Drive Programming & Mobile App Frameworks

Page 2: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Outline• Sequential programming

• Event-driven programming

• Model-view-controller

• Mobile programming

• iOS programming framework

• Android programming framework

Page 3: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Sequential Programming• Flow of the program

• Execution starts at first line of main

• Statements executed in sequential order, from top to bottom

• Program ends when main function terminates

• Examples:

• Most Java and C++ programs developed in 111, 112, 221, 222

• Generally blocking calls

• Not much emphasis on exception handling or testing

• Applications

• Most often in problems where the output depends on set inputs and where computation proceeds without user intervention

Page 4: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Event-Driven Programming• Flow of the program

• Determined by events from sensor readings, messages from other programs or threads

• Event: an input action caused by mouse click, keyboard click, touch, etc.

• Main loop

• Part of the app that listens for events and then triggers an appropriate callback function

• Callback functions or event handlers

• A function or method invoked to respond to the event

• It generally receives information about the event that trigger it

• Applications

• Dominant paradigm for graphical user interfaces, web applications, etc.

Page 5: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Event-Driven Programming• Programming frameworks/toolkits/libraries

• Provide the main loop, event handling mechanism, and other parts associated with control

• Some examples:

• PyQT: QT library for Python

• Swing for Java

• Tk for Python, C, C++,

• FLTK for C++

• MFC in Windows

• Designers and programmers develop

• The user experience (UX) and user interface (UI) design

• Callback functions and appropriate use of framework APIs

• Other functions not necessarily associated with events

• Most often implemented using object-oriented languages

• Object-oriented design

• Lots of non-blocking calls, threads, and exception handling

Page 6: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Model-View-Controller• What is it?

• A software design pattern used for developing user interfaces

• Software design pattern: general and reusable solution for common software design problems

• For more see: “Design Patterns” by Gamma et al., Addison-Wesley, 94 and “Head First Design Patterns” by Freeman et al., O’Reilly, 2004

• Code organization

•Model• Manages the data, receives input from the controller

•View• Determines what the user will see, displays data in some format

•Controller• Receives and validates input, passes the input to the model

Page 7: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

MVC Interactions

• View is a collection of objects drawn in the screen (requires good user interface and user experience design)

• Controller is a collection of callback functions that update the view or the model

• Model is a collection of functions that manage the data, often involve a database backend

Model

ViewController

Draws and presents to user

Key press, touch,user input

Manipulates Updates

Page 8: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Mobile Programming• Involves more than event-driven programming and

MVC

• Basic fundamental frameworks

• Data types, resource management, notifications, file system and serialization, processes and threads, networking

• Graphics frameworks

• Images, animations, vision, maps

• Services frameworks

• Database, location, sound, motion, machine learning, language processing, speech, camera & video

• Other less common tools

• Bluetooth, NFC, ad support, authentication

Page 9: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

iOS• Evolution

• iPhone OS released in 2007

• iPhone OS SDK released in 2008 (also App Store)

• iOS and SDK for all portable devices released in 2010

• Features

• Multi-touch gestures & direct manipulation of digital objects

• Multi-touch gesture: sequence of single touch inputs (UIEvent)

• Gesture recognition (UIGestureRecognizer)

• Layered architecture• Cocoa Touch layer

• Media layer

• Core Services layer

• Core OS layer

Page 10: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Layered Architecture

BLE, external accessories, Accelerate

String management, threads, sockets datatypes, network, iCloud, SQLite, XML parsing

Graphics, audio, video, and streaming

UIKit, multi-touch input, multi-tasking, in-app ads, push notifications, maps, printing & file sharing

https://codeingwithios.blogspot.com/2017/09/ios-layered-architecture.html

Page 11: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

MVC in iOS

Page 12: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Development Tools• Languages

• Objective-C: object-oriented extension of C

• Swift: open-source, released in 2014 as alternative to Objective-C

• Integrated development environments• Xcode by Apple

• Appcode by Jetbrains

• iOS Simulator

• Simulator for iPhone and iPad devices used for testing

• Simulates actions such as touch, rotating, and shaking

• iCloud

• Remote server storage service

• Provides document storage and key-value data storage

Page 14: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Android• Evolution

• Mobile platform developed by Android Inc. in 1999

• Acquired by Google in 2005

• Open Handset Alliance announced in 2007 (including Samsung, Motorola, HTC, Intel, Qualcomm, Texas Instruments)

• Android v 1.0 launched in 2008

• Rapid growth made it one of dominant platforms

• Features

• Touch inputs & direct manipulation

• Linux based

• Application development support through Java and Kotlin primarily

• Platform architecture

• Applications

• Applications framework

• System libraries and Android runtime

• Kernel

Page 15: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Android Architecture

Linux kernel, threading, low-level memory management, hardware drivers

ART: AOT and JIT compilation, garbage collectionLibraries: Native code exposed through Java APIs

Java APIs for views, management, and access to data from other apps

Core apps for mail, messaging, calendar, internet browsing, contacts, etc. Can be used by other apps

HAL provides interfaces to higher-level APIs

https://www.studytonight.com/android/android-architecture

Page 16: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Model-View-Presenter in Android• Model-View-Presenter

• Activity = presenter

• Handles display of a window and its views

• Manages communication between model and views

• XML layout = view

• Contains all the UI components

• Handles events for these components

• Other classes = model

• Handle database access or other domain specific data

https://www.spaceotechnologies.com/mvp-android-architectural-pattern/

Page 17: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Development Tools• Languages

• Java: object-oriented general purpose language

• Kotlin: open-source, released in 2017 by JetBrains & Google

• Integrated development environments

• Android Studio: official IDE released in 2014, built on top of IntelliJ

• IntelliJ Idea: released in 2001 by JetBrains

• Eclipse: released in 2001 by the Eclipse Foundation, application support for many languages such as C, C++, Java, etc.

• Android Emulator

• Simulates functionality in numerous Android devices including phone calls, text messages, etc

• Heavily used during testing

Page 18: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Some Useful Online Resources

• Android’s developer site

• Android studio

• Android developer user guide

• Android developer training courses

• User interface design

• Android user interface guidelines

Page 19: Event-Drive Programming & Mobile App Frameworkscsweb.cs.wfu.edu/~pauca/csc332/3-5-MobileAppFrameworks.pdf · Event-Driven Programming • Programming frameworks/toolkits/libraries

Metacognition• Understanding well enough to teach to others?

• Events

• Event-driven programming

• Main loop

• Callback functions

• Model-View-Controller

• iOS layered architecture

• Android platform architecture

• Model-View-Presenter

• Some additional important concepts

• Software design patterns

• User experience (UX) & user interface (UI)

• Blocking & non-blocking calls

• Threads