Skip to content

Commit b390155

Browse files
committed
Deploying to gh-pages from @ fb4cf82 🚀
1 parent 21b2402 commit b390155

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

assets/jupyter/blog.ipynb.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

feed.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://logds.github.io/feed.xml" rel="self" type="application/atom+xml"/><link href="https://logds.github.io/" rel="alternate" type="text/html" hreflang="en"/><updated>2025-10-09T10:33:54+00:00</updated><id>https://logds.github.io/feed.xml</id><title type="html">LogDS Lab</title><subtitle>A simple, whitespace theme for academics. Based on [*folio](https://github.com/bogoli/-folio) design. </subtitle><entry><title type="html">Code generation from PlantUML</title><link href="https://logds.github.io/blog/2025/generating-code-plantuml/" rel="alternate" type="text/html" title="Code generation from PlantUML"/><published>2025-10-03T00:00:00+00:00</published><updated>2025-10-03T00:00:00+00:00</updated><id>https://logds.github.io/blog/2025/generating-code-plantuml</id><content type="html" xml:base="https://logds.github.io/blog/2025/generating-code-plantuml/"><![CDATA[<p><a href="https://plantuml.com/">PlantUML</a> syntax linearizes UML diagrams to a text file, similarly to <a href="https://systemarchitect.info/sysml-mbse/different-types-of-xmi/">XMI</a>: as for any tool supporting PlantUML as a UML representation, it should always be possible to generate code, as you are ultimately generating code from UML, independently of its serialisation format (UXF, XMI, etc.). The rationale behind it is to define a PlantUML parser which then generates classes and relationships according to the classes and relationships listed in the PlantUML file. Given this information, you can easily generate a class per instantiated class, as well as generate the fields as indicated by the relationships, while taking specific care of cardinality and aggregations, which should be ultimately represented as fields.</p> <p><strong>XMI Solution</strong></p> <p>Despite it should be possible to generate the UML directly from PlantUML, the only existing tool requires legacy NodeJS support and, during its operation with more recent versions of NodeJS, generates empty classes. An alternative solution is then to first generate an XMI file, for then ultimately generating the Java classes. This solution should be the less preferred one, as it currently seems that different tools support different XMI representations, <a href="https://plantuml.com/xmi">one conflicting with the other</a>. As far as I am concerned, ArgoUML was the tool better supporting PlantUML’s XMI syntax. Thus, you can generate ArgoUML XMI from PlantUML as follows:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>java -jar plantuml-1.2025.7.jar demofile.puml -txmi:argo
1+
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://logds.github.io/feed.xml" rel="self" type="application/atom+xml"/><link href="https://logds.github.io/" rel="alternate" type="text/html" hreflang="en"/><updated>2025-10-11T20:21:05+00:00</updated><id>https://logds.github.io/feed.xml</id><title type="html">LogDS Lab</title><subtitle>A simple, whitespace theme for academics. Based on [*folio](https://github.com/bogoli/-folio) design. </subtitle><entry><title type="html">Code generation from PlantUML</title><link href="https://logds.github.io/blog/2025/generating-code-plantuml/" rel="alternate" type="text/html" title="Code generation from PlantUML"/><published>2025-10-03T00:00:00+00:00</published><updated>2025-10-03T00:00:00+00:00</updated><id>https://logds.github.io/blog/2025/generating-code-plantuml</id><content type="html" xml:base="https://logds.github.io/blog/2025/generating-code-plantuml/"><![CDATA[<p><a href="https://plantuml.com/">PlantUML</a> syntax linearizes UML diagrams to a text file, similarly to <a href="https://systemarchitect.info/sysml-mbse/different-types-of-xmi/">XMI</a>: as for any tool supporting PlantUML as a UML representation, it should always be possible to generate code, as you are ultimately generating code from UML, independently of its serialisation format (UXF, XMI, etc.). The rationale behind it is to define a PlantUML parser which then generates classes and relationships according to the classes and relationships listed in the PlantUML file. Given this information, you can easily generate a class per instantiated class, as well as generate the fields as indicated by the relationships, while taking specific care of cardinality and aggregations, which should be ultimately represented as fields.</p> <p><strong>XMI Solution</strong></p> <p>Despite it should be possible to generate the UML directly from PlantUML, the only existing tool requires legacy NodeJS support and, during its operation with more recent versions of NodeJS, generates empty classes. An alternative solution is then to first generate an XMI file, for then ultimately generating the Java classes. This solution should be the less preferred one, as it currently seems that different tools support different XMI representations, <a href="https://plantuml.com/xmi">one conflicting with the other</a>. As far as I am concerned, ArgoUML was the tool better supporting PlantUML’s XMI syntax. Thus, you can generate ArgoUML XMI from PlantUML as follows:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>java -jar plantuml-1.2025.7.jar demofile.puml -txmi:argo
22
</code></pre></div></div> <p>This will generate a <code class="language-plaintext highlighter-rouge">demofile.xmi</code> file. Next, you can import the XMI file into ArgoUML: this will generate a PlantUML model. At the time of the writing, this will generate an empty class diagram with some class and relationships provided separately. Notwithstanding the former, it should always be possible to drag the classes on the empty class diagram file, which should automatically import the relationships occurring among the classes. After doing this, you can select all the classes for then generating the corresponding Java code. Please consider that ArgoUML does not corretly implement the difference between extension and implemnetation (interfaces), thus you might still generate some incorrect Java code, which should be fixed manually.</p> <p><strong>Legacy NodeJS Solution</strong></p> <p>If you have access to a <a href="https://github.com/jupe/puml2code/issues/59">legacy NodeJs version</a>, you can try to use this tool: this is limited to class diagrams, though but in essence, is generating code depending on the aforementioned description: <a href="https://github.com/jupe/puml2code">https://github.com/jupe/puml2code</a>. Given a PlantUML file <code class="language-plaintext highlighter-rouge">demofile.puml</code>, you can then generate some java code as follows:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>puml2code -i demofile.puml -l java
33
</code></pre></div></div>]]></content><author><name></name></author><category term="sample-posts"/><category term="xmi,"/><category term="plantuml,"/><category term="uml,"/><category term="java,"/><category term="code-generation"/><summary type="html"><![CDATA[This post provides a brief explanation on how to connect visualization tools to code generation, without using propietary software.]]></summary></entry><entry><title type="html">Process algebra and StateCharts</title><link href="https://logds.github.io/blog/2018/java-state/" rel="alternate" type="text/html" title="Process algebra and StateCharts"/><published>2018-09-16T00:00:00+00:00</published><updated>2018-09-16T00:00:00+00:00</updated><id>https://logds.github.io/blog/2018/java-state</id><content type="html" xml:base="https://logds.github.io/blog/2018/java-state/"><![CDATA[<p>If we want to model an access to a resource that could not be read and written at the same time, we could use either process algebra or State Charts from UML analysis. In either cases the desired object is an element that could perform both read and write operations, without changing the type of the element or to remember to close and re-open the object in a different state.</p> \[P = \textup{read}.P + \textup{read}.P\] <p><img src="https://raw.githubusercontent.com/jackbergus/LucenePdfIndexer/master/images/Diagramma1_2.png" alt="P = read.P + write.P" style="margin:auto; display:block;"/></p> <p>We know that usually it is not good to keep reading and writing operations on the same object, and hence we have always to close and re-open the object if we want to change the type of the operation. As a consequence we have to handle three objects at a time, an initial state (<code class="language-plaintext highlighter-rouge">P</code>), an opened state for reading purposes (<code class="language-plaintext highlighter-rouge">R</code>) and another one for writing (<code class="language-plaintext highlighter-rouge">W</code>). This could be easily modelled as follows</p> \[\begin{cases} P = \textup{openRead}.R + \textup{openWrite}.W &amp; \\ R = \textup{read}.R + \textup{close}.P &amp; \\ W = \textup{write}.W + \textup{close}.P &amp; \end{cases}\] <p><img src="https://raw.githubusercontent.com/jackbergus/LucenePdfIndexer/master/images/twostates_2.png" alt="Representing states P, R and W" style="margin:auto; display:block;"/></p> <p>Now we want to hide all the open and close operations, and hence we want to define an object, that is a State Machine, that keeps track of all the object states and then “smartly decides” which operations have to be carried out in order to reach the desired operation to execute.</p> \[\begin{cases} ClosedObject = \overline{\textup{OpenRead}}.\overline{\textup{close}}.ClosedObject + \overline{\textup{OpenWrite}}.\overline{\textup{close}}.ClosedObject&amp; \\ ReadableObject = {\textup{OpenRead}}.R&amp; \\ WritableObject = {\textup{OpenWrite}}.W&amp; \\ R = \textup{read}.R + \textup{close}.ReadableObject&amp; \\ W = \textup{write}.W + \textup{close}.WritableObject&amp; \end{cases}\] \[(\nu (\textup{OpenRead},\textup{OpenWrite},\textup{close})) ( ClosedObject | ReadableObject | WritableObjeect)\] <p><img src="https://raw.githubusercontent.com/jackbergus/LucenePdfIndexer/master/images/complete_2.png" alt="Representing the synchronized states" style="margin:auto; display:block;"/></p> <p>We could easily see that this implementation corresponds to the first tone, that is the model that we want to reach.</p> <h2 id="using-interfaces-to-implement-the-internal-states">Using Interfaces to implement the internal states</h2> <p>Firstly, we must declare in Java that closed, opened, readable and writable states belong to a same type of object. This allows define an unique interface for any possible state of the internal object.</p> <div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cm">/**
44
* Defines a document that could be opened, closed, read and written.

0 commit comments

Comments
 (0)