Generátor smalltalku z UML

Generátor smalltalku uxf2st

Ryantova úvodní stránka | Stáhnout uxf2st pro Win64 nebo Linux

15. prosince 2013

1. Účel

Program uxf2st slouží k převodu diagramů UML do jazyka Smalltalk. Generuje zdrojový program ve smalltalku pro vývojové prostředí Pharo z diagramu tříd nástroje Umlet. Generují se jen třídy a vazby mezi třídami, ostatní prvky diagramu se ignorují. Diagram musí být uložen jako soubor v formátu uxf (to je nativní formát Umletu).

2. Licence

Autorem programu uxf2st je Ivan Ryant. Program smí být volně užíván a šířen k nevýdělečným účelům tak, jak je. Uživatel není oprávněn program měnit a šířit jej smí pouze vcelku v originální podobě, zejména společně s tímto návodem a licenčním ujednáním. Přes veškerou svou snahu autor nezaručuje, že v programu nejsou chyby, ani že program bude správně sloužit zamýšlenému účelu. S požadavky na opravu chyb nebo na změny programu se obracejte na autora na adresu ryant@atlas.cz. K jakémukoli jinému užití programu nad rámec této licenční smlouvy je potřeba získat souhlas autora.

3. Instalace

Program se instaluje pod 64bitovou verzi MS Windows (testováno pod MS Windows Vista). Rozbalte komprimovaný soubor s programem uxf2st.exe. Podle potřeby upravte spouštěcí dávku uxf2st.bat.

4. Spuštění

Spuštěním programu uživatel vyjadřuje souhlas s licenčním ujednáním. Licenční klíč pro volné užití programu je "free".

Program se spouští z příkazové řádky příkazem ve tvaru:

uxf2st licenceKey input\path\file.uxf output\directory\

např.:

uxf2st free C:\Users\Ivan\Documents\UmletModels\pokus1.uxf C:\Users\Ivan\Documents\UmletModels\uxf2st\

Chcete-li program spouštět opakovaně, můžete k tomu použít dávku. Dávku nejsnáze vytvoříte úpravou vzorové dávky uxf2st.bat.

5. Chyby a jejich oprava

Doběhne-li uxf2st správně až do konce, vypíše na konzoli "Done". V tom případě se má ve výstupním adresáři objevit vygenerovaný soubor s příponou .st. Hlásí-li uxf2st při běhu chybu, přečtěte si chybové hlášení a pokuste se chybu odstranit. Chybu obvykle odstraníte opravou diagramu.

Jednou z tajemných příčin chyb může být, že po importu předchozího zdrojového souboru .st do Pharo nezavřete Pharo a pokoušíte se přepsat starý zdrojový soubor pomocí uxf2st. Zdá se, že starý naimportovaný soubor zůstává otevřený a nedá se přepsat. Chybu opravíte např. tím, že zavřete Pharo.

Není-li příčina chyby zřejmá, obraťte se na autora nejlépe mejlem na adresu ryant@atlas.cz, popište, jak k chybě dochází, a přiložte uxf-soubor s diagramem. Pokud se vygeneroval smalltalkový program, přiložte i ten.

6. Import do Pharo

Přetáhněte myší ikonu souboru .st do okna vývojového prostředí Pharo. Pharo vám dá vybrat, co chcete se souborem udělat - zvolte "FileIn entire file". Hlásí-li Pharo chyby při importu, opravte je nejlépe v diagramu, případně ve zdrojovém souboru .st. Typickou chybou jsou např. duplicitní jména tříd nebo atributů. Jestliže implementujete několik navzájem disjunktních vazeb (např. na fáze), měly by být v diagramu všechny tyto vazby pojmenovány stejně - ale uxf2st vygeneruje několik atributů se stejným jménem a Pharo to pak odmítne importovat. Chybu opravíte např. tak, že jméno vazby uvedete v diagramu nikoli opakovaně u vazeb, nýbrž jako roli u svorníku "XOR". Případně také můžete chybu opravit jen ve zdrojovém souboru pro Pharo (smažete tam duplicitní atributy). Automatické rozpoznání disjunktního vztahu mezi vazbami je problematické a mohlo by vést k chybám, které by Pharo ani nedetekovalo.

Proběhne-li import úspěšně, otevřete "System Browser" - v seznamu packages by se měl objevit importovaný program. Důkladně si prohlédněte, co se nahrálo včetně "Class side" a včetně komentářů. V komentářích bývají uvedeny požadované násobnosti atributů a vazeb, které je potřeba zajistit programem. Dále jsou v komentářích uvedena různá další omezení, zejména neimplementované vazby.

Které vazby se generují automaticky a které musíte naprogramovat sami? Není-li vyznačen směr navigace nebo je-li navigace obousměrná, uvede se jen omezení (constraint) v komentáři ke třídě a implementace vazby je ponechána na vás. Má-li vazba vyznačený směr navigace, implementuje se jako atribut té třídy, ze které vychází. V metodě "initialize" se nastavují počáteční hodnoty atributů a vazeb buď na výchozí hodnotu uvedenou v diagramu (default) nebo na hodnotu nil nebo na kolekci. Atribut s násobností >1 se inicializuje na kolekci a podobně se inicializuje také vazba, která má na cílové straně násobnost >1. Chcete-li implementovat "lazy initialization", musíte sami změnit jak vygenerovanou inizializaci atributu, tak i příslušný accessor (getter).

Násobnost na výchozí straně vazby se musí také zajistit, ale příslušné testy se negenerují automaticky. Jen u inicializace atributu, který implementuje vazbu, je uveden komentář s požadovanou násobností na výchozí straně. Implementace případného testu je na vás.

Pečlivě si prohlédněte v systémovém browseru, které třídy a vazby se podařilo vygenerovat a zkontrolujte také atributy a metody. Jestliže něco chybí, prohlédněte si vygenerovaný zdrojový text ve smalltalku, protože co se nedalo ani vygenerovat, ani napsat do poznámek ke třídám, to může být uvedeno jako poznámka ve zdrojovém programu i mimo třídy. Typicky se jedná o vazby, které nejsou napojeny oběma konci na třídu, nebo o uživatelsky definované prvky diagramu. Většina těchto komentářů se nachází na začátku souboru, nicméně některé mohou být i jinde. Tyto komentáře začínají "NOTE:", takže podle toho je v editoru snadno vyhledáte (použijte např. ctrl-F v notepadu).

7. Tady návod končí.

Ryantova úvodní stránka | Stáhnout uxf2st pro Win64 nebo Linux

15. prosince 2013

uxf2st Smalltalk Generator

Ryant's home | Download uxf2st for Win64 or Linux

December 15, 2013

1. Purpose

Use uxf2st to convert UML diagrams into Smalltalk. The uxf2st generates source program in Smalltalk for Pharo development environment from the UmLet UML class diagram. Only classes and relations between classes are generated, other elements of the diagram are ignored. The diagram must be saved in an uxf file format (which is the native format of UmLet).

2. Licence

The author of the uxf2st program is Ivan Ryant. The program may be freely used and distributed as is and for non-profit purposes only. User may not modify the program and may distribute it only in its original form, particularly together with the manual and license agreement. Despite all the efforts, the author does not guarantee that the program is free of errors, or that it will properly serve its intended purpose. With requirements for correction of errors or changes in the program, contact the author at the address ryant@atlas.cz. For any other use of the program beyond this license agreement you are required to obtain the explicit consent of the author. Licence key for free use is 'free'.

3. Installation

Install the program under 64-bit MS Windows (tested under MS Windows Vista). Unzip the zip file with the program uxf2st.exe. Adjust the starting batch uxf2st.bat.

4. Launching

By launching the program, the user agrees to the License Agreement. The license key for the free use of the program is "free".

Run the program from the command line with the command like this:

uxf2st licenceKey input\path\file.uxf output\directory\

e.g.:

uxf2st free C:\Users\Ivan\Documents\UmletModels\pokus1.uxf C:\Users\Ivan\Documents\UmletModels\uxf2st\

To run the program repeatedly, you can use a batch. The easiest way to create your own batch is editing the sample batch file uxf2st.bat.

5. Errors and Their Correction

If uxf2st finishes successfully, the console displays "Done". In this case, the generated file with the extension .st appears in output directory. If uxf2st reports an error, read the error message and try to correct the error. Errors can be usually fixed by correcting the diagram.

One of the mysterious causes of error may be that after importing the previous .st source file into Pharo you haven't closed the Pharo and you try to overwrite the old file with the new one. It seems that the previously imported file remains open and can not be overwritten. Fix the error e.g. by closing Pharo.

If no obvious cause of the error can be found, contact the author preferably by e-mail to addresses ryant@atlas.cz, describe how the error occurs and attach uxf-diagram file. If the smalltalk source file has been generated, attach it, too.

6. Import to Pharo

Drag the .st file icon to the window of Pharo development environment. Pharo asks you to choose what you want to do with the file - select "FileIn entire file". If Pharo reports any errors at import, try to cerrect them preferably in the diagram or, alternatively, in the source file. Duplicate class or attribute names is a typical error. If you implement several disjoint links (e.g. phase), all links should be named the same, because just one attribute is enough to implement all the links - but uxf2st generates several attributes of the same name. Pharo then refuses to import the source file. You can fix the bug e.g. by writing the name of the attribute not to the links, but as a role name at the "XOR" dotted line. Alternatively, you can just fix the bug in the source file for Pharo (delete the duplicate attributes). Automatic recognition of disjoint relationship between constraints is problematic and could lead to errors that Pharo would not be able to detect.

As the import is successfull, open the "System Browser" - the imported program should appear in the list of packages. Please look what has been imported, including "Class side" and including comments. The comments usually contain a list of desired multiplicities of attributes and relationships that have to be checked by your program. The comments also contain various other constraints, especially unimplemented links.

Which links are generated automatically and which you need to program yourself? If no direction of navigation is indicated or if bidirectional navigation is indicated, there is reported only constraint in the comments to the class and the implementation of links is left to you. If the direction of navigation is marked at the link, it is implemented by an attribute in the class where it originates. The initial values of the attributes and links in the "initialize" method are set either to the default value shown in the diagram, or they are set to nil or to a collection. Attribute with multiplicity >1 is initialized to the collection, and also a link which target has the multiplicity >1 is initialized similarly. To implement the "lazy initialization" you have to change both the generated initialization of the attribute, and the proper accessor (getter), as well.

The required multiplicity must be also ensured at the starting side of the link, but the tests are not generated automatically. Only at the initialization of the attribute that implements the link, there is given the desired multiplicity in a comment. Implementation of any test is left to you.

Review carefully in system browser, what classes and links succeeded to get generated and check also the attributes and methods. If something is missing, check the generated source code in Smalltalk, because anything what could be neither generated, or at least commented, it can be written as a comment in the source program outside of class declarations. Typically, that applies to the links that are not connected with their both ends to classes, or a to user-defined diagram elements. Most of the comments are located at the beginning of the file, however, some may be elsewhere. These comments begin with "NOTE", so they can be easily found by your editor (e.g., use ctrl-F in Notepad).

7. This is End of the Manual

Ryant's home | Download uxf2st for Win64 or Linux

December 15, 2013