🏠 Home

Week 1

Introduction to Software Design & Architecture

BS Software Engineering - IV - A

Instructor: Baber Sheikh (Visiting Faculty)

1.1 Introduction
1.2 Requirements & Implementation
1.3 Design Principles
1.4 Architectural Styles
1.5 Quality Attributes
1.6 Design Guidelines

Course Assessment Breakdown

Assessment Type Marks Percentage
Final Examination 50 50%
Mid-Term Examination 30 30%
Quizzes 5 5%
Assignments/Presentations 10 10%
Class Participation/Activities 5 5%
TOTAL 100 100%

Important: Regular attendance and active participation are essential!

Recommended Textbooks

Main Textbook 1

Software Architecture and Design Illuminated

By: K. Qian, J. Fu, X. Tao, C.W. Xu, L. Diaz-Herrera

Publisher: Jones & Bartlett

Main Textbook 2

Dive Into Design Patterns

By: Alexander Shvets

Year: 2019

⭐ Highly Visual & Beginner-Friendly!

Reference Book

Software Architecture in Practice

By: Len Bass, Paul Clements, Rick Kazman

Edition: Second Edition

Publisher: Addison Wesley

Tip: "Dive Into Design Patterns" is available as PDF with excellent visual explanations!

🍕 Real-World Example: Restaurant System

Imagine designing a restaurant management system...

Just like a restaurant has different areas (kitchen, dining, billing), software architecture divides the system into components!

Kitchen (Backend)

• Prepares food (processes data)

• Follows recipes (business logic)

• Hidden from customers

Dining Area (Frontend)

• Customer interface

• Takes orders (user input)

• Displays menu (UI)

Manager (Database)

• Stores recipes

• Tracks inventory

• Manages orders

Architecture defines how these parts communicate!

Learning Objectives

By the end of this lecture, you will be able to:

  • Understand the relationship between software requirements and architecture
  • Explain the relationship between architecture styles and architecture
  • Identify the elements of software architecture
  • Describe quality attributes and tradeoff analysis
  • Apply software design guidelines in practice

1.1 What is Software Architecture?

IEEE Definition:

"The fundamental organization of a system embodied in its elements, their relationships to each other and to the environment, and the principles guiding its design and evolution."

Simple Analogy

Architecture is like a house blueprint before construction begins

In Software

It's the high-level structure showing how parts work together

Why is Software Architecture Important?

Poor Architecture Leads To:

  • Deficient products
  • Doesn't meet requirements
  • Not adaptive to changes
  • Poor performance
  • Unpredictable behavior
  • Inefficient development

Good Architecture Provides:

  • Reduced risks
  • Team coordination
  • Clear implementation path
  • Easier testing
  • Higher quality
  • Better maintainability

Software Development Life Cycle (SDLC)

SDLC Diagram

Architecture Design Phase:

Comes after requirements analysis and before implementation

Input: Software Requirements Specification (SRS)

Output: Software Design Description (SDD)

Architecture Design vs Detailed Design

Architecture Design (Strategic) Detailed Design (Tactical)
High-level structure Low-level implementation details
Visible to stakeholders Internal to developers
Example: "Use a priority queue" Example: "Implement with linked list"
What and Why How

Real Example: Traffic Controller System

Architecture: "System will use a priority queue to handle requests"

Detailed Design: "Priority queue implemented using doubly linked list for O(1) insertion"

Key Elements of Software Architecture

Components and Connectors

Elements/Components

Modules, objects, services that perform functions

Connectors

Communication channels between elements

Constraints

Rules governing integration

1.2 Bridging Requirements & Implementation

Requirements to Implementation Bridge

Architecture is the Bridge

Software architecture connects what the customer wants (requirements) with what developers build (implementation)

Typical Architecture Representation

Box and Line Diagram

⚠️ Important Note:

Box-and-line diagrams are a starting point, but they are NOT complete!

Missing information:

  • Quality attributes (performance, security, etc.)
  • Detailed constraints and behaviors
  • Implementation guidelines

What Does a Software Architect Do?

1️⃣ Decomposition

Partition system into subsystems and define communication

2️⃣ Control Flow

Establish data flow and control relationships

3️⃣ Style Selection

Evaluate and choose appropriate architecture styles

4️⃣ Tradeoff Analysis

Balance quality attributes and requirements

Most Important: Map SRS to architecture design while ensuring functional and nonfunctional requirements are met!

1.3 Key Software Design Principles

Two Fundamental Principles:

High Cohesion

Each element should have a single, well-defined responsibility

Example: A "User Authentication" module should ONLY handle login/logout, not also send emails

Loose Coupling

Elements should have minimal dependencies on each other

Example: Changing the database shouldn't require changing the UI

High Cohesion - Detailed Example

Low Cohesion (Bad)

class UserManager {
    login()
    logout()
    sendEmail()
    generateReport()
    processPayment()
}
                        

Too many unrelated responsibilities!

High Cohesion (Good)

class AuthService {
    login()
    logout()
}

class EmailService {
    sendEmail()
}

class ReportService {
    generateReport()
}
                        

Each class has ONE clear purpose!

Loose Coupling - Detailed Example

Email vs Phone Conversation Analogy

Email (Loose Coupling): Send message anytime, receiver responds when available. You can do other work while waiting.

Phone (Tight Coupling): Both must be available at same time. You're blocked until call ends.

Benefits of Loose Coupling:

  • Change one component without affecting others
  • Easier testing (test components independently)
  • Better reusability
  • Parallel development possible

1.4 Architectural Styles

Definition:

An architecture style is a family of similar designs that share common properties, rules, and patterns for structuring a system.

House Analogy

Victorian, Colonial, Modern - different styles for different needs

Software Styles

Layered, MVC, Client-Server - different patterns for different problems

Key Components of an Architecture Style

1. Elements

Components that perform required functions

2. Connectors

Enable communication and coordination

3. Constraints

Rules for integration

4. Attributes

Advantages and disadvantages

Common Architecture Styles (Preview)

We'll study these in detail in coming weeks:

Data-Centric

Database at center, accessed by other elements

Dataflow

Data transformed through series of operations

Call-and-Return

Functions organized in hierarchy

Object-Oriented

Objects with data and operations

Layered

Organized in abstraction levels

Distributed

Components on different servers

Example: Multi-Tier Architecture

Three-Tier Architecture (Very Common!)

Tier 1: Client

Role: User Interface

Accepts requests, displays results

Example: Web browser, mobile app

Tier 2: Server

Role: Business Logic

Processes requests, applies rules

Example: Laravel backend, Node.js API

Tier 3: Database

Role: Data Storage

Manages data queries and updates

Example: MySQL, PostgreSQL

Real Example: Your Moodle Deployments!

Client (Browser) → Server (PHP/Apache) → Database (MySQL)

1.5 Quality Attributes

Quality Attributes Wheel

Quality attributes are nonfunctional requirements that describe HOW WELL the system performs its functions.

Three Categories of Quality Attributes

1️⃣ Implementation Attributes (Not Observable at Runtime)

Maintainability, Testability, Portability, Scalability, Flexibility, Interoperability

2️⃣ Runtime Attributes (Observable at Runtime)

Performance, Security, Availability, Usability, Reliability

3️⃣ Business Attributes

Time to Market, Cost, Lifetime

Implementation Attributes (Detailed)

Attribute Description Example
Maintainability Ease of modifying the system Well-documented code, modular design
Testability Ease of establishing test cases Unit tests, integration tests
Portability Independence from platforms Java "write once, run anywhere"
Scalability Ability to handle growth System handles 100 to 10,000 users
Flexibility Ease of adaptation Plugin architecture, microservices

Runtime Attributes (Detailed)

Attribute Description Example
Performance Response time, throughput Page loads in < 2 seconds
Security Protection against attacks Encryption, authentication, firewalls
Availability System uptime 99.9% uptime (8.76 hours downtime/year)
Reliability Failure frequency, accuracy Mean Time To Failure (MTTF)
Usability User satisfaction Intuitive UI, good documentation

Quality Attributes Tradeoffs

⚠️ Important Reality:

You CANNOT maximize all quality attributes simultaneously! Tradeoffs are necessary.

Space vs Time

Hash table: More space = Faster lookup

Compression: Less space = Slower access

Reliability vs Performance

Java: Safe (array bounds checking) but slower

C: Fast (pointers) but less safe

Scalability vs Performance

Replicated servers: More scalable

But synchronization reduces performance

Security vs Usability

More security checks = More user friction

Easier login = Potential security risk

Real-World Example: Moodle Deployment

Scenario: Deploying Moodle for 5,000 Students

Client Requirement: "I want it fast, secure, cheap, and available 24/7!"

Can't Have All!

  • Fast + Cheap = Less reliable
  • Secure + Fast = More expensive
  • 24/7 + Cheap = Lower performance

Architect's Decision:

  • Priority 1: Security (student data)
  • Priority 2: Availability (99% uptime)
  • Priority 3: Performance (< 3s load)
  • Compromise: Moderate cost

1.6 Software Architecture Design Guidelines

Rules of Thumb for Software Architects

These guidelines help you make better design decisions

Guideline 1: Think WHAT Before HOW

Principle:

Identify requirements before thinking about implementation

Wrong Approach

"Let's use MongoDB!"

But why? What problem are we solving?

Right Approach

"We need to store user data"

"Requirements: Fast reads, flexible schema"

"Therefore: MongoDB is suitable"

Benefit: Avoid costly redesigns later in development!

Guideline 2: Think ABSTRACT Before CONCRETE

Principle:

Start with interfaces and contracts, then implement details

Example: Payment System

// First: Define abstract interface
interface PaymentProcessor {
    processPayment(amount, method)
    refund(transactionId)
}

// Later: Implement concrete classes
class StripePayment implements PaymentProcessor { ... }
class PayPalPayment implements PaymentProcessor { ... }
                    

Benefit: Easy to add new payment methods without changing existing code!

Guideline 3: Consider Quality Attributes EARLY

Principle:

Think about performance, security, scalability from the start, not as an afterthought!

Common Mistake

"Let's build it first, optimize later"

Result: Complete redesign needed!

Better Approach

"Expected 10,000 concurrent users"

"Design for horizontal scaling from day 1"

Result: System ready to scale!

Guideline 4: Design for REUSABILITY

Principle:

Don't reinvent the wheel! Use existing components and design for future reuse.

Example: Email Service

Instead of writing email code in every feature:

// Create reusable service
class EmailService {
    send(to, subject, body)
    sendTemplate(to, templateName, data)
}

// Use everywhere
emailService.send(user.email, "Welcome", "Hello!")
emailService.send(admin.email, "Alert", "Issue detected")
                    

Benefits: Fix bugs once, add features once, test once!

Guideline 5: High Cohesion + Loose Coupling

Principle:

We already covered this! It's SO important it's a guideline too!

High Cohesion

Each module does ONE thing well

Measure: Can you describe the module's purpose in one sentence?

Loose Coupling

Modules don't depend heavily on each other

Measure: Can you change one module without changing others?

Guideline 6: Embrace ITERATION

Principle:

Design is NOT a one-time activity. Expect to refine and improve!

Typical Design Process:

  1. Version 1: Initial design based on requirements
  2. Prototype: Build small version, test with users
  3. Feedback: Discover missing requirements or issues
  4. Version 2: Refined design addressing feedback
  5. Repeat: Continue until design is solid

"Perfect is the enemy of good" - Don't wait for perfection, iterate!

Guideline 7: Avoid AMBIGUOUS or OVER-DETAILED Design

Too Ambiguous

"Build a user management system"

Problem: No constraints, developers confused

Too Detailed

"Use exactly 3 nested for-loops, variable names must be x, y, z"

Problem: Restricts implementation, no flexibility

Just Right

"User management system with authentication, role-based access control, and audit logging. Use industry-standard security practices. Performance: < 200ms response time."

Clear requirements + implementation freedom!

How to Document Architecture?

📐 UML Diagrams

Visual notation for software design

  • Class diagrams
  • Sequence diagrams
  • Component diagrams

👁️ 4+1 View Model

Show different perspectives

  • Logical view
  • Process view
  • Physical view
  • Development view
  • Scenarios

📝 ADL

Architecture Description Languages

Formal specification of structure and semantics

We'll cover UML in detail in Week 3!

Week 1 Summary

What We Learned Today:

Core Concepts

  • Software architecture definition
  • Role in SDLC
  • Elements, connectors, constraints
  • Architecture vs detailed design

Key Principles

  • High cohesion, loose coupling
  • Architecture styles overview
  • Quality attributes & tradeoffs
  • Design guidelines

Key Takeaway:

Architecture is the BRIDGE between requirements and implementation. Good architecture = Successful software!

Next Week: Software Architecture Design Space

Week 2 Topics:

  • Types of Software Structures (Static, Runtime, Management)
  • Building blocks: Components, Connectors, Constraints
  • Software Connectors in detail
  • Connector types and roles

Reading Assignment:

Textbook Chapter 2: Software Architecture Design Space

Come prepared with questions!

Questions?

Let's Discuss!

Think about a software system you use daily (Facebook, WhatsApp, etc.)

What architecture style do you think it uses?

What quality attributes are most important for it?

Thank you!