Post on 21-Dec-2015
transcript
Declarative Approach to Implementing Automata Classes
in Imperative Programming Languages
Artyom Astafurov, SPbSUITMOArtyom.Astafurov@gmail.comAnatoly Shalyto, SPbSUITMO
Second Spring Young Researchers’ Colloquium on Software EngineeringMay 29th 2008
Before We Start
• Automata based programming?• OOP and Automata?• Imperative?• Declarative?• Our framework• Example
Result: working code that doesn’t have explicit delegation of calls to nested automatons and
has all the magic behind the inheritance implemented
public interface IAcceptsPlay{ void Play();}public interface IAcceptsPlayHold{ void PlayHold();}public interface IIpodPlayer : IAcceptsPlay, IAcceptsPlayHold{ }
public class Sleeping : State, IAcceptsPlay{
public void Play(){
//...}
}
public class PlayerMode : State, IAcceptsPlayHold{
public void PlayHold(){
//...}
}
[InitialState(“Sleeping”), InnerState(“PlayerMode”)]public class IpodPlayer : Automaton, IIpodPlayer{
// Play and PlayHold stubs go here}
public class Paused : State, IAcceptPlay{
public void Play() {
Container.SetState(“Playing”); }}
public class Playing : State, IAcceptPlay{
public void Play() {
Container.SetState(“Paused”); }}
[InitialState(“Paused”),State(“Playing”)]public class NewPlayerMode : PlayerMode{
// That’s it!}