The true test of a software architecture is its response to change. This project demonstrates the Scalability of Polymorphism. By adding a Tester role to our existing Employee hierarchy, we show that the system's core logic—the team iteration loop—requires zero modifications to handle new types of employees. This follows the Open/Closed Principle: the system is open for extension (adding new roles) but closed for modification (the processing logic remains stable).
- Hierarchy Expansion: Integrated a new
Testerclass into the establishedEmployeestructure. - Method Overriding: Specialized the
work()method to reflect quality assurance activities. - Dynamic Integration: Successfully added the new object type to a polymorphic array.
- Logic Invariance: Verified that the same loop processes all roles (Manager, Developer, Tester) correctly.
- Java 8+ (Polymorphism, Inheritance, Array Initialization)
- Employee: The base abstraction.
- Tester: The newly added role focused on bug hunting.
- HRSystemEvolutionLauncher: The updated entry point managing the expanded team.
Manager is holding a meeting
Developer is writing code.
Tester is searching for bugs.
Project Structure:
JavaBasics_Task_318/
├── src/
│ └── com/yurii/pavlenko/
│ ├── app/
│ │ └── HRSystemEvolutionLauncher.java
│ └── hr/
│ ├── roles/
│ │ ├── Manager.java
│ │ ├── Developer.java
│ │ └── Tester.java
│ └── Employee.java
├── LICENSE
├── TASK.md
├── THEORY.md
└── README.md
Code
package com.yurii.pavlenko.app;
import com.yurii.pavlenko.hr.Employee;
import com.yurii.pavlenko.hr.roles.Manager;
import com.yurii.pavlenko.hr.roles.Developer;
import com.yurii.pavlenko.hr.roles.Tester;
public class HRSystemEvolutionLauncher {
public static void main(String[] args) {
Employee[] team = {
new Manager(),
new Developer(),
new Tester()
};
for (Employee employee : team) {
employee.work();
}
}
}package com.yurii.pavlenko.hr;
public class Employee {
public void work() {
System.out.println("The employee is working...");
}
}package com.yurii.pavlenko.hr.roles;
import com.yurii.pavlenko.hr.Employee;
public class Manager extends Employee {
@Override
public void work() {
System.out.println("Manager is holding a meeting");
}
}package com.yurii.pavlenko.hr.roles;
import com.yurii.pavlenko.hr.Employee;
public class Developer extends Employee {
@Override
public void work() {
System.out.println("Developer is writing code.");
}
}package com.yurii.pavlenko.hr.roles;
import com.yurii.pavlenko.hr.Employee;
public class Tester extends Employee {
@Override
public void work() {
System.out.println("Tester is searching for bugs.");
}
}This project is licensed under the MIT License.
Copyright (c) 2026 Yurii Pavlenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
License: MIT