19 - Application Design & Development
486 words
2 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# 19 - Application Design & Development ## 🎯 Learning Objectives After reading this topic, you will be able to: - Describe the 3-tier architecture (presentation, business logic, data) - Explain how applications connect to databases (ODBC, JDBC, Python DB-API) - Understand cookies and sessions for state management -...

19 - Application Design & Development
🎯 Learning Objectives
After reading this topic, you will be able to:
- Describe the 3-tier architecture (presentation, business logic, data)
- Explain how applications connect to databases (ODBC, JDBC, Python DB-API)
- Understand cookies and sessions for state management
- List RAD frameworks and their advantages
📖 Core Content
19.1 3-Tier Architecture
(Diagram)
| Tier | Role | Technologies |
|---|---|---|
| Presentation | User interface, display | HTML, CSS, JavaScript, React |
| Business Logic | Application logic, validation | Python (Flask/Django), Java, Node.js |
| Data Access | Data storage and retrieval | PostgreSQL, MySQL, Oracle |
Advantages:
- Modularity: Each tier can be developed independently
- Scalability: Scale each tier separately
- Security: Data tier is never exposed to clients
19.2 Database Connectivity
ODBC (Open Database Connectivity)
- Standard API for accessing databases from C/C++
- Database-independent: same code works for different DBMS
- Uses a driver manager to translate calls
JDBC (Java Database Connectivity)
- Java equivalent of ODBC
- Four types of drivers (Type 1-4), with Type 4 (pure Java) being most common
Python DB-API
Standard interface for Python database access:
pythonimport psycopg2 # PostgreSQL adapter conn = psycopg2.connect( host="localhost", database="university", user="postgres", password="secret" ) cur = conn.cursor() cur.execute("SELECT name, salary FROM instructor WHERE dept_name = %s", ('CS',)) results = cur.fetchall() for row in results: print(f"Name: {row[0]}, Salary: {row[1]}") cur.close() conn.close()
Other Python drivers:
pg8000, ocpgdp, PyGreSQL19.3 Cookies and Sessions
| Concept | Location | Purpose |
|---|---|---|
| Cookie | Client-side (browser) | Stores small data (session ID, preferences) |
| Session | Server-side | Stores user state during interaction |
How it works:
- User logs in → Server creates a session, sends a session cookie
- Browser sends cookie with each request → Server looks up session
- User logs out → Session destroyed, cookie expires
19.4 WSGI (Web Server Gateway Interface)
Python standard for connecting web servers (Apache, Nginx) to Python applications (Flask, Django).
19.5 RAD Frameworks
| Framework | Language | Features |
|---|---|---|
| Ruby on Rails | Ruby | Convention over configuration, scaffolding |
| Django | Python | Admin interface, ORM, batteries-included |
| Flask | Python | Lightweight, extensible |
| Spring Boot | Java | Enterprise-grade, dependency injection |
| ASP.NET | C# | Microsoft ecosystem, MVC pattern |
19.6 Embedded SQL
SQL statements embedded directly in host language code:
cEXEC SQL SELECT name, salary INTO :name_var, :sal_var FROM instructor WHERE ID = :id_var;
Pre-processed by the SQL pre-processor before compilation.
📝 Practice Questions
Q1. Describe the 3-tier architecture and its advantages.
AnswerTiers: Presentation (UI), Business Logic (application server), Data Access (database server)Advantages: Modularity, independent scalability, security (data never exposed to clients), reusability of components.
Q2. What is the difference between cookies and sessions?
AnswerCookies are stored client-side; sessions are stored server-side. Sessions are more secure (data not exposed to the client). Cookies are typically used to store the session ID.
Q3. List two Python drivers for PostgreSQL.
Answerpsycopg2, pg8000, ocpgdp, PyGreSQL (any two).
🔗 Cross-References
- Related: BSCS2003 (MAD 1) — Web application development
- Related: 08 - SQL Joins (used in application queries)
- Textbook: Chapter 9 (Application Design) Join Discord Previous18 - DecompositionNext20 - Storage Systems