Mobile Programming Lecture Notes PDF
Document Details
Uploaded by Deleted User
Tags
Summary
These lecture notes provide an overview of mobile programming concepts. Topics covered include class rules, course assessment, mobile devices, mobile application development, and mobile platforms. The document also includes details on mobile operating systems, advantages and disadvantages of MVC and MVVM architectures, and good practices for mobile app development.
Full Transcript
10/18/2024 Mobile Programming 1 Class Rules You can do anything except: Make noises (chatting, singing…) Feel free to interrupt me if you have questions. According to the university policy, taking attendance is needed. Important: you...
10/18/2024 Mobile Programming 1 Class Rules You can do anything except: Make noises (chatting, singing…) Feel free to interrupt me if you have questions. According to the university policy, taking attendance is needed. Important: you are required to have an 80% attendance to be able to seat for the final exam. 2 2 1 10/18/2024 Course Assessment Temporary according to the situation: Final exam:50% Midterm: 20%, Quizzes: 10% Project: 20%, 2-3 members per group; report and presentation are required. Important:cheating and plagiarism will get no marks. 3 3 A few suggestions…. Your final grade is based on points – not on an accumulation of grades. You start the class with zero points and earn your way to your final grade If you have an issue or problem, communicate – send me an email If you know you’re not going to meet the deadline for a quiz or assignment – email me BEFORE the deadline 4 4 2 10/18/2024 WHAT IS A MOBILE DEVICE? A mobile device is a portable handheld computer designed to connect to the Internet. It is easy and quick to use and can be taken and used everywhere at any time. Some mobile devices are more powerful than others, which allows users to do many things that can be done with a desktop or laptop computer. The primary mobile devices currently available are: Tablet computers, E-readers, Smartphones 5 What is Mobile Application Development? Mobile app development refers to creating software applications that run on mobile devices such as smartphones and tablets. The software can be designed for various operating systems (OS), such as Android, iOS, or others. 6 3 10/18/2024 Types of Mobile Applications Native Apps: Explicitly built for a particular operating system (e.g., Android, iOS) using platform-specific languages like Java/Kotlin for Android and Swift/Objective C for iOS. These apps are installed directly from app stores and can leverage all device- specific features. Hybrid Apps: These are cross-platform apps developed using web technologies (HTML, CSS, JavaScript) and frameworks like React Native, Ionic, and Cordova. They are essentially web apps wrapped in a native container, allowing them to be installed like native apps. Web Apps: Brows-based apps accessed through mobile browsers (e.g., Progressive Web Apps PWAs). These do not require installation but provide limited access to device hardware. 7 Mobile Platforms Android: Developed by Google, it is the world’s most widely used mobile OS. It is written in Java, Kotlin, and C++ and has an open ecosystem. iOS: Apple’s proprietary OS for iPhones and iPads. It is known for its security, smooth user experience, and strict app store guidelines. Other platforms : Windows Mobile and Blackberry have largely been phased out, but their legacy and influence on mobile development are worth mentioning. 8 4 10/18/2024 Mobile Operating Systems 1. Palm OS 2. WML 3. J2ME/JME (Java 2 Platform, Micro Edition) 4. Windows 5. Android 6. IOS 9 ANDROID Google formed the Open Handset Alliance with 86 hardware, software, and telecom companies, which developed and announced Android as an open-source mobile OS. It has been used as the OS for mobile devices such as tablets and smartphones. This OS is now being used by many handheld device manufacturers including Samsung, Motorola, HTC, LG and Sony. 10 5 10/18/2024 ANDROID PROS You can develop on any platform. The environment is more open: call history is available to all apps; notifications between apps and content sharing are possible; apps can be installed from any source. Apps can be self-signed. You can publish to Google Play for a one-off fee of $25. 11 ANDROID CONS Fragmentation between different versions of the OS, which are often significantly different, is a significant problem. Upgrades are passed through manufacturers and carriers who add their customizations, delaying the process. App developers must try accommodating users whose OS versions are years apart. Graphics are often slower. 12 6 10/18/2024 IOS iPhone OS is based on Unix OS and was renamed ‘iOS,’ released in 2007. Apple initially developed this OS for the iPhone and later extended it to iPad, iPod Touch, and Apple TV. It consists of four layers, namely the Core OS layer, the Core Services layer, the Media layer, and the Cocoa Touch layer. The iOS user interface is based on a multitouch gesture concept. 13 IOS PROS Less fragmentation arising from upgrades – 80% of users are on the latest version. New features are usually available very quickly. The OpenGL API is standard for graphics across the platform. Navigation is nonprescriptive–you can decide how users will navigate within your app. 14 7 10/18/2024 IOS CONS iOS is a more closed platform with limited possibilities for inter-app communication. The App Store automatically rejects private APIs. Development can only be done on a Mac. To publish apps, you need to subscribe to the iOS developer program (annual fee), and the intricate App Store guidelines will keep you engaged. The process of signing apps is nontrivial. You need an Apple certificate to install it on your device. 15 App Stores & Monetization Google Play Store and Apple App Store are the two dominant platforms for app distribution. Monetization models: Free apps with ads (popular in Android due to user demographics). Freemium apps: free to download but with in-app purchases (common in games and subscription-based apps). Paid apps: Less common, especially on Android. Subscriptions: A growing trend, especially for media, content, or service apps (e.g., Netflix, Spotify, news apps). 16 8 10/18/2024 Mobile App Development Lifecycle Ideation & Planning Design (UI/UX) Development Testing Deployment Maintenance 17 Programming Languages for Mobile Development Java Swift JavaScript Dart 18 9 10/18/2024 Mobile Development Frameworks Android Studio: Official integrated development environment (IDE) for Android. It offers a built-in emulator, code editing, and testing tools. Xcode: Apple’s official IDE for iOS/macOS development. It includes an interface builder, testing, and debugging tools. React Native: Enables building cross platform apps using JavaScript. Allows for faster development since you write the code once and run it on both Android and iOS. Flutter: Google’s cross-platform UI toolkit that allows you to create natively compiled apps for mobile, web, and desktop from a single codebase. It uses widgets and is highly customizable. 19 Mobile App Architecture MVC (Model-View-Controller) Architecture MVVM (Model-View-ViewModel) Architecture Clean Architecture 20 10 10/18/2024 MVC Architecture 21 MVC Architecture Model (Data and Business Logic): Manages the data and business logic of the application. Represents the state of the app, independent of the UI. Updates the controller when data changes. 22 11 10/18/2024 MVC Architecture View (User Interface) The user interface (UI) component that represents the data. It displays the model’s data and handles what the user sees. Receives updates from the controller when data changes. 23 MVC Architecture Controller (Application Logic) The intermediary between the model and the view. It processes user input (e.g., taps, gestures) and translates it into actions that update the model or view. Controls the flow of data to the view. 24 12 10/18/2024 Advantages of MVC Separation of Concerns. Reusability Maintainability Testability 25 Disadvantages of MVC Architecture Increased Complexity Tight Coupling Between View and Controller: 26 13 10/18/2024 Example Scenario in an E-Commerce App (MVC Implementation) 1. Model: 1. Holds the data about products (name, price, description, etc.). 2. Contains the business logic for adding items to the cart or applying discounts. 2. View: 1. Displays the product list, cart summary, and purchase button to the user. 2. Shows dynamic changes when new items are added to the cart or removed. 3. Controller: 1. Listens for the user clicking the "Add to Cart" button. 2. Updates the Model to reflect the new item in the cart. 3. Instructs the View to update and show the new item count and price. 27 MVVM Architecture 28 14 10/18/2024 MVVM Architecture Model (Data and Business Logic) Manages the app’s data and business logic, similar to MVC. Data is fetched from the database, API, or any other source. 29 MVVM Architecture View (User Interface): The UI layer of the app represents the data to the user. It is passive in MVVM, meaning it doesn’t contain any business logic and observes the ViewModel. 30 15 10/18/2024 MVVM Architecture ViewModel (Presentation Logic): Acts as a bridge between the View and the Model. Responsible for handling the presentation logic and interacting with the Model to fetch and manage data. 31 Advantages of MVVM Architecture Separation of Concerns Two-Way Data Binding Testability Reusable Components Reduced Code in View 32 16 10/18/2024 Disadvantages of MVVM Architecture Complexity Learning Curve Overhead for Small Apps 33 Example Scenario in a Weather App (MVVM Implementation) 1. Model: 1. Fetches weather data from an API (e.g., temperature, conditions). 2. Stores the fetched data in a local cache or database for offline use. 2. ViewModel: 1. Retrieves the weather data from the Model. 2. Formats the weather data for display (e.g., converting temperatures, formatting dates). 3. Exposes the weather data through observable properties for the View to bind to. 3. View: 1. Displays the weather data, such as the current temperature and forecast. 2. Automatically updates when the ViewModel’s weather data changes (e.g., after a new API request). 3. Allows the user to trigger actions like refreshing the weather data or changing location settings. 34 17 10/18/2024 Clean Architecture 35 Clean Architecture Entities (Domain Layer): The innermost layer of the application. Contains the core business logic and rules, independent of any UI or data source. Highly reusable across different parts of the app and easily testable. 36 18 10/18/2024 Clean Architecture Use Cases (Application Layer): This layer contains the specific application logic (interactors). It defines how the business rules interact with one another. Use cases to orchestrate the data flow between the UI and the Entities. 37 Clean Architecture Interface Adapters (Presentation Layer): The layer where ViewModels, Presenters, or Controllers reside. It transforms and prepares the data from the Use Cases for display in the View. Keep the UI separate from the underlying data sources and business logic. 38 19 10/18/2024 Clean Architecture Frameworks & Drivers (Infrastructure Layer): The outermost layer of Clean Architecture. It includes implementing data sources (APIs, databases), frameworks, and UI. This layer should depend on the inner layers, not the other way around (inversion of control principle). 39 Advantages of Clean Architecture Separation of Concerns Testability Scalability 40 20 10/18/2024 Disadvantages of Clean Architecture Complexity Learning Curve More Code 41 Example Scenario in an E-Commerce App (Clean Architecture Implementation) Entity: A Product entity with attributes such as id, name, price, stock, and methods like applyDiscount(). Use Case: AddProductToCart interacts with the Product entity to check stock and calculate the total price. It also prepares the cart for checkout by updating the repository. Interface Adapter: Controller captures the "Add to Cart" button press from the UI and triggers the AddProductToCart use case. Presenter prepares the cart’s total price and product information to display in the UI. Frameworks & Drivers: The UI Framework (e.g., Android/iOS) displays the updated cart. A Database stores the cart’s content for persistence. 42 21 10/18/2024 Good Practices UI/UX in Mobile Apps Mobile App Performance Optimization Security in Mobile Applications Testing Mobile Applications Deploying and Publishing Mobile Apps 43 Attendance 44 22 10/18/2024 Attendance 45 23