Advanced 25 min read

Review and Refactor

By the end of this lesson, you'll be able to:

  • Review the complete dashboard feature across every layer
  • Confirm the service/controller separation held up cleanly throughout
  • Apply the full course checklist one more time, now spanning the UI boundary

Prerequisites: "Optimize Performance"

The complete feature, layer by layer

AccountHealthService (with sharing)
  - getOpenCaseCount, getAverageResolutionDays,
    getTotalWonRevenue, getDaysSinceLastActivity
  - getHealthSummary (combines all four)

AccountHealthSummary (wrapper/DTO, @AuraEnabled fields)

AccountHealthController (with sharing)
  - getAccountHealth (@AuraEnabled, cacheable=true, thin — delegates entirely to the service)

Three classes, each with exactly one job — this is Module 26's Single Responsibility Principle, now spanning the full distance from raw SOQL to the LWC boundary.

The full checklist

  • Requirements precisely defined? Yes — each metric stated concretely before coding (Lesson 1).
  • Service layer UI-agnostic? Yes — no @AuraEnabled anywhere in AccountHealthService itself.
  • Sharing reasoned through deliberately? Yes, with sharing, justified explicitly (Lesson 3).
  • Field-level security respected? Yes, via WITH USER_MODE and explicit checks (Lesson 3).
  • Thin controller? Yes — AccountHealthController delegates entirely (Lesson 4).
  • cacheable=true reasoned through? Yes — a read-only method, explicitly justified (Lesson 4).
  • Comprehensive tests, including edge cases? Yes — every metric, the combiner, the controller, and zero-data/null-input scenarios (Lessons 5-6).
  • Performance considered, even beyond today\'s scope? Yes — the N+1 risk named explicitly for future extension (Lesson 7).

What this project represents

This is the last "single-feature" project of the course — every subsequent project module builds on genuinely new Apex capabilities (integrations, asynchronous processing) not yet introduced. But the shape of how to build a feature well — design, service layer, security, controller, tests, edge cases, performance, review — is now fully established, and every remaining project in this course reuses it without needing to re-explain it from scratch.

Exercise

As a comment, name the three classes this feature ended up with, and the one job each one has.

Show hint

Refer back to the layer-by-layer summary in this lesson.

APEX

Review and Refactor Quiz

1. What does this project module represent in the overall course structure?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

The closing lesson reviews the whole Client Health Dashboard feature — service layer, security, controller, tests, edge cases, and performance — as one coherent whole.