To verify equality of two length values measured in feet.
Given two length values in feet, check whether they are equal.
- Created a
Feetclass - Stored length value as
double - Overridden
equals()method to compare values - Written JUnit test cases
- OOP
- Encapsulation
- Method Overriding
- Unit Testing
Successfully compared two length objects based on value instead of reference.
To verify equality between length values measured in different units (Feet and Inches).
Given two length values where:
- One value is in Feet
- One value is in Inches
The system should correctly determine whether both represent the same physical length.
- Created an
Inchesclass - Stored length value as
double - Implemented logic to convert inches to feet (or vice versa) for comparison
- Used overridden
equals()method for value-based comparison - Written JUnit test cases for cross-unit validation
- OOP
- Encapsulation
- Unit Conversion
- Method Overriding
- Floating Point Comparison
- Unit Testing
Successfully implemented comparison between different measurement units by introducing unit conversion logic.
To refactor the existing design by introducing a Generic Quantity class in order to follow the DRY (Don't Repeat Yourself) principle.
In previous use cases, separate classes (Feet, Inches) contained similar comparison and conversion logic, leading to code duplication.
The goal of UC3 is to:
- Remove repetitive logic
- Introduce a reusable and generic
Quantityclass - Centralize comparison logic
- Created a generic
Quantityclass - Stored value and unit inside the same class
- Implemented common comparison logic in one place
- Eliminated duplicate conversion logic from individual unit classes
- Updated test cases to use the generic class
- DRY Principle
- Refactoring
- Abstraction
- Encapsulation
- Code Reusability
- Object-Oriented Design
Successfully reduced code duplication by introducing a single reusable Quantity class.
Improved maintainability and scalability of the system.
π feature/UC3-GenericLength
To extend the Quantity system to support additional measurement units beyond Feet and Inches.
The system currently supports limited units for length comparison.
The goal of this use case is to:
- Add support for more units (e.g., Yard, Centimeter, etc.)
- Ensure accurate comparison between all supported units
- Maintain scalability without increasing code duplication
- Extended the
Quantityclass to support multiple units - Added unit conversion factors for new measurement types
- Centralized conversion logic inside the generic structure
- Updated equality comparison to handle all supported units
- Added test cases for new unit combinations
- Extensibility
- Open-Closed Principle (OCP)
- Abstraction
- Unit Conversion Design
- Scalable Architecture
- Clean Code Practices
Successfully enhanced the system to support multiple measurement units while keeping the design clean and maintainable.
The application is now more scalable and ready for future unit additions.
To implement direct unit-to-unit conversion functionality within the Quantity system.
The system currently supports comparison between different units.
The goal of this use case is to:
- Allow explicit conversion from one unit to another
- Provide accurate converted values
- Ensure conversion logic is reusable and centralized
Example:
- Convert Feet to Inches
- Convert Yard to Feet
- Convert Centimeter to Inch
- Added a conversion mechanism inside the
Quantityclass - Used standard conversion factors for supported units
- Ensured conversions happen through a base reference unit
- Added test cases to validate conversion accuracy
- Maintained DRY principle by avoiding duplicate conversion logic
- Unit Conversion Logic
- Base Unit Strategy
- DRY Principle
- Clean Architecture
- Floating Point Precision Handling
- Unit Testing
Successfully implemented reliable unit-to-unit conversion functionality.
The system now supports both comparison and direct conversion across multiple units.
π feature/UC5-UnitConversion
To implement functionality that allows addition of two length quantities, even if they are in different units.
The system currently supports comparison and conversion of units.
The goal of this use case is to:
- Add two length quantities
- Handle different units during addition
- Return the correct summed result
Example:
- 1 ft + 12 in
- 2 yd + 1 ft
- 5 cm + 2 in
- Implemented an
add()method inside theQuantityclass - Converted both quantities to a common base unit before performing addition
- Returned the result in a standard or specified unit
- Ensured floating point precision handling
- Added test cases to validate addition logic
- Unit Normalization
- Base Unit Strategy
- Arithmetic Operations on Objects
- DRY Principle
- Clean Code Design
- Unit Testing
Successfully implemented addition of two length quantities across different units.
The system now supports arithmetic operations in addition to comparison and conversion.
To enhance the addition functionality by allowing the result to be returned in a specified target unit.
The system currently supports addition of two length quantities.
The goal of this use case is to:
- Add two quantities with different units
- Allow the user to specify the desired output unit
- Return the final result in the requested unit
Example:
- 1 ft + 12 in β result in ft
- 2 yd + 1 ft β result in in
- 5 cm + 2 in β result in cm
- Extended the
add()method to accept a target unit parameter - Converted both input quantities to a base unit
- Performed addition in base unit
- Converted the final result to the specified target unit
- Added test cases for different target unit scenarios
- Method Overloading / Parameterized Methods
- Base Unit Strategy
- Flexible API Design
- Clean Architecture
- Reusability
- Unit Testing
Successfully implemented addition with target unit specification.
The system now provides flexible and user-controlled arithmetic operations across different measurement units.
π feature/UC7-TargetUnitAddition
To refactor the design by extracting the Unit enum into a standalone component for better maintainability and separation of concerns.
Previously, unit definitions and conversion logic were tightly coupled within the Quantity class.
This created reduced flexibility and limited reusability.
The goal of this use case is to:
- Move the
Unitenum into a separate standalone structure - Encapsulate unit-specific conversion logic inside the enum
- Improve modularity and maintainability
- Follow clean architecture principles
- Extracted
Unitenum into a separate file - Moved conversion factors inside the enum
- Delegated conversion responsibility to the
Unitenum - Reduced responsibility of the
Quantityclass - Updated test cases to validate refactored structure
- Refactoring
- Separation of Concerns
- Single Responsibility Principle (SRP)
- Enum-based Design
- Clean Architecture
- Maintainable Code Structure
Successfully refactored the unit handling mechanism into a standalone enum.
The system is now more modular, extensible, and aligned with solid design principles.
π feature/UC8-StandaloneUnit
To extend the Quantity Measurement system to support weight units in addition to length units.
Until now, the system handled only length measurements.
The goal of this use case is to:
- Introduce weight measurement support
- Add weight units such as Gram and Kilogram
- Ensure accurate comparison and conversion within weight units
- Prevent invalid comparisons between different measurement types (e.g., Length vs Weight)
- Added new weight units (e.g., Gram, Kilogram) in the Unit enum
- Defined appropriate conversion factors for weight units
- Ensured weight conversions are handled through base unit strategy
- Implemented validation to restrict cross-type comparison (Length β Weight)
- Added test cases for weight comparison and conversion
- Domain Extension
- Type Safety
- Enum Enhancement
- Separation of Measurement Types
- Base Unit Strategy
- Clean Architecture
- Unit Testing
Successfully extended the system to support weight measurements.
The application now handles multiple measurement categories while maintaining type safety and design consistency.
π feature/UC9-WeightMeasurement
To refactor the system by introducing a Unit interface that enables true generic support for multiple measurement categories such as Length and Weight.
With the introduction of multiple measurement types (Length and Weight), the existing design needed better abstraction to:
- Support multiple categories cleanly
- Avoid tight coupling between Quantity and specific Unit implementations
- Enable future extension (e.g., Volume, Temperature)
- Maintain type safety and scalability
- Introduced a
Unitinterface to define common unit behaviors - Implemented category-specific enums (e.g., LengthUnit, WeightUnit) that implement the
Unitinterface - Updated the
Quantityclass to work with theUnitinterface instead of a specific enum - Ensured conversion logic is delegated to respective unit implementations
- Maintained type safety to prevent cross-category operations (Length β Weight)
- Updated test cases to validate multi-category behavior
- Interface-based Design
- Polymorphism
- Dependency Inversion Principle (DIP)
- Separation of Concerns
- Scalable Architecture
- Type Safety
- Clean Code Practices
Successfully refactored the system into a fully generic and extensible measurement framework.
The application now supports multiple measurement categories using interface-driven design, making it scalable for future enhancements.
π feature/UC10-MultiCategoryUnit
To extend the system to support volume measurements including equality comparison, unit conversion, and addition operations for Litre, Millilitre, and Gallon.
The system currently supports Length and Weight categories.
The goal of this use case is to:
- Introduce Volume as a new measurement category
- Support units such as Litre (L), Millilitre (mL), and Gallon (gal)
- Enable equality comparison across volume units
- Allow conversion between supported volume units
- Implement addition of volume quantities
- Maintain strict type safety between categories (Volume β Length β Weight)
- Added a new VolumeUnit enum implementing the
Unitinterface - Defined appropriate conversion factors using a base unit strategy (e.g., Litre as base)
- Implemented equality comparison across volume units
- Enabled unit-to-unit conversion for volume measurements
- Implemented addition of two volume quantities
- Ensured cross-category operations are restricted
- Added comprehensive test cases for equality, conversion, and addition
- Multi-Category Architecture
- Interface-Based Design
- Base Unit Strategy
- Polymorphism
- Type Safety
- Open-Closed Principle (OCP)
- Clean Code Practices
- Unit Testing
Successfully extended the system to support volume measurements including equality, conversion, and arithmetic operations.
The application now functions as a scalable, multi-category measurement framework supporting Length, Weight, and Volume with consistent architecture.
π feature/UC11-VolumeMeasurement
To extend the Quantity system by implementing subtraction and division operations across supported measurement categories (Length, Weight, Volume).
The system currently supports equality, conversion, addition, and multi-category handling.
The goal of this use case is to:
- Implement subtraction between two quantities
- Implement division operations on quantities
- Ensure unit consistency during arithmetic operations
- Maintain strict type safety across categories
Example:
- 5 ft - 2 ft
- 2 kg - 500 g
- 3 L - 500 mL
- 10 ft Γ· 2
- 4 kg Γ· 2
- Added
subtract()method in theQuantityclass - Converted both operands to base unit before performing subtraction
- Implemented
divide()method to support division by scalar values - Ensured arithmetic operations are restricted within the same measurement category
- Preserved immutability by returning new Quantity objects
- Added comprehensive test cases for subtraction and division scenarios
- Arithmetic Operations on Domain Objects
- Base Unit Strategy
- Polymorphism
- Type Safety
- Immutability
- Clean Architecture
- Defensive Programming
- Unit Testing
Successfully implemented subtraction and division operations across multiple measurement categories.
The system now supports full arithmetic capabilities while maintaining scalable and type-safe architecture.
π feature/UC12-QuantitySubtractionDivision
To refactor arithmetic operations (addition, subtraction, division) by centralizing the logic in order to strictly enforce the DRY (Don't Repeat Yourself) principle.
With multiple arithmetic operations implemented (add, subtract, divide), there was duplication in:
- Base unit conversion logic
- Category validation logic
- Arithmetic execution steps
- Result reconstruction logic
The goal of this use case is to:
- Eliminate repetitive arithmetic logic
- Create a centralized internal operation handler
- Improve maintainability and scalability
- Ensure consistent behavior across all arithmetic methods
- Introduced a centralized private method to handle arithmetic operations
- Abstracted common steps:
- Category validation
- Conversion to base unit
- Execution of arithmetic operation
- Conversion to target unit
- Refactored existing methods (
add(),subtract(),divide()) to delegate to centralized logic - Reduced code duplication significantly
- Ensured no change in external behavior
- Updated test cases to confirm consistent functionality
- DRY Principle
- Refactoring
- Template Method Pattern (Conceptually)
- Clean Architecture
- Code Maintainability
- Separation of Concerns
- Defensive Programming
- Unit Testing
Successfully centralized arithmetic logic, reducing duplication and improving code clarity.
The Quantity system is now more maintainable, scalable, and aligned with solid software design principles.
π feature/UC13-CentralizedArithmeticLogic
To introduce Temperature as a new measurement category while refactoring the architecture using an IMeasurable interface and supporting selective arithmetic operations.
Temperature differs from other measurement types (Length, Weight, Volume) because:
- It requires offset-based conversion (e.g., Celsius β Fahrenheit)
- Not all arithmetic operations are logically valid
- Addition of absolute temperatures is conceptually incorrect in many cases
The goal of this use case is to:
- Introduce Temperature units (Celsius, Fahrenheit, Kelvin)
- Support equality comparison and conversion
- Allow only valid arithmetic operations
- Refactor system using
IMeasurableabstraction for better flexibility
- Created a
TemperatureUnitenum implementing theUnitinterface - Implemented offset-based conversion logic (e.g., Celsius β Fahrenheit)
- Introduced
IMeasurableinterface to define measurable behavior - Ensured only meaningful arithmetic operations are permitted
- Restricted invalid operations through validation
- Updated the
Quantityclass to support selective arithmetic handling - Added comprehensive unit tests for temperature equality and conversion
- Interface Segregation Principle (ISP)
- Polymorphism
- Offset-Based Conversion Logic
- Selective Arithmetic Enforcement
- Type Safety
- Clean Architecture Refactoring
- Defensive Programming
- Unit Testing
Successfully introduced Temperature measurement with proper conversion handling and selective arithmetic support.
Refactored the system using IMeasurable abstraction, making the architecture more flexible, extensible, and aligned with SOLID design principles.
π feature/UC14-temperaturemeasurement
-
Description: UC15 restructures the Quantity Measurement App into a layered architecture by introducing Controller, Service, Repository, DTO, Model, and Entity layers. This separation improves maintainability, modularity, and testability while preserving all measurement logic implemented in previous use cases.
-
Architecture:
- Controller β Handles requests and delegates operations to the service layer.
- Service β Contains business logic and coordinates conversions and operations.
- Repository β Provides a cache-based storage layer.
- DTO / Model / Entity β Used for structured data transfer and internal representation.
-
Implementation:
- Introduced
QuantityMeasurementController,QuantityMeasurementServiceImpl, andQuantityMeasurementCacheRepository. - Added
QuantityDTO,QuantityModel, andQuantityMeasurementEntity. - Service performs DTO β Model β Quantity β Model β DTO transformation.
- Reuses the existing generic
Quantityengine and unit enums from previous UCs.
- Introduced
-
Example:
QuantityDTO(10, FEET, LENGTH) + QuantityDTO(12, INCHES, LENGTH) β QuantityDTO(11, FEET, LENGTH)QuantityDTO(100, CELSIUS, TEMPERATURE).equals(QuantityDTO(212, FAHRENHEIT, TEMPERATURE)) β true
UC15βArchitecture Refactoring
-
Description: UC16 extends the N-Tier architecture by replacing the cache-based repository with a database-backed persistence layer. The application now stores and retrieves quantity measurements using JDBC and a connection pool. This improves scalability and enables persistent storage while maintaining the same layered architecture introduced in UC15.
-
Architecture:
- Controller β Handles incoming requests and forwards them to the service layer.
- Service β Performs business logic, conversions, and arithmetic operations.
- Repository β Provides database-based storage using JDBC instead of in-memory caching.
- Connection Pool β Manages reusable database connections for efficient access.
- DTO / Model / Entity β Continue to support structured data transfer and internal representation.
-
Implementation:
- Introduced
QuantityMeasurementDatabaseRepositoryto replace the cache repository. - Implemented database operations using JDBC (
Connection,PreparedStatement,ResultSet). - Added
ConnectionPoolutility for managing database connections. - Repository stores measurement results in the
quantity_measurementtable. - Service layer continues performing DTO β Model β Quantity β Model β DTO transformations.
- Existing Controller and Service logic remain unchanged, ensuring backward compatibility.
- Introduced
-
Example:
QuantityDTO(5, FEET, LENGTH) + QuantityDTO(24, INCHES, LENGTH) β QuantityDTO(7, FEET, LENGTH)- Result is stored in the database with a unique key.
find(key)retrieves the stored measurement entity from the database.
-
Description:
Migrated the application to a Spring Boot REST service with embedded server, replacing JDBC with Spring Data JPA for ORM-based persistence. -
Architecture:
- Controller β Handles REST API requests
- Service β Business logic & transactions
- Repository β JPA-based data access
- Database β ORM using Hibernate
- Spring Boot β Auto-config + embedded Tomcat
-
Implementation:
- Built REST APIs using
@RestController - Replaced JDBC with Spring Data JPA
- Used DI (
@Autowired),@Transactional - Added exception handling & validation
- Integrated Swagger, Actuator, and testing (MockMvc)
- Optional Spring Security integration
- Built REST APIs using
-
Example:
POST /quantity/addβ Returns calculated result stored via JPA
-
Description:
Secured the Spring Boot application using Spring Security with Google OAuth2 authentication and JWT-based authorization for stateless API access. -
Architecture:
- Security Layer β Handles authentication & authorization
- OAuth2 (Google) β User login via Google account
- JWT β Token-based authentication
- Controller β Secured REST endpoints
- Service β Business logic with role checks
-
Implementation:
- Integrated Spring Security
- Implemented Google OAuth2 login
- Generated & validated JWT tokens
- Secured APIs using filters and configurations
- Enabled role-based access control (RBAC)
-
Example:
Login via Google β Receive JWT β Access secured APIs with token