Mad 1 Week 1
Mad 1 Week 1
What is an "App"?
Types of Apps
Desktop Apps
● Characteristics:
○ Standalone programs (e.g., editors, word processors, web browsers, mail
clients).
○ Often functional offline with local data storage.
○ May include network connectivity for updates or features.
● Development:
○ Utilize Software Development Kits (SDKs).
○ Often OS-specific frameworks.
Mobile Apps
● Characteristics:
○ Targeted for phones or tablets with platform-specific constraints.
○ Constraints:
■ Limited screen space.
■ Touch/audio/camera interactions.
■ Restricted memory/processing power.
■ Battery consumption considerations.
○ Often network-dependent.
● Development Frameworks:
○ OS-specific.
○ Cross-platform tools (e.g., React Native, Flutter).
Web Apps
● Characteristics:
○ Platform-independent, works across devices and operating systems.
○ Strongly reliant on network connectivity.
○ Offline workarounds can be implemented.
● Core Components:
○ Storage: Data handling and formats.
○ Computation: Indexing, processing, and calculations.
○ Presentation: User interfaces and rendering.
● Example: Email Client
○ Storage: Server-side email storage, file formats.
○ Compute: Email indexing, search functions.
○ Presentation: Display email list, rendering individual messages.
Platforms
● Desktop:
○ Input: Keyboard, mouse, video.
○ Paradigm: Folders, files, documents.
● Mobile:
○ Interfaces: Touchscreen, voice, tilt sensors, camera.
○ Self-contained apps for specific functionalities.
● Web-based:
○ Datacenter storage with persistent cloud-based access.
○ Multi-device usage and synchronization.
● Embedded:
○ Focused on single functions, e.g., IoT devices.
Architectures
Client-Server Model
● Server:
○ Stores and processes data.
○ Provides data upon request.
● Client:
○ Requests data and displays it to the user.
○ Handles user interaction.
● Network:
○ Connects clients and servers.
○ Can be local or internet-based.
● Examples:
○ Email, messaging apps, web browsers, databases.
● Characteristics:
○ All peers have equivalent roles, though some may take on special roles
(e.g., master nodes).
○ Error tolerance with mechanisms for role reassignment on failure.
● Examples:
○ Bittorrent, blockchain systems, distributed file storage like IPFS.
● Common Patterns:
○ Model-View-Controller (MVC):
■ Model: Core data handling, e.g., databases, indexing.
■ View: User interface for interaction.
■ Controller: Business logic managing data manipulation.
○ Other Patterns:
■ Model-View-Adapter, Model-View-Presenter, MVVM, Hierarchical
MVC.
○ Purpose: Provide reusable solutions to common design problems.
Web-Based Platforms
● Advantages:
○ Cross-platform compatibility across OS and hardware.
○ Sound underlying principles with clear constraints and costs.
Historical Background
Web Mechanics
Web Servers
● Role:
○ Listen on a fixed port, process incoming requests, and return responses.
● Protocol:
○ Govern communication between clients and servers.
● Definition:
○ Text-based protocol for exchanging hypertext documents.
● Structure:
○ Requests from clients (e.g., GET / HTTP/1.1).
○ Responses from servers with headers and data.
Debugging Tools
● curl:
○ Command-line tool for making HTTP requests.
○ Verbose output shows headers and response details.
● Example:
curl -v http://localhost:1500
Protocols
HTTP Basics
Loopback Address
● IPv4: 127.0.0.1
● IPv6: ::1
Packets sent here are processed locally and don't leave the computer.
Type Purpose
Informational
Code Description
100 Continue: Request is in
progress.
Successful
Code Description
Redirection
Code Description
Client Errors
Code Description
Server Errors
Code Description
Latency
Latency is the total time it takes for a request to travel from the client to the server and
back.
● Speed of Light:
○ In vacuum: 3 × 10⁸ m/s.
○ In copper cable: Approx 2 × 10⁸ m/s.
● Time Approximation:
○ 1000 km takes 5 ms (calculated as: 1,000,000 m ÷ 2 × 10⁸ m/s = 5 ms).
● Example Calculation:
○ Distance: 200 km.
○ Time one way = 200 km ÷ 1000 km × 5 ms = 1 ms.
○ Round trip = 10 ms.
● Requests per Second:
○ One round trip takes 20 ms.
○ Max requests per second = 1000 ms ÷ 20 ms = 50 requests/sec.
Response Size
Response size refers to how much data is sent from the server to the client for a single
request.
Example:
Simplified Calculation: