Programmable Controllers: Theory and Implementation