Title: Declarative Approach to Implementing Automata Classes in Imperative Programming Languages
1Declarative Approach to Implementing Automata
Classes in Imperative Programming Languages
Second Spring Young Researchers Colloquium on
Software Engineering May 29th 2008
- Artyom Astafurov, SPbSUITMO
- Artyom.Astafurov_at_gmail.com
- Anatoly Shalyto, SPbSUITMO
2Before We Start
- Automata based programming?
- OOP and Automata?
- Imperative?
- Declarative?
- Our framework
- Example
3- What is Automata based programming?
4(No Transcript)
5(No Transcript)
6 7Foundation
8Nesting
9Inheritance
10 11- Explicit instructions
- Steps to take
- Answers the question How?
12 13- Defines the end result
- Doesnt contain steps to achieve the result
- Answers the question What?
14- This HTML code
- lthtmlgt
- Input ltinput value"Hello, world!"gt
- lt/htmlgt
- Can produce
15(No Transcript)
16 17 18- Imperative for functionality and logic
- Declarative for the structure
19or
InnerState(State1A) public class State1 //
Events go here
20- Add some reflection or instrumentalization
21- Result working code that doesnt have explicit
delegation of calls to nested automatons and has
all the magic behind the inheritance implemented
22 23(No Transcript)
24 25public interface IAcceptsPlay void
Play() public interface IAcceptsPlayHold
void PlayHold() public interface IIpodPlayer
IAcceptsPlay, IAcceptsPlayHold
26public class Sleeping State, IAcceptsPlay pub
lic void Play() //... public class
PlayerMode State, IAcceptsPlayHold public
void PlayHold() //... InitialState(Sl
eeping), InnerState(PlayerMode) public class
IpodPlayer Automaton, IIpodPlayer // Play
and PlayHold stubs go here
27 28public 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) pub
lic class NewPlayerMode PlayerMode // Thats
it!
29And the new player is
30State(PlayerMode, NewPlayerMode) public
class NewIpodPlayer IpodPlayer // Thats
it!
31