|
From: despird on 3 Apr 2007 21:54 SOME(Simple Object Model Edit) is not a programming language, it just seems like to be. If you know UML very well, you will understand SOME quite easily. Compare with UML, SOME seems more like a lauguage because it contains only charactors , unlike UML... If you're a kind of bored, just visit "http://blog.csdn.net/despird/" for some more details about SOME. But be careful, it might be another boring thing.
From: despird on 11 Apr 2007 21:57 On 4ÔÂ4ÈÕ, ÉÏÎç9ʱ54·Ö, "despird" <desp...(a)gmail.com> wrote: > SOME(Simple Object Model Edit) is not a programming language, it just > seems like to be. If you know UML very well, you will understand SOME > quite easily. Compare with UML, SOME seems more like a lauguage > because it contains only charactors , unlike UML... > > If you're a kind of bored, just visit "http://blog.csdn.net/despird/" > for some more details about SOME. But be careful, it might be another > boring thing. Strategy pattern of SOME Code of SOME: AStrategy //Abstract class Strategy{} a_DoAlgorithm() //public abstract void DoAlgorithm() CFirstStrategy : AStrategy //class FirstStrategy: Strategy{} o_DoAlgorithm() //public override void DoAlgorithm() CSecondStrategy : AStrategy //class SecondStrategy: Strategy{} o_DoAlgorithm() //public override void DoAlgorithm() CContext ->AStrategy[_s] //reference list (Strategy _s) //constructor DoWork() DoStrategyWork() CCliet main // abbreviation of main entry CClient.main { CFirstStrategy firstStrategy.(); //FirstStrategy firstStrategy = new FirstStrategy(); CContext c.(_s = firstStrategy); //Constructor with quick assignment c.DoWork(); // only invoking c.DoStrategyWork() // invoking and definition { // definition beginning of Context::DoStrategyWork() _s.DoAlgorithm<CFirstStrategy>() // override method invoking and definition { // definition beginning of CFirstStrategy::DoAlgorithm() <% Console.WriteLine("In first strategy"); %> //object code snippet }; // end of definition: CFirstStrategy::DoAlgorithm() }; //end of definition: Context::DoStrategyWork() } Code of C#: abstract class Strategy { abstract public void DoAlgorithm(); } class FirstStrategy : Strategy { override public void DoAlgorithm() { Console.WriteLine("In first strategy"); } } class SecondStrategy : Strategy { override public void DoAlgorithm() { Console.WriteLine("In second strategy"); } } class Context { Strategy s; public Context(Strategy strat) { s = strat; } public void DoWork() { // some of the context's own code goes here } public void DoStrategyWork() { // now we can hand off to the strategy to do some // more work s.DoAlgorithm(); } } ///<summary> /// Summary description for Client. ///</summary> public class Client { public static int Main(string[] args) { FirstStrategy firstStrategy = new FirstStrategy(); Context c = new Context(firstStrategy); c.DoWork(); c.DoStrategyWork(); return 0; } }
From: despird on 11 Apr 2007 22:10 Stragety pattern in SOME code in c#: abstract class Strategy { abstract public void DoAlgorithm(); } class FirstStrategy : Strategy { override public void DoAlgorithm() { Console.WriteLine("In first strategy"); } } class SecondStrategy : Strategy { override public void DoAlgorithm() { Console.WriteLine("In second strategy"); } } class Context { Strategy s; public Context(Strategy strat) { s = strat; } public void DoWork() { // some of the context's own code goes here } public void DoStrategyWork() { // now we can hand off to the strategy to do some // more work s.DoAlgorithm(); } } ///<summary> /// Summary description for Client. ///</summary> public class Client { public static int Main(string[] args) { FirstStrategy firstStrategy = new FirstStrategy(); Context c = new Context(firstStrategy); c.DoWork(); c.DoStrategyWork(); return 0; } } code in SOME: AStrategy //Abstract class Strategy{} a_DoAlgorithm() //public abstract void DoAlgorithm() CFirstStrategy : AStrategy //class FirstStrategy: Strategy{} o_DoAlgorithm() //public override void DoAlgorithm() CSecondStrategy : AStrategy //class SecondStrategy: Strategy{} o_DoAlgorithm() //public override void DoAlgorithm() CContext ->AStrategy[_s] //reference list (Strategy _s) //constructor DoWork() DoStrategyWork() CCliet main // abbreviation of main entry CClient.main { CFirstStrategy firstStrategy.(); //FirstStrategy firstStrategy = new FirstStrategy(); CContext c.(_s = firstStrategy); //Constructor with quick assignment c.DoWork(); // only invoking c.DoStrategyWork() // invoking and definition { // definition beginning of Context::DoStrategyWork() _s.DoAlgorithm<CFirstStrategy>() // override method invoking and definition { // definition beginning of CFirstStrategy::DoAlgorithm() <% Console.WriteLine("In first strategy"); %> //object code snippet }; // end of definition: CFirstStrategy::DoAlgorithm() }; //end of definition: Context::DoStrategyWork() } As you can see, a type declaration is just like class diagram, while a sequence definition is a plain-text way for sequence diagram. A SOME model emphasizes not only the static structure for class relations, but the dynamic flow of how objects cooperate and in what order they execute. Furthermore, you can place multiple type declarations and sequence definitions in any order, and SOME generator will know how to organize them in an object-oriented way and translate them into desired source code in a certain language. So SOME is a light-weight design language, learning and using SOME is quite simple and time-saving, you just need a text edit tool, then input your codes and save them into a SOME source file. Next step SOME compiler will help to check its grammar, and next, SOME generator will make it into source codes in a certain object-oriented language(ranging from c++, java, c# to VB.net, even MSIL.) . Actually, "Compiling" is the process of Code Engineering, features of which you heard from UML. Besides, Having no keywords is another reason for being simple. Instead of keywords, it uses some short tokens such as ".", "->", or specific prefix to denote desired meanings. these are some examples(c#): "CSample" means "class Sample". "o_Method()" means "public override void Method()". "int r_Length" means "private int _length; public int Length{get{return _length};}" (note: read-only property). "CSample s<CSubSample>.();" means "CSample s = new CSubSample();". "obj;" means "return obj;".
|
Pages: 1 Prev: Mixing P/R philosophy with OO (within J2EE). Next: What gives data meaning? |