DEV Community

Arthur Menezes
Arthur Menezes

Posted on

The 2,000-line Apex class nobody dares to touch

On a recent project I worked with Apex files over 2,000 lines long that nobody fully understood. It got so bad I'd joke with the team that just removing a System.debug — a line that changes literally nothing — felt like it might break something three processes away.

The disease is always the same in messy orgs: there's no shared vocabulary. What's a Service? What's a DAO? Where does business logic actually live? Nobody agreed, so every dev did it their way — and two years later nobody touches anything without breaking three other things.

It's never a talent problem. The people who built it know the business and know Salesforce. What's missing is a convention.

I wrote down the exact set of patterns I apply when I walk into a new org — Trigger Handler, Service, DAO, Controller and Wrapper — with the before/after Apex for each and how they wire together:

👉 Read the full breakdown here

Curious where others draw the line between Service and Controller in practice. 👇

Top comments (0)