Teaching Concurrent Software Design: A Case Study Using Android

George K. Thiruvathukal, PhD, Konstantin Läufer, George K. Thiruvathukal

TL;DR

This paper presents a pedagogical approach to teaching concurrent software design using Android as a case study. It bridges the gap between theoretical concurrency concepts and practical mobile application development, emphasizing user-centric design and the challenges of building responsive and correct concurrent applications on resource-constrained mobile devices.

What Problem Does This Paper Address?

The paper addresses the challenge of teaching concurrent software design in a way that is relevant and engaging for undergraduate students. Traditional concurrency courses often rely on abstract examples that may not resonate with students' experiences. The authors argue that mobile application development, particularly on Android, offers a rich and practical context for learning these concepts. This context is crucial because mobile devices are now the primary interface for many users, and their applications often involve complex interactions, timers, and asynchronous operations that necessitate a solid understanding of concurrency. The paper aims to provide instructors with a structured module that covers essential concurrency topics through hands-on examples within the Android framework.

Methods

The paper employs a case-study-driven approach, using Android development as the primary vehicle for teaching concurrency. Key methods and techniques discussed include:

  • Event-driven programming: Explaining how GUIs handle user interactions through events and event listeners.
  • Thread safety fundamentals: Introducing concepts like race conditions, deadlocks, and the importance of thread safety using simple Java examples.
  • Synchronization mechanisms: Demonstrating the use of locks (synchronized keyword) to ensure mutual exclusion and serialization.
  • GUI programming model: Detailing the producer-consumer architecture of GUI frameworks, the role of the UI thread (Event Dispatch Thread), and the single-threaded rule for accessing UI components.
  • State machines: Modeling complex interactive behaviors using UML state machine diagrams.
  • Observer pattern: Illustrating how event sources notify listeners.
  • Model-View-Adapter (MVA) architecture: Presenting a common architectural pattern for organizing Android applications.
  • Testing strategies: Discussing unit testing, system testing, and the use of mock objects for testing components with autonomous behavior.
  • Asynchronous tasks: Introducing AsyncTask for offloading long-running operations from the UI thread and ensuring responsiveness.

Datasets

Not discussed in the paper.

Key Insights and Ideas

  • Mobile as a compelling concurrency learning platform: Android's event-driven nature, resource constraints, and ubiquitous presence make it an ideal environment for teaching practical concurrency.
  • The single-threaded rule is paramount for GUI correctness: Accessing UI components exclusively from the UI thread simplifies concurrency management and prevents race conditions, even though it requires careful handling of background operations.
  • Breaking down long-running tasks is key to UI responsiveness: For processor-bound activities, either breaking them into small, manageable chunks executed on the UI thread or offloading them to asynchronous tasks is essential to prevent UI freezes.
  • State machines are powerful for modeling complex interactive behavior: They provide a clear and structured way to represent the dynamic behavior of applications with multiple states and transitions.
  • Testing is crucial for concurrent applications: Thorough testing, including unit and system tests, is necessary to ensure correctness and identify potential concurrency issues.

Key Results

The paper doesn't present quantitative results in the traditional sense of performance benchmarks. Instead, its key "results" are pedagogical:

  • A structured, five-week module on concurrency topics suitable for intermediate to advanced undergraduate courses.
  • Demonstration of how to implement interactive Android applications (e.g., a bounded counter, a countdown timer, a prime checker) that illustrate core concurrency concepts.
  • Practical guidance on managing thread safety, UI responsiveness, and application architecture in the context of mobile development.
  • Examples of how to apply software design patterns (Observer, State, MVA) and testing techniques to build robust concurrent applications.

Limitations and Future Work

  • Scope of concurrency: While the paper focuses on concurrency within the mobile device, it acknowledges that extending coverage to offloading tasks to the cloud is possible.
  • Android-specific details: The examples are primarily Android-centric, which might require adaptation for other mobile platforms.
  • Depth of topics: The paper provides an introduction to various topics; further depth on specific areas like memory consistency issues for SMP hardware is mentioned as a topic for further reading.
  • Future work: The authors suggest extending the module by going into more depth on online examples and exploring techniques for offloading tasks to the cloud.

Summary updated

Abstract

In this article, we explore various parallel and distributed computing topics from a user-centric software engineering perspective. Specifically, in the context of mobile application development, we study the basic building blocks of interactive applications in the form of events, timers, and asynchronous activities, along with related software modeling, architecture, and design topics.
BibTeX
@misc{phd2017teaching,
  author = {George K. Thiruvathukal, PhD and Konstantin Läufer and George K. Thiruvathukal},
  title = {{Teaching Concurrent Software Design: A Case Study Using Android}},
  year = {2017},
  eprint = {1705.02899},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1705.02899},
}
Figure