✅ Week 4 Assessment

This assessment evaluates your understanding of:

  • Design patterns
  • Clean architecture principles
  • Code structure and maintainability

🧠 Part 1 – Conceptual Questions

Answer the following in your own words:

1️⃣ What problem does the Singleton pattern solve?

When should it NOT be used?


2️⃣ How does the Factory pattern reduce tight coupling?


3️⃣ Why is Builder preferred over constructors when a class has many fields?


4️⃣ What problem does the Strategy pattern solve that if-else cannot solve effectively?


5️⃣ What is the purpose of a DTO?

Why should sensitive fields (like passwords) not be included?


6️⃣ Explain Layered Architecture in your own words.

What problems does it prevent?


💻 Part 2 – Coding Assessment

✅ Task: Refactor a Shopping Cart System

Create a console-based Shopping Cart system that includes:

Requirements

  • Use Strategy Pattern for discount calculation
  • Use Factory Pattern to create products
  • Use DTO to return order summary
  • Use Layered Architecture:
    • Controller
    • Service
    • Repository
    • Model

✅ Functional Requirements

Your system should:

  1. Create products
  2. Add products to cart
  3. Apply different discount strategies
  4. Calculate final price
  5. Display order summary using DTO

🧪 Evaluation Criteria

Your submission will be evaluated on:

  • Correct use of design patterns
  • Proper separation of responsibilities
  • Clean and readable code
  • Avoidance of unnecessary complexity
  • Meaningful class and method names

🎯 Expected Outcome

After completing this assessment, you should demonstrate:

✅ Ability to apply patterns correctly
✅ Understanding of clean architecture
✅ Modular and extensible code design
✅ Reduced tight coupling between components


⭐ Reflection

Write a short paragraph:

  • Which pattern was most useful?
  • Which pattern felt unnecessary?
  • What would you improve in your design?

📌 Important

Do not over-engineer.

Use patterns only where they improve clarity and flexibility.


This site uses Just the Docs, a documentation theme for Jekyll.