Proposal : IoC and conditional block

6 views
Skip to first unread message

eKameleon

unread,
May 30, 2011, 10:07:56 AM5/30/11
to VEGAS - ECMASCript & ActionScript OpenSource framework
Hello :)

----- English

I propose a new feature in the IoC factory of VEGAS.

Right now I'm trying to develop new tools in the package system of
VEGAS (Maashaack) with the new packages system.rules and
system.process.logic. That will enable the development of simple and
complex conditional logic in our applications and invoke tasks in a
sequencer or a batch without taking the head of a logic function if /
else / elseif and more when I'm done with all these tools.

You can if you want to start reading the reference being written on
the google project site:

http://sites.google.com/site/ekameleon/Home/opensource/vegas-opensource-project/vegas-tutorials/condition-task-engine

These tools are very interesting and will extend the possibilities of
the task engine (system.process) entered by giving a new conditional
approach in your applications.

This is my problem:) To extend the use of conditional rules
(system.rules) in the factory IoC VEGAS I have an idea to extend the
system of "factory strategy" that allows to change the logical objects
are created in the factory for a given object definition.

The idea would be to create objects in the factory according to preset
patterns and so create "conditional block" easy to implement and use
the principle of dependency injection in the existing factory.

Here is an example of an object to define the logical strategy to
create an object:

# if-else if-else factory block

factoryLogic:
{
pattern: "if {0} elseif {1?} elseif {2} else {3}"
arguments: [{ref: "ref_rule"}, {ref: "ref1"}, {ref: "ref2"},
{ref: "ref3"}}
}

# Ternary Operator factory block

factoryLogic:
{
pattern: "cond {0}? {1} {2}"
arguments: [{ref: "ref_rule"}, {ref: "ref1"}, {ref: "ref2"},
{ref: "ref3"}}
}

Example of use in an IoC context :

{
id: "mario"
type: "Mario" / / library
}
,
{
id: "luigi"
type: "Luigi" / / library
}
,
{
id: "is_mario"
type: "system.rules.Equals"
arguments: [{config: "user.name"}, {value: "mario"}]
}
,
{
id: "Hero"
type: "flash.display.MovieClip"
factoryLogic:
{
pattern: "cond {0}? {1} {2}"
arguments: [{ref: "is_mario"}, {ref: "mario"}, {ref: "luigi"}}
}
}

We can imagine in the next evolution of the library to defines for,
for..in, for..each blocks, etc. :)

I hope you take some time to get an idea of ​​this new tool to give me
your opinion on it)

Any reaction on the subject interests me!

----- french

Je vous propose une nouvelle fonctionnalité dans la fabrique IoC de
VEGAS.

En ce moment je suis en train de développer des nouveaux outils dans
le package system.* de VEGAS (Maashaack) avec les packages
system.rules et system.process.logic qui vont permettre de développer
des logiques conditionnelles simples ou complexes dans nos
applications et invoquer des taches dans un séquenceur ou un batch
sans se prendre la tête en fonction d'une logique if/else/elseif et
bien plus encore quand j'en aurai fini avec tous ces outils.

Vous pouvez si vous en avez envie commencer à lire la référence en
cours d'écriture sur le google site du projet :

http://sites.google.com/site/ekameleon/Home/opensource/vegas-opensource-project/vegas-tutorials/condition-task-engine

Ces outils sont très intéressant et vont étendre les possibilités du
moteur de taches (system.process) existant en donnant une toute
nouvelle approche conditionnelle dans vos applications.

J'en arrive à ma problématique :) Pour prolonger l'usage des règles
conditionnelles (system.rules) dans la fabrique IoC de VEGAS j'ai dans
l'idée d'étendre le system de "factory strategy" qui permet de changer
la logique de création des objets dans la fabrique pour une définition
d'objet donnée.

L'idée serai de créer des objets dans la fabrique en suivant des
patterns prédéfinis et ainsi de créer des "conditional block" simple à
implémenter et utilisant le principe d'injection de dépendance
existant déjà dans la fabrique.

En gros si l'on souhaite créer un objet et mettre en place son contenu
en fonction de certains critères (config, etc.) il serait pas mal de
pouvoir utiliser dans un premier temps une logique conditionnelle de
base de type if/else/elseif ou cond?true:false (opérarateur ternaire)
pour définir la nature de l'objet en fonction de règles
conditionnelles simples.

Voici donc un exemple d'objet pour définir la stratégie logique
permettant de créer un objet :

# pour un if/elseif/else

factoryLogic :
{
pattern : "if {0} elseif {1 } elseif {2} else {3}"
arguments : [ { ref : "ref_rule" } , { ref : "ref1" } , { ref :
"ref2" } , { ref : "ref3" } }
}

# pour un cond ? true : false

factoryLogic :
{
pattern : "cond {0} ? {1} : {2}"
arguments : [ { ref : "ref_rule" } , { ref : "ref1" } , { ref :
"ref2" } , { ref : "ref3" } }
}

Example d'utilisation dans un context ioc :

{
id : "mario" ,
type : "Mario" // library
}
,
{
id : "luigi" ,
type : "Luigi" // library
}
,
{
id : "is_mario" ,
type : "system.rules.Equals" ,
arguments : [ { config : "user.name" } , { value : "mario" } ]
}
,
{
id : "hero" ,
type : "flash.display.MovieClip" ,
factoryLogic :
{
pattern : "cond {0} ? {1} : {2}"
arguments : [ { ref : "is_mario" } , { ref : "mario" } ,
{ ref : "luigi" } }
}
}

A voir du coup par la suite si il peut être utile d'ajouter des for..
for..in for..each etc :)

J'espère que vous prendrez un peu de temps pour vous faire une idée de
ce nouvel outil pour me donner votre avis sur la chose :) Je vais
continuer à réfléchir sur ce système conditionnel intégré dans les
définitions d'objets de la fabrique IoC... pour voir si je peux faire
mieux que ce qui est défini ci-dessus.

Toute réaction sur le sujet m'intéresse !

EKA+ :)
Reply all
Reply to author
Forward
0 new messages