# Using the Strategy Pattern | #56

> Episode of [PawCast with GeePaw Hill](https://podistic.com/podcast/pawcast-with-geepaw-hill.md) · Published May 19, 2020 · Duration 9:56 · Episode 56, season 1

- **Listen on Podistic:** https://podistic.com/episode/using-the-strategy-pattern-56
- **Audio:** https://anchor.fm/s/f6a6558/podcast/play/13938634/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fproduction%2F2020-4-18%2F74403300-44100-2-0880e9465d644.mp3 (audio/mpeg)

## About this episode

The strategy pattern lets you make "pluggable algorithms", so clients have different behavior without having different code themselves. We often use it to capture the "consequence in code" of some condition, which we can then let other code use without re-testing the condition. Here's a little java snippet:  
  
 dimension = horizontal ? width : height  
  
 If you're not familiar with ternary operations, what this says is "if horizontal is true, use the width, otherwise use the height". That snippet occurs in the context of a SplitPane (from JavaFx). A SplitPane holds N other panes, and its job is to lay them out in a row (or column!) with a draggable divider between them. The user drags the divider, and the child panes resize accordingly. If you think about that job, you realize that all the layout math is basically identical for horizontal splitters or for vertical ones, with the only difference being whether its all based on the widths of things or all based on the heights of things. 

\---

You can read the full transcription of this podcast over on [GeePawHill.org](https://geepawhill.org/). Any feedback, you can always tweet [@GeePawHill](https://twitter.com/geepawhill) on Twitter, or drop a voice message via the voice messages link here on Anchor. If you are interested in becoming more involved in the Change-Harvesting community, [click here to learn how to join GeePaw's Camerata](https://www.geepawhill.org/camerata/).
