Plan du site  
pixel
pixel

Articles - Étudiants SUPINFO

Proof Of Concept - Algorithm Simulator

Par Etienne BAUDOUX Publié le 19/08/2015 à 15:36:44 Noter cet article:
(0 votes)
Avis favorable du comité de lecture

This is a POC consisting to realize a portable algorithm interpreter based on the architecture of SoftwareZator, who compile a code instead of interpret it, but the design patterns are very close together.

What is the concept ?

The concept is to be able to interpret and debug an algorithm by using C# at runtime. For a bigger challenge, we want to be able to use it in a cross-platform project.

It means several things :

  • I will be unable to use CodeDom or Roslyn to compile code and run it.

  • I will be unable to use the Windows Debugger as it is not available with WinRT for example, or even on Linux with Mono if we want to be more cross-platform in C#.

  • So, in this case, I will make my own CodeDom-like architecture, named AlgorithmDom.

  • And make an interpreter that will analyze the AlgorithmDom and perform an action depending of it.

Remark : the code is not very complicated, but the project architecture is complex because it uses a LOT of abstraction.

POC - Be indulgent

It is just a Proof Of Concept ! There is no Unit Test. There is not a lot of comments and documentation.

The simulator is not complete and not very clean ! There miss a lot of classes in AlgorithmDom compared to the existing CodeDom. It miss a lot of interpreters, the support of asynchronous simulation...etc. It is just the minimum !

How does it work ?

  1. First of all, we create a Project that represents a program with classes and methods.

  2. We add our global variables (it is simpler to manage in the simulator).

  3. In a method, we add an algorithm. This algorithm is represented by an Action. An action, in SoftwareZator, as in this simulator, it is a part of an algorithm that does something. For example :

  4. And then, we start the Simulator.

What does the simulator ?

  1. The first step is to create a dictionary that contains a definition of each variable in the project and their associated values.

  2. Then, we start to simulate/interpret each Action of the algorithm :

    1. We display in the Debug the value of each variables of the project (like Visual Studio does on a breakpoint).

    2. The action will generate an AlgorithmDom (my cross-plateform CodeDom-like architecture).

    3. And we will ask to the Interpreter to analyze it and change, for example, the value of a variable if tha AlgorithmDom is corresponding to an assignation.

    4. In case of exception in the algorithm (for example : I want to read a file that does not exists), we ask to the current Action to bring us some tips to fix this error.

Use case

  • Any programming learning app (SoftwareZator, Spark, Scratch...).

  • If you want to download a part of an application from internet in WinRT and want to run it. I guess that we cannot load an Assembly at runtime with WinRT. Download an algorithm and simulate it can be a solution.

Sources

Please find all my codes on my GitHub and feel free to read and reuse it as you want.

A propos de SUPINFO | Contacts & adresses | Enseigner à SUPINFO | Presse | Conditions d'utilisation & Copyright | Respect de la vie privée | Investir
Logo de la société Cisco, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société IBM, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sun-Oracle, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Apple, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sybase, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Novell, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Intel, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Accenture, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société SAP, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Prometric, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Toeic, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo du IT Academy Program par Microsoft, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management

SUPINFO International University
Ecole d'Informatique - IT School
École Supérieure d'Informatique de Paris, leader en France
La Grande Ecole de l'informatique, du numérique et du management
Fondée en 1965, reconnue par l'État. Titre Bac+5 certifié au niveau I.
SUPINFO International University is globally operated by EDUCINVEST Belgium - Avenue Louise, 534 - 1050 Brussels