Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
Like this article? We recommend

Using the Interpreter Pattern

We’ve seen a simple example of implementing a Boolean grammar. How might this use be extended to produce something like the scheme pictured in Figure 1? Let’s say that we wanted to implement the semantics shown in Figure 1. This amounts to the rules illustrated in Listing 10.

Listing 10 A network management policy.

Can I create a path from router 1 to router 5?
Required bandwidth: 5Mbps
Round trip: 3ms

The answer to how you might implement something like this lies in the expression classes and the associated evaluation functions. A new expression class could be created, such as PathExpression, into which the required parameters are passed. The parameters are the path, the bandwidth, and the roundtrip time. The rule processor in Figure 1 would determine whether the constraints could be met. The result would then be passed back to the network management system in Figure 1, where it would be fed back into the evaluation function. The network manager would then know whether or not the required path could be placed.

  • + Share This
  • 🔖 Save To Your Account