inheritance of automata classes using dynamic programming languages (using ruby as an example)

16
Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example) Kirill Timofeev [email protected] 29.05.2009

Upload: jalila

Post on 25-Feb-2016

48 views

Category:

Documents


2 download

DESCRIPTION

Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example). Kirill Timofeev. [email protected]. 29.05.2009. Table of Context. Automata-Based Programming and Its Benefits Extended Automata Approach Dynamical Programming Languages - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Inheritance of Automata Classes Using Dynamic Programming Languages(Using Ruby as an Example)

Kirill Timofeev

[email protected]

29.05.2009

Page 2: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Automata-Based Programming and Its Benefits Extended Automata Approach Dynamical Programming Languages Graphical Notation being Used Inheritance of Automata Classes Comparison by Extending Ruby on Rails Plugin Conclusions

Table of Context

Page 3: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Minimalistic core: transitions, states, and functions (actions and guard conditions)

Documentation and software development happens at the same time

Visual and obvious specifications

Possibility of automata (and software) verification and reverse engineering

Automata-Based Programming and Its Benefits

Page 4: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Acts automata as an object-oriented class

Nested groups (encapsulation): reduce duplicataed transitions

Automata inheritance: reduce number of states and transitions required for a new automata creation

Extended Automata Approach: Object Automata Approach

Page 5: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Allow runtime program extension

Dynamic creation of new methods

Macro scripts usage and executing any text instruction as a program code (evaluation)

Partial support of functional style by using lambda functions and closures

And... DSL – Domain Specific Language

Dynamical Programming Languages

Page 6: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

There is no spoon strict definition of dynamical languages

In 2008 the proportion of dynamic languages to the languages with static type checking was 40%

The most popular dynamical languages: Javascript, Python, Ruby

Buzz word again: Ruby on Rails

Some Fact of Dynamical Languages

Page 7: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Complex programs are build on simple functions aggregation

Polimorphism of data types

Easy to test and verify software: no side effects

More expressive syntax by using closures and lambda functions (hello, DSL!)

Functional Programming Languages

Page 8: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Graphical Notation Being Used

SampleUser automata class presented

It inherited from BasicUser

Added new group Deleted

Group Activation has been overrided

New state Suspended was added

Page 9: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Basic Registered User Automata

BasicUser automata class presented

Has five states: Deleted, Pending, Passive, Active, and Suspended

On entering Active state system generates the activation code (lambda function)

Guard conditions on event Unsuspend

Page 10: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Extended User Registration Automata

AdvancedUser automata class presented

Inherited from BasicUser automata

New group Activation with states: Captcha and Active

New group Deleted: Suspended and Deleted (delete user's data)

Page 11: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

A Nightmare without Nested Groups and Inheritance – Part 1/3

Statistic Number of

transitions: 11 Number of states: 5

Page 12: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

A Nightmare without Nested Groups and Inheritance – Part 2/3

Are you still not afraid in the dark?!

StatisticStates: 8Transitions: 20

(O'RLY?)Statistic (with groups and

inheritance)States: 8Transitions: 9Groups: 3

Page 13: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

A Nightmare without Nested Groups and Inheritance – Part 3/3

VS

Page 14: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Ruby Domain Specific Languageautomaton :user, :initial => :activation do

state :deleted

group :activation, :initial => :pending do

transition :suspend, :to => :suspended

transition :delete, :to => :deleted

state :passive do

transition :register, :to => :pending,

:guard => Proc.new { ... },

:proc => Proc.new { ... }

end

end

end

Macro methods Automaton State Group Transition

Each method creates special class Integrated with Ruby on Rails and Active Record libraries

Page 15: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Automata is a great approach which helps a lot to describe and create systems with a complex behavior

It's easy to maintain a system by using object-automata approach, groups, and inheritance

It can be plugged in to many existing system without monkey patching and code breaks

Syntax matters. By using helpers and macros (building DSL) it's possible to reduce an automata code by 50%

Conclusion

Page 16: Inheritance of Automata Classes Using Dynamic Programming Languages (Using Ruby as an Example)

Thank you!

Questions?