Skip to content

Classic Gang of Four design patterns in the Salesforce Apex programming language

License

Notifications You must be signed in to change notification settings

bdJohnson72/Design-Patterns-In-Apex

Repository files navigation

Design Patterns In The Apex Programming Language

CI Workflow

recipes-logo

Few things have helped me more in my career than understanding how you use the Object Oriented Features of Apex to write code that is flexible, testable and maintainable. I have done quite a few YouTube videos on this topic and have a lot more to do. I was not happy with my previous Repo and its organization. This is an attempt of my part to give back to the community with repo that offers implementations of all the class Gang of Four patterns in Apex. I grant you that my implementations will often be trivial and contrived. But I hope that helps make the underlying ideas easy to understand.

If I have also published a video about the pattern I have added a link to in the heading.

Table of Contents

Creational Patterns

Design patterns that are concerned with the creation of objects

  • One of my every day go to patterns. Code is based on Head First Design Patterns
  • UML diagram

-Watch on YouTube

This can be a bit more involved but is also the ultimate in closed for modification but open for extension. By making our factory reflective we never need to update it when we add new concrete types.

  • Unique to Apex and Salesforce. Refactor the simple factory pattern with custom metadata. Wow your colleagues with the Type class. One of my favorite Apex party tricks.

-Watch on YouTube

Another implementation using the pizza example from Head First Design Patterns. What do we do if we want our Pizza Store to access different factories?

-Watch on YouTube

An easy pattern to understand and always useful for keeping your governer limits under control

Behavioral Design Patterns

These patterns are all about the communication between objects. How can objects cooperate to perform tasks.

-Watch on YouTube

When one object changes state we want to notify all the depenents. But we want to publisher and subscribers to be loosely coupled.

##Refactoring I have begun to add some of the examples from Martin Fowler's Refactoring and Joshua Kerievsky's Refactoring to Patterns

Read All About It

Nothing in this repo would be possible without the books below. And most of the implementations will be based on ones found in these books. If they are not on your shelf they should be.

About

Classic Gang of Four design patterns in the Salesforce Apex programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published