Two standalone tasks that demonstrate the SOLID principles in plain Java. The assignment is part of the Software Design Patterns course at Astana IT University.
- Task 1 — Payment Processing System: a small payment pipeline that accepts any payment method through a common interface, making it trivial to add new methods without touching existing code.
- Task 2 — Notification System: a multi-channel notification dispatcher (SMS, Email, Push, Slack) that also supports bulk delivery to a list of recipients.
- Single Responsibility Principle (SRP) — each class does exactly one thing:
CreditCardPaymenthandles credit-card logic;PaymentProcessorhandles dispatching;BulkNotificationSenderhandles iteration over recipients. - Open/Closed Principle (OCP) — new payment methods (
BankTransferPayment) and notification channels (SlackNotification) are added by implementing an interface, without modifying any existing class. - Liskov Substitution Principle (LSP) —
PaymentProcessoraccepts anyPaymentMethod;BulkNotificationSenderaccepts anyNotificationChannel; all concrete implementations are interchangeable at those injection points. - Interface Segregation Principle (ISP) —
PaymentMethodexposes a single method (processPayment);NotificationChannelexposes a single method (sendNotification). No class is forced to implement methods it doesn't need. - Dependency Inversion Principle (DIP) — high-level modules (
PaymentProcessor,BulkNotificationSender) depend on abstractions (interfaces), not on concrete implementations. - Polymorphism via interfaces — concrete classes (
CreditCardPayment,SMSNotification, etc.) are treated uniformly through their interface type at call sites.
src/
├── com/payment/
│ ├── PaymentMethod.java # interface: processPayment(double)
│ ├── CreditCardPayment.java # implements PaymentMethod
│ ├── PayPalPayment.java # implements PaymentMethod
│ ├── BankTransferPayment.java # implements PaymentMethod
│ ├── PaymentProcessor.java # dispatches to any PaymentMethod
│ └── Main.java # demo: runs all three payment types
│
└── com/notification/
├── NotificationChannel.java # interface: sendNotification(String, String)
├── SMSNotification.java # implements NotificationChannel
├── EmailNotification.java # implements NotificationChannel
├── PushNotification.java # implements NotificationChannel
├── SlackNotification.java # implements NotificationChannel
├── BulkNotificationSender.java # sends one message to a list of recipients
└── Main.java # demo: bulk email, SMS, and push
Task 1 — Payment:
cd src
javac com/payment/*.java
java com.payment.MainTask 2 — Notification:
cd src
javac com/notification/*.java
java com.notification.Main- Open the project root in IntelliJ IDEA.
- The SDK is pre-configured to JDK 21 (see
.idea/misc.xml). - Open either
com/payment/Main.javaorcom/notification/Main.javaand click Run.
Adil Ormanov — GitHub