The Interpreter Pattern - Translate expressions in code episode artwork

EPISODE · Feb 8, 2022 · 17 MIN

The Interpreter Pattern - Translate expressions in code

from Develpreneur: Become a Better Developer and Entrepreneur · host Rob Broadhead

We continue our season of software architecture patterns and more by reviewing the interpreter pattern.  This one may seem familiar.  It has been discussed in other areas of software development.  However, it is worth refreshing our memory on this helpful solution. The Interpreter Pattern Defined The way this works is to start from a client, and given a context; we receive an expression.  That may be a very simple or complex series of "sentences."  Next, the expression is broken down into parts that are individually interpreted.  Finally, the combined results are sent back.  That gives us yet another pattern that involves breaking the big problem down into smaller pieces.  Thus, it is easier to solve. Applying The Pattern There are many opportunities for us to create a language in software and then use an interpreter.  Likewise, every computer science student has spent some time with these sorts of problems.  Of course, every computer language has this pattern implemented in some way.  While the interpreter pattern may seem difficult to apply, it has potential in many areas.  Therefore, it is worth considering as you design your approach.  As you will see, it is another way to chop up a big problem into more manageable bites. Challenges This pattern is based on splitting up the work (interpretation) into stand-alone steps that can be mixed and matched as needed.  The challenge is to avoid interdependencies wherever possible.  The less each unit of work links to others, the easier it is to build and re-use the solution.  There is also the problem of walking through a sentence or complex expression and breaking it into component parts. For example, think of diagraming a sentence.  It is not always a natural way to think about a request.  However, you can build from simple expressions up to complex ones.  Next, use testing to confirm you are on the right track.  Thus, the solution often ends up much easier to maintain than a holistic approach.  The focus is on components instead of the permutations of expressions.

NOW PLAYING

The Interpreter Pattern - Translate expressions in code

0:00 17:30

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

Frequently Asked Questions

How long is this episode of Develpreneur: Become a Better Developer and Entrepreneur?

This episode is 17 minutes long.

When was this Develpreneur: Become a Better Developer and Entrepreneur episode published?

This episode was published on February 8, 2022.

What is this episode about?

We continue our season of software architecture patterns and more by reviewing the interpreter pattern.  This one may seem familiar.  It has been discussed in other areas of software development.  However, it is worth refreshing our memory on this...

Can I download this Develpreneur: Become a Better Developer and Entrepreneur episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!