implicit conversion

X10 Home Automation using a Scala internal DSL

Scala has been designed to enable the implementation of Domain Specific Languages. This is surely one of its major strength (see DSLs – A powerfull Scala feature for more information).

This article is an attempt to develop a very simple internal DSL dealing with the X10 home automation protocol (as done here on the top of Oslo).

Here is the syntax (not sure that it reflects exactly the X10 protocol, but it's enough for our example ...):
  • on [house_code] [unit_code]
    where [house_code] is a letter between A and P (16 values) and [unit_code] an integer between 1 and 16 or All (for any devices).
  • Idem for the off command
  • It's the same for bright and dim commands except that an additional level parameter is required:
    bright A 12 level 80

Scala & the Decorator design pattern

As mentioned in my previous article about the Proxy design pattern, the ability to add features to an existing abstraction without involving an explicit extension of this abstraction is basically the purpose of the Decorator design pattern.
So, this article is simply a recap of the way to implement a Decorator using the technique based on implicit conversion.

Scala & the Proxy design pattern

In this article we will focus on the Proxy design pattern as defined by the GoF.
In short, the definition of the "Proxy" pattern could be reduced to "something for something". That's why it will be presented here as the Quid Pro Quo pattern, "Quo" meaning the entity that will be controlled/wrapped by the "Quid" entity (i.e. the proxy itself).
Syndicate content