The primary goal of a senior developer is to write code that doesn't need to be rewritten every time requirements change. This project demonstrates Advanced Polymorphism and the Open/Closed Principle. By encapsulating the iteration logic in a universal method printWorkForAll(Employee[]), we create a system where adding a new type of worker (like an Intern) requires zero changes to the processing logic. This decoupling ensures that the system remains stable and maintainable even as the organization expands.
- Extensible Hierarchy: Built a robust hierarchy including
Manager,Developer,Designer, andIntern. - Logic Encapsulation: Isolated the polymorphic loop into a reusable private method.
- Null Safety: Implemented checks to handle partially filled arrays.
- Dynamic Integration: Proven that the same method handles new object types added at runtime.
- Architectural Scalability: Demonstrated the power of programming to an interface/superclass.
- Java 8+ (Inheritance, Polymorphism, Encapsulation, Array Management)
- Employee: The root of the corporate hierarchy.
- Intern: The latest addition, demonstrating seamless integration.
- SystemEvolutionLauncherApp: The orchestrator that manages staff and triggers activities.
--- Current Staff Activity ---
Employee is working...
Manager is holding a meeting.
Developer is writing code.
Designer is drawing layouts.
--- Updated Staff Activity (Intern Joined) ---
Employee is working...
Manager is holding a meeting.
Developer is writing code.
Designer is drawing layouts.
Intern learning how to work.
Project Structure:
JavaBasics_Task_319/
├── src/
│ └── com/yurii/pavlenko/
│ ├── app/
│ │ └── SystemEvolutionLauncherApp.java
│ └── hr/
│ ├── roles/
│ │ ├── Manager.java
│ │ ├── Developer.java
│ │ ├── Designer.java
│ │ └── Intern.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.*;
public class SystemEvolutionLauncherApp {
public static void main(String[] args) {
Employee[] staff = new Employee[5];
staff[0] = new Employee();
staff[1] = new Manager();
staff[2] = new Developer();
staff[3] = new Designer();
System.out.println("--- Current Staff Activity ---");
printWorkForAll(staff);
staff[4] = new Intern();
System.out.println("\n--- Updated Staff Activity (Intern Joined) ---");
printWorkForAll(staff);
}
private static void printWorkForAll(Employee[] staff) {
for (Employee e : staff) {
if (e != null) {
// Polymorphic call: JVM finds the right implementation at runtime
e.work();
}
}
}
}package com.yurii.pavlenko.hr;
public class Employee {
public void work() {
System.out.println("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 Intern extends Employee {
@Override
public void work() {
System.out.println("Intern learning how to work.");
}
}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