Course Content
Data Structures & Algorithms
Full Stack Web Development
Understanding and playing with DOM (Document Object Model)
0/2
MERN project
0/2
Low Level System Design
LLD Topics
High Level System Design
Fast-Track to Full Spectrum Software Engineering
Class Diagram – Weather Station 

In object-oriented design, a class diagram represents the static structure of a system by showing its classes, their attributesmethods, and the relationships between the classes. Below is a breakdown of the key components for a Weather Station system.



1. Class: WeatherStation

Attributes:

  • stationId: String
  • location: String
  • installationDate: Date

Methods:

  • collectData(): void
  • generateReport(): Report
  • sendAlert(): void

Responsibilities:

  • Central class that coordinates all sensor readings
  • Interfaces with external users and systems
  • Triggers alerts based on sensor data thresholds


2. Class: Sensor

Attributes:

  • sensorId: String
  • type: String (e.g., temperature, humidity, wind)
  • unit: String
  • lastCalibrated: Date

Methods:

  • readData(): float
  • calibrate(): void
  • getStatus(): String

Responsibilities:

  • Abstract class (or base class) for all sensor types
  • Provides methods to read and calibrate data


3. Subclasses of Sensor:

These inherit from the Sensor class and implement specialized behavior.

a. TemperatureSensor
  • Additional Methods: getTemperatureInCelsius()

b. HumiditySensor
  • Additional Methods: getHumidityPercentage()

c. WindSpeedSensor
  • Additional Methods: getWindSpeedInKmPerHour()

d. RainfallSensor
  • Additional Methods: getRainfallInMM()



4. Class: DataLogger

Attributes:

  • logId: String
  • timestamp: Date
  • data: Map<String, Float>

Methods:

  • logData(sensorType: String, value: float): void
  • retrieveLogs(startDate: Date, endDate: Date): List<DataLogger>

Responsibilities:

  • Stores the historical weather data
  • Provides access to past readings for reporting and analysis


5. Class: Report

Attributes:

  • reportId: String
  • generatedOn: Date
  • reportType: String (Daily, Weekly, Monthly)

Methods:

  • displayReport(): void
  • exportToCSV(): File

Responsibilities:

  • Generates and formats weather data reports
  • Supports multiple formats (table, chart, file)


6. Class: AlertSystem

Attributes:

  • alertId: String
  • thresholdMap: Map<String, Float>
  • recipients: List<String>

Methods:

  • checkForAlert(data: Map<String, Float>): void
  • notifyUsers(message: String): void

Responsibilities:

  • Monitors weather data for abnormal values
  • Sends alerts to users or external systems


7. Class: User

Attributes:

  • userId: String
  • name: String
  • email: String
  • role: String (Administrator, Observer)

Methods:

  • login(): Boolean
  • viewData(): void
  • requestReport(): Report

Responsibilities:

  • Represents a person interacting with the system
  • Role determines access level and features


8. Class: MaintenanceTechnician (inherits User)

Additional Methods:

  • performCalibration(sensorId: String): void
  • replaceSensor(sensorId: String): void

Responsibilities:

  • Extends the User class with additional capabilities
  • Can perform technical maintenance tasks


Relationships Overview:

  • WeatherStation “has a” Sensor → One-to-many association
  • Sensor “is a” superclass of specialized sensors → Inheritance
  • WeatherStation “uses” DataLogger and Report → Dependency/association
  • AlertSystem “uses” WeatherStation data → Association
  • User “interacts with” WeatherStation → Association
  • MaintenanceTechnician “extends” User → Inheritance


Explanation for Students:

  • class diagram represents how different parts of the Weather Station system are organized and how they communicate.
  • Inheritance is used to create a hierarchy among sensor types, reducing duplication.
  • The WeatherStation class acts as the central hub, coordinating with sensors, logs, users, and alert systems.
  • Modularity and separation of concerns are maintained by assigning distinct roles to each class (e.g., reporting, logging, alerts).
0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.