Cooking with the Strategy Pattern

Here’s a brief checklist on how to implement the strategy pattern:

1. Determine what aspects of your program vary versus which aspects are static.

2. Encapsulate the aspects that vary by creating interfaces/classes for each of them.

3. Program to the encapsulated interfaces/classes rather than implementing those aspects locally.

4. Strive to utilize composition over inheritance as much as possible to keep your code as flexible and maintainable as possible.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s