Avoid the God class

This is one of the very common issues in application development, where a class either has too many lines of code or knows too much about the application or plays too many roles in an application. This type of a class is known as the God class. For example, it is a best practice that triggers should not contain business logic, and therefore we create helper classes. Sometimes, we create utility classes as well. By the time the development phase of a project progresses, these classes become huge and are referred to by many other classes. In such situations, refactoring of code becomes very tough and may break other parts of the application. As expected, developers avoid changing anything that exists in the God class, and therefore these types of classes contain many lines of code, which may not be used anywhere.

Tip

If this class is used indirectly by any Apex scheduled jobs, then it is serialized, and further updating the class is restricted by the platform while a job is in progress.

As per the best practices and the single responsibility principle, we should avoid these types of classes in our application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset