<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Luminis Software Development &#187; Uncategorized</title>
	<atom:link href="http://lsd.luminis.eu/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://lsd.luminis.eu</link>
	<description></description>
	<lastBuildDate>Sun, 03 Mar 2013 08:42:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>nl</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Kennissessie Services op 24 oktober: de videos</title>
		<link>http://lsd.luminis.eu/kennissessie-services-op-24-oktober-de-videos/</link>
		<comments>http://lsd.luminis.eu/kennissessie-services-op-24-oktober-de-videos/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 11:28:52 +0000</pubDate>
		<dc:creator>Richard van der Laan</dc:creator>
				<category><![CDATA[Celix]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Apache ACE]]></category>
		<category><![CDATA[Apache Celix]]></category>
		<category><![CDATA[Apache Felix]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[Services]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1755</guid>
		<description><![CDATA[Op 24 oktober 2011 vond een kennissessie plaats over services in gedistribueerde en/of embedded omgevingen. Deze sessie was georganiseerd door Luminis in samenwerking met Thales en leden van de Apache community, en ging in op de vraag hoe het toepassen van services kan helpen bij het verbeteren van de flexibiliteit van bestaande systemen.

De video presentaties van deze sessie zijn nu beschikbaar.]]></description>
			<content:encoded><![CDATA[<p>Op 24 oktober 2011 vond een kennissessie plaats over services in gedistribueerde en/of embedded omgevingen. Deze sessie was georganiseerd door Luminis in samenwerking met Thales en leden van de Apache community, en ging in op de vraag hoe het toepassen van services kan helpen bij het verbeteren van de flexibiliteit van bestaande systemen.</p>
<p>De video presentaties van deze sessie zijn nu beschikbaar.</p>
<p><strong>Innovatie, Services en Open Source</strong><br />
<em>Rene van Hees, Technical Authority Software bij Thales</em></p>
<p><a href="http://www.youtube.com/watch?v=2NlzXw37okM&#038;fmt=18">http://www.youtube.com/watch?v=2NlzXw37okM</a></p>
<p><strong>OSGi en Dynamische Services</strong><br />
<em>Marcel Offermans, lid van de Apache Software Foundation</em></p>
<p><a href="http://www.youtube.com/watch?v=bfEOKva1xhc&#038;fmt=18">http://www.youtube.com/watch?v=bfEOKva1xhc</a></p>
<p><strong>Apache Celix en Apache Foundation</strong><br />
<em>Alexander Broekhuis, Software Engineer Luminis, committer Apache Celix</em></p>
<p><a href="http://www.youtube.com/watch?v=FG04jERMznU&#038;fmt=18">http://www.youtube.com/watch?v=FG04jERMznU</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/kennissessie-services-op-24-oktober-de-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARTER Surveillance Use Case &#8211; Industrial Evaluation</title>
		<link>http://lsd.luminis.eu/charter-surveillance-use-case-industrial-evaluation/</link>
		<comments>http://lsd.luminis.eu/charter-surveillance-use-case-industrial-evaluation/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 14:31:29 +0000</pubDate>
		<dc:creator>Andriy Levytskyy</dc:creator>
				<category><![CDATA[MDD]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[CHARTER]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[evaluation]]></category>
		<category><![CDATA[industry]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[MDE]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1718</guid>
		<description><![CDATA[This month, Luminis has started development of a surveillance use case. The purpose of the case is industrial assessment and validation of tools and technologies developed in the “Critical and High Assurance Requirements Transformed through Engineering Rigor” project (CHARTER).  The ultimate goal of CHARTER is to ease, accelerate, and cost-reduce the certification of embedded systems. The CHARTER tool-suite employs real-time Java, Model Driven Development (MDD), rule-based compilation and formal verification. The coming series of articles will describe evaluation experiences in the surveillance use case.]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1719 alignleft" title="Screen shot 2011-10-10 at 4.18.26 PM" src="http://lsd.luminis.eu/wp-content/uploads/2011/10/Screen-shot-2011-10-10-at-4.18.26-PM.png" alt="Screen shot 2011-10-10 at 4.18.26 PM" width="150" height="150" />This month, Luminis has started development of a surveillance use case. The purpose of the case is industrial assessment and validation of tools and technologies developed in the “Critical and High Assurance Requirements Transformed through Engineering Rigor” project (<a href="http://charterproject.ning.com/" target="_blank">CHARTER</a>).  The ultimate goal of CHARTER is to ease, accelerate, and cost-reduce the certification of embedded systems. The CHARTER tool-suite employs real-time Java, Model Driven Development (MDD), rule-based compilation and formal verification. The coming series of articles will describe evaluation experiences in the surveillance use case.</p>
<p>The CHARTER project includes user partners from four key industries: aerospace, automotive, surveillance and medical, each of which develops embedded systems that require high assurance or formal certification in order to meet business or governmental requirements. The four user partners will each validate the CHARTER tools and methodology using industrial applications and actual development scenarios, which will provide feedback for the project and ensure the tools and technologies perform as expected, and deliver the expected improvements in embedded systems development. As part of the evaluation process, metrics will be used to quantify industrial experiences in terms of development effort, cost savings, verification time, etc., to document for others the benefits achieved.</p>
<p>The CHARTER project was established to improve the software development process for developing critical embedded systems. Critical embedded software systems assist, accelerate, and control various aspects of society and are common in cars, aircraft, medical instruments and major industrial and utility plants. These systems are critical to human life and need to be held to the highest standards of performance through formal certification procedures. Improving the quality and robustness of these systems is paramount to their widespread adoption.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/charter-surveillance-use-case-industrial-evaluation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When MDE does not reduce effort</title>
		<link>http://lsd.luminis.eu/when-mde-does-not-reduce-effort/</link>
		<comments>http://lsd.luminis.eu/when-mde-does-not-reduce-effort/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 12:36:40 +0000</pubDate>
		<dc:creator>Andriy Levytskyy</dc:creator>
				<category><![CDATA[MDD]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[benefit]]></category>
		<category><![CDATA[effort]]></category>
		<category><![CDATA[MDE]]></category>
		<category><![CDATA[MDSD]]></category>
		<category><![CDATA[metric]]></category>
		<category><![CDATA[modelling]]></category>
		<category><![CDATA[quality]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1534</guid>
		<description><![CDATA[While effort reduction and quality increase are both commonly recognized benefits of MDE, the former particularly has become its trademark, thanks to numerous generative uses in model-driven software development (MDSD). Examples include generation of code and configurations from models written in UML, DSLs and XML.


Figure: The effort in MDE approach with partial manual coding (adapted [...]]]></description>
			<content:encoded><![CDATA[<p>While effort reduction and quality increase are both commonly recognized benefits of MDE, the former particularly has become its trademark, thanks to numerous generative uses in model-driven software development (MDSD). Examples include generation of code and configurations from models written in UML, DSLs and XML.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1539" title="The effort in MDE approach with partial manual coding" src="http://lsd.luminis.eu/wp-content/uploads/2011/08/The-effort-in-MDE-approach-with-partial-manual-coding1.png" alt="The effort in MDE approach with partial manual coding" width="507" height="301" /></p>
<p style="text-align: center;">
<p><em>Figure: The effort in MDE approach with partial manual coding (adapted from [1])</em></p>
<p>The generative MDE automates well defined routine activities. An effective metric of depicting economical benefit thereof is effort. The above figure illustrates effort reduction due to automation and reuse in an MDE approach with partial manual coding. Of cause, the generative MDE improves quality as well: error reduction, enforced architecture conformance, and up-to-date documentation are common factors that have positive effect on software quality. But usually these are considered as icing on the cake that is effort reduction. In my experience this perspective on the economical value of MDE is common among both customers and MDE professionals. The perspective can be summarized as “the same with less”.</p>
<p><strong>More with the same</strong></p>
<p>Recently a client tasked me together with its domain experts to assess benefits of applying MDE to a difficult process within the organization. Having analyzed the before and after situations, we came up with estimated economical benefit expressed in effort savings. The estimate was hard to quantify, but “should” have been OK. Although I wanted to share this optimism, I felt that in practice the effort saving would be negligible if not even negative. This paradox was due to the fact that the largest activity in the problem domain was inherently creative and exploratory.</p>
<p>In the figure, the output of a single exploration in this activity is shown as intermediate result, corresponding to line <em>ad</em>. As the figure suggests, code generation directly from the output is not possible (this happens further downstream in development). You may have noticed that the modelling curve rises more steeply towards point <em>a</em>. This rise occurs because modelling requires increased level of domain understanding and more information is needed by semantically rich operations, such as simulation, verification, code generation (eventually), etc. On the other hand, the figure shows effort reduction indicated by distance <em>cd</em>, which is the result of providing end users with proper abstractions, faster access to right knowledge, separation of concerns, DRY modelling, maintained consistency and integrity.</p>
<p>While working efficiency per exploration is likely to  increase (compare <em>ab</em> and <em>cd</em>), the leading concern is quality of the output. Here benefits are early detection of design errors, deep exploration of design choices, better communication and documentation, maximized reuse of domain-specific platforms in further development. Moreover, the domain experts noted that any saved effort would be re-invested in more alternative explorations in search of a more optimal output. This increased number of explorations, is likely to balance out any savings due to higher efficiency.</p>
<p>With these insights, economical benefits were expressed with quality metrics and linked to different business goals than initially thought.</p>
<p><strong>Conclusion</strong></p>
<p>The described MDE assessment targets a highly creative engineering activity that explores alternative choices. In extreme case, the main benefit is not effort reduction, but increased product and process quality. The icing on the cake is that processable models can open opportunities for generative uses as well.</p>
<p>In my experience, such and certainly less extreme quality-driven cases are not exotic. In recent years, quite a few MDE projects I’ve participated in, had benefits strongly linked to quality improvement. What are your MDE experiences with creative activities? What were the economical benefits and how were they conveyed?</p>
<p><strong>References</strong></p>
<p>[1] Thomas Stahl, Markus Voelter, Krzysztof Czarnecki. “Model-Driven Software Development: Technology, Engineering, Management”. Wiley; 1 edition (May 19, 2006)</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/when-mde-does-not-reduce-effort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to build a custom model interpreter in a model-driven way</title>
		<link>http://lsd.luminis.eu/how-to-build-a-custom-model-interpreter-in-a-model-driven-way/</link>
		<comments>http://lsd.luminis.eu/how-to-build-a-custom-model-interpreter-in-a-model-driven-way/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 15:41:54 +0000</pubDate>
		<dc:creator>Andriy Levytskyy</dc:creator>
				<category><![CDATA[MDD]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AToM3]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[executable]]></category>
		<category><![CDATA[execution]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[mda]]></category>
		<category><![CDATA[MDE]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[semantics]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[workbench]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1511</guid>
		<description><![CDATA[Blogs by Johan den Haan, Stefano Butti and Jordi Cabot raised interesting discussions about code generation (CG) and model interpretation (MI). One observation I took from these discussions is that MI is still little known. Previously I demonstrated operation of a custom-made model interpreter for a so-called weighbridge domain. Today I would like to share [...]]]></description>
			<content:encoded><![CDATA[<p>Blogs by <a href="http://www.theenterprisearchitect.eu/archive/2010/06/28/model-driven-development-code-generation-or-model-interpretation" target="_blank">Johan den Haan</a>, <a href="http://tinyurl.com/3gga7f6" target="_blank">Stefano Butti</a> and <a href="http://modeling-languages.com/executable-models-vs-code-generation-vs-model-interpretation/" target="_blank">Jordi Cabot</a> raised interesting discussions about code generation (CG) and model interpretation (MI). One observation I took from these discussions is that MI is still little known. Previously I demonstrated <a href="http://lsd.luminis.eu/model-interpretation-for-weighbridge-domain/" target="_blank">operation of a custom-made model interpreter for a so-called weighbridge domain</a>. Today I would like to share my experience of building this interpreter in a model-driven way.</p>
<p><strong>MDE Approach</strong></p>
<p>Two main choices underpin the process and technology used to develop the interpreter:</p>
<ol>
<li>Execution semantics of the interpreter is defined within the problem domain itself (weighbridge in this case), without translating it to another domain (e.g. .Net or Java) as it is the case with CG. Such definition of semantics is also known as operational semantics. The advantage is reduction of development complexity: out of at least 2 domains needed for CG, only one and the more abstract domain is sufficient.</li>
<li>Operational semantics is defined within an MDE framework. This enables customization of modeling language for problem domains besides that of the weighbridge example. Moreover, transformation capabilities are used to define operational semantics.</li>
</ol>
<p style="text-align: center;"><img class="size-medium wp-image-1514 aligncenter" title="Domain-specific, nested interpretation MDE framework" src="http://lsd.luminis.eu/wp-content/uploads/2011/07/Domain-specific-nested-interpretation-MDE-framework-300x247.png" alt="Domain-specific, nested interpretation MDE framework" width="300" height="247" /></p>
<p><em>Figure 1: Domain-specific, nested interpretation (DSNI) MDE framework</em></p>
<p>Figure 1 shows the MDA framework [1] after it has been adapted to reflect the above mentioned choices. (If you are confused between MDA and MDE, you might find this <a href="http://modeling-languages.com/relationship-between-mdamdd-and-mde/" target="_blank">article</a> useful.) In contrast to MDA, there is no PIM or PSM model, but single computational independent model (CIM) written in DSL. CIM is both source and target of Transformation Tool. Transformation Tool carries out transformation classified as same language, same model. Transformation Definition defines operational semantics. It is not important if Transformation Definition Language (TDL), extends the Metalanguage as in MDA or is customizable by means of meta-specification. Therefore TDL is omitted from the framework and TDL selection criteria are defined instead (see below). Finally, new concept System Context is connected to Transformation Tool. This is due to the fact that interpretation as system exhibits external behavior through communication with other systems.</p>
<p>This approach can be described as nested interpretation, where a domain-specific interpreter is executed (nested) by a generic interpreter. From this perspective, Transformation Tool assumes the role of a generic interpreter and execution of Transformation Definition fills in the role of the domain-specific interpreter.</p>
<p><strong>TDL Selection Criteria</strong></p>
<p>Selection criteria for transformation definition language are:</p>
<ul>
<li>declarative modeling</li>
<li>support for domain-specific notation</li>
</ul>
<p>These criteria help to reduce development complexity and improve communication with problem domain experts.</p>
<p><strong>Selected MD Technology</strong></p>
<p><a href="http://atom3.cs.mcgill.ca/" target="_blank">AToM3</a> is a free language workbench written in Python and under development at the Modelling, Simulation and Design Lab (MSDL) in the School of Computer Science of McGill University. The workbench closely matches the DSNI framework and meets the TDL selection criteria.</p>
<p>In AToM3, DSLs and models are described as graphs. From a language specification written in the metalanguage (ER formalism), AToM3 generates a tool to visually manipulate (create and edit) models written in the specified DSL. Model transformations are performed by graph rewriting. The transformations themselves can thus be declaratively expressed as graph-grammar models. However, AToM3 provides no communication infrastructure as needed by the framework.</p>
<p><strong>Proof of Concept</strong></p>
<p>As demonstration, a language specification for the weighbridge domain was defined (see sections <strong>domain</strong> and <strong>weighbridge DSL</strong> <a href="http://lsd.luminis.eu/model-interpretation-for-weighbridge-domain/" target="_blank">here</a>) and graph rewriting was used to model operational semantics (see below). Source code of AToM3 itself, being written in Python, was extended to support web services for the communication purpose.</p>
<p><strong>Operational </strong><strong>Semantics</strong></p>
<p>As blueprint for operational semantics of the interpreter, we took πDemos [2], a small process-oriented discrete event simulation language. There is a number of πDemos events that change state of a weighbridge system. For each such event, [2] defined the transitions induced on system state. While the original used functional programming language, this work uses graph rewriting and a graph grammar (GG) rule is defined per event.</p>
<table border="0">
<tbody>
<tr>
<th>Priority</th>
<th>GG Rule</th>
<th>Description</th>
</tr>
<tr>
<td>50</td>
<td>importProcess</td>
<td>Adds an external vehicle to EL</td>
</tr>
<tr>
<td>25</td>
<td>removeProcess</td>
<td>Deletes a vehicle that has completed its todos (events)</td>
</tr>
<tr>
<td>40</td>
<td>newR</td>
<td>Creates a new weighbridge</td>
</tr>
<tr>
<td>40</td>
<td>decP</td>
<td>Creates a new vehicle class</td>
</tr>
<tr>
<td>40</td>
<td>newP</td>
<td>Creates a vehicle from a vehicle class</td>
</tr>
<tr>
<td>40</td>
<td>getR</td>
<td>Acquires a non-busy weighbridge</td>
</tr>
<tr>
<td>40</td>
<td>blockProcess</td>
<td>Blocks a vehicle acquiring a busy weighbridge</td>
</tr>
<tr>
<td>40</td>
<td>promoteProcess</td>
<td>Unblocks a delayed vehicle</td>
</tr>
<tr>
<td>40</td>
<td>useR</td>
<td>Moves a vehicle on a weighbridge until service is complete</td>
</tr>
<tr>
<td>30</td>
<td>releaseResource</td>
<td>Moves a served vehicle from a weighbridge to EL</td>
</tr>
<tr>
<td>41</td>
<td>putR</td>
<td>Releases an occupied weighbridge</td>
</tr>
</tbody>
</table>
<p><em>Table 1: Graph grammar rules of weighbridge events</em></p>
<p>Table 1 lists the minimum set of required events and their corresponding GG rules. Execution of such rules needs to be globally orchestrated through proper sequencing. The rules, together with execution sequencing, form an operational semantics model of the interpreter.</p>
<p>For complete description of the model, please refer to [3]. In the following, we present a detailed description of an example rule, followed by the execution sequencing model.</p>
<p><strong>Example GG Rule</strong></p>
<p><img class="alignnone size-medium wp-image-1515" title="LHS" src="http://lsd.luminis.eu/wp-content/uploads/2011/07/LHS-246x300.png" alt="LHS" width="246" height="300" /></p>
<p>a) Left-hand side (LHS)</p>
<p><img class="alignnone size-medium wp-image-1516" title="RHS" src="http://lsd.luminis.eu/wp-content/uploads/2011/07/RHS-287x300.png" alt="RHS" width="287" height="300" /></p>
<p>b) Right-hand side (RHS)</p>
<p><em>Figure 2: Subgraphs of the promoteProcess rule</em></p>
<p>Rule promoteProcess releases a busy weighbridge (bluish box in Figure 2a) that delays at least one vehicle (yellow box labelled 5). In the new state, the weighbridge remains busy and the blocked vehicle (5) is removed from the head of queue Delay and inserted in waiting queue EL.</p>
<p>The rule is executed if:</p>
<div>
<div>
<ol>
<li>The left-hand side (LHS) shown in Figure 2a is matched in the host graph (the CIM model).</li>
<li>Associated condition is true: the weighbridge in LHS is the one referred to in the imminent event putR (a todo) in the body (a todo list) of the first vehicle (label 21) in queue EL.</li>
</ol>
<p>If the above holds, the matched part of the CIM model is substituted with the right-hand side (RHS) shown in Figure 2b. Note new objects are labelled 10, 11, 13. The entities and relationships in RHS are initialized as follows:</p>
<ol>
<li>Objects copied from LHS keep all their properties.</li>
<li>Imminent event putR (a todo)  of the current vehicle (21) is completed.</li>
<li>All properties of blocked vehicle (5) are copied to vehicle (10).</li>
</ol>
<p><strong>Execution Sequencing</strong></p>
<p>The execution sequencing is based on the next-event approach: Next event to execute is always the imminent event in the body of the current vehicle. Informally, the operational semantics of execution sequencing is as follows: if EL is empty, interpreter idles until at least one vehicle is inserted in EL. Such vehicle becomes current. If the body of the current vehicle is empty then it is removed from EL and EL is examined again. Otherwise, interpreter  executes a GG rule corresponding to the imminent event of the current and EL is examined again. Note that whenever interpreter is idle, EL is being updated with new vehicles that meanwhile might have arrived from system context.</p>
<p>The execution sequencing is implemented by organizing GG rules into groups, each group having its own base priority. These groups, in the descending order of priority are: vehicle removal, weighing activities and vehicle arrival. Within a group, each rule is assigned a relative priority. If pattern matching of two and more rules within a group is deterministic on the basis of LHSs and conditions, then these rules can share the same priority level. Example rule priorities are given in Table 1.</p>
<p><strong>Conclusion</strong></p>
<p>The demonstrated development approach is characterized by a very high level of abstraction, direct involvement of problem domain experts and absence of software development. All these factors contribute to fast development times: The lead time of this one man project including research and development was 3 weeks. Admittedly, tests of the produced model interpreter showed noticeable performance penalty due to 1) repurposing of MD technology that was not designed for use as interpreter and 2) the overhead introduced by nested interpretation. In my opinion there is much room for performance improvement and I am wondering if MDE can prove useful again. An important message from this experience is that model interpretation does not have to be prerogative of big commercial tools and can get closer to code generation in terms of accessibility.</p>
<p><strong>References</strong></p>
<p>[1] Anneke G. Kleppe, Jos Warmer and Wim Bast. &#8220;MDA Explained: The Model Driven Architecture: Practice and Promise&#8221;. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, April 2003.</p>
<p>[2] Graham Birtwistle and Chris Tofts. &#8220;An operational semantics of process-oriented simulation languages: Part 1 πDemos&#8221;. ACM Transactions on Modeling and Com- puter Simulation, 10(4):299–333, December 1994.</p>
<p>[3] Andriy Levytskyy. &#8220;Model Driven Construction and Customization of Modeling &amp; Simulation Web Applications&#8221;. PhD thesis, Delft University of Technology, Delft, The Netherlands, January 2009.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/how-to-build-a-custom-model-interpreter-in-a-model-driven-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Threading made easy in .Net 4.0 (2/2)</title>
		<link>http://lsd.luminis.eu/threading-made-easy-in-net-4-0-22/</link>
		<comments>http://lsd.luminis.eu/threading-made-easy-in-net-4-0-22/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 15:06:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1429</guid>
		<description><![CDATA[.net threading system.threading.task twitter parallel 4.0 microsoft dotnet ]]></description>
			<content:encoded><![CDATA[<h3>Threading made Easy (2/2)</h3>
<p>This blog is part two of a little example I wrote to test the new threading stuff in .Net 4.0. To read part 1 follow this <a href="http://lsd.luminis.eu/treading-made-ease-in-net-4-0/">link</a>.</p>
<p>Short recap from part 1 first. This is what I wrote:<br />
The thing I have to do is get some data from the web in the following pseudo manner:<br />
<code><br />
foreach subject from the list<br />
search for the last 100 tweets on this subject<br />
</code></p>
<p>The part left over was to show some results from the threaded calls from part 1. It so happens to be that, somewhere near the end, I showed the following call as the most nicest and clean threading mechanism:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> GetParallel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Parallel.<span style="color: #0600FF;">ForEach</span><span style="color: #000000;">&#40;</span>UrlList, url <span style="color: #008000;">=&amp;</span>gt<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#123;</span>
            Get<span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h4>Threadsafe collections</h4>
<p>From the example it shows we&#8217;re not doing anything useful with the result which is returned by Twitter. A byte array is returned and the thing I want to do is to store the byte array in a collection of byte arrays. Pretty simple huh? Well almost because a potential threading problem is kickin&#8217; in. The standard collections in .Net are <em>not</em> threadsafe. We used to write code with a locking object and lock the piece of code which makes changes to the collection. The new .Net 4.0 has a more smooth solution to this problem: System.Collections.Concurrent.BlockingCollection. And the code above is changed in:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// use a thread safe collection for all threads</span>
BlockingCollection<span style="color: #008000;">&lt;</span><span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">&gt;</span> data <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BlockingCollection<span style="color: #008000;">&lt;</span><span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
Parallel.<span style="color: #0600FF;">ForEach</span><span style="color: #000000;">&#40;</span>UrlList, url <span style="color: #008000;">=&gt;</span>
<span style="color: #000000;">&#123;</span>
    data.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>Get<span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// return an ordinary collection (non thread safe) to the outside world</span>
<span style="color: #0600FF;">return</span> data.<span style="color: #0000FF;">ToList</span><span style="color: #008000;">&lt;</span><span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>So each thread use a thread safe collection to store its results and when we&#8217;re ready with all threads the non-threadsafe counterpart is returned because when processing the result we don&#8217;t need any multithreaded handling.</p>
<h4>Twitter data structure</h4>
<p>Twitter returns its data in JSON format. The search API returns the data in the following structure (see also the <a href="http://apiwiki.twitter.com/w/page/22554756/Twitter-Search-API-Method:-search">Twitter API documentation</a>), here is an example:<br />
<code><br />
{<br />
&nbsp;&nbsp;"results":<br />
&nbsp;&nbsp;[<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"text":"@twitterapi  http:\/\/tinyurl.com\/ctrefg",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"to_user_id":396524,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"to_user":"TwitterAPI",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"from_user":"jkoum",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "metadata":<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"result_type":"popular",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"recent_retweets": 109<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"id":1478555574,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"from_user_id":1833773,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"iso_language_code":"nl",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"source":"&lt;a href="http:\/\/twitter.com\/"&gt;twitter&lt;\/a&gt;",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/118412707\/2522215727_a5f07da155_b_normal.jpg",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"created_at":"Wed, 08 Apr 2009 19:22:10 +0000"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... truncated ...<br />
&nbsp;&nbsp;],<br />
&nbsp;&nbsp;"since_id":0,<br />
&nbsp;&nbsp;"max_id":1480307926,<br />
&nbsp;&nbsp;"refresh_url":"?since_id=1480307926&amp;q=%40twitterapi",<br />
&nbsp;&nbsp;"results_per_page":15,<br />
&nbsp;&nbsp;"next_page":"?page=2&amp;max_id=1480307926&amp;q=%40twitterapi",<br />
&nbsp;&nbsp;"completed_in":0.031704,<br />
&nbsp;&nbsp;"page":1,<br />
&nbsp;&nbsp;"query":"%40twitterapi"<br />
}</code></p>
<p>The list of byte arrays we have is a list of bytes in JSON format. Each byte array represents the results of a query and consists of some meta data describing the query and a list with references to all tweets returned by the search query. Each of these byte arrays needs to be transformed in something more meaningful and useful. Here JSON comes to the rescue, it is not only blazingly fast it is also simple. All we have to do is just define the interesting elements in the structure and the serialization will do its work, silently and fast. The structure in a .Net understandable format is:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>DataContract<span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> TwitterSearchResultList
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>DataMember<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> TwitterSearchResult<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> results <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#91;</span>DataMember<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> query <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#91;</span>DataMember<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">double</span> completed_in <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#91;</span>DataContract<span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> TwitterSearchResult
<span style="color: #000000;">&#123;</span>
     <span style="color: #000000;">&#91;</span>DataMember<span style="color: #000000;">&#93;</span>
     <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> from_user <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
     <span style="color: #000000;">&#91;</span>DataMember<span style="color: #000000;">&#93;</span>
     <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> text <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
     <span style="color: #000000;">&#91;</span>DataMember<span style="color: #000000;">&#93;</span>
     <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> profile_image_url <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Transforming one byte array with twitter results is now as easy as:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">List<span style="color: #008000;">&lt;</span>TwitterSearchResultList<span style="color: #008000;">&gt;</span> tweets <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>TwitterSearchResultList<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> tweetlist <span style="color: #0600FF;">in</span> allTweetLists<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
        MemoryStream tweetStream <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MemoryStream<span style="color: #000000;">&#40;</span>tweetlist<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        DataContractJsonSerializer serializer <span style="color: #008000;">=</span> 
                <span style="color: #008000;">new</span> DataContractJsonSerializer<span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>TwitterSearchResultList<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        TwitterSearchResultList tsrl <span style="color: #008000;">=</span> 
                <span style="color: #000000;">&#40;</span>TwitterSearchResultList<span style="color: #000000;">&#41;</span>serializer.<span style="color: #0000FF;">ReadObject</span><span style="color: #000000;">&#40;</span>tweetStream<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h4>Rendering to html</h4>
<p>To render the TwitterSearchReturnList to a presentable format I generated some html. This can be done much cleaner and nicer with XSLT and/or CSS but for the sake of the example I just coded the bare minimum. It looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">StringBuilder <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
stringBuilder.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;TABLE&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>TwitterSearchResult tweet <span style="color: #0600FF;">in</span> list.<span style="color: #0000FF;">results</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
     stringBuilder.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;TR&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
     <span style="color: #008080; font-style: italic;">// the tweeters' avatar</span>
     stringBuilder.<span style="color: #0000FF;">AppendFormat</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;TD&gt;&lt;IMG src=<span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span> width=<span style="color: #008080; font-weight: bold;">\&quot;</span>48<span style="color: #008080; font-weight: bold;">\&quot;</span> heigth=<span style="color: #008080; font-weight: bold;">\&quot;</span>48<span style="color: #008080; font-weight: bold;">\&quot;</span> /&gt;&lt;/TD&gt;&quot;</span>, tweet.<span style="color: #0000FF;">profile_image_url</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
     <span style="color: #008080; font-style: italic;">// tweeters' name</span>
     stringBuilder.<span style="color: #0000FF;">AppendFormat</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;TD&gt;{0}&lt;/TD&gt;&quot;</span>, tweet.<span style="color: #0000FF;">from_user</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
     <span style="color: #008080; font-style: italic;">// tweet text; with all urls as an href</span>
     stringBuilder.<span style="color: #0000FF;">AppendFormat</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;TD&gt;{0}&lt;/TD&gt;&quot;</span>, Regex.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span>tweet.<span style="color: #0000FF;">text</span>, <span style="color: #666666;">&quot;(http:/[<span style="color: #008080; font-weight: bold;">\\</span>S/]*)&quot;</span>, <span style="color: #666666;">&quot;&lt;a href=<span style="color: #008080; font-weight: bold;">\&quot;</span>$1<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;$1&lt;/A&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    stringBuilder.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;/TR&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
stringBuilder.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;/TABLE&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Resulting in the following output:<br />
 <a href="http://lsd.luminis.eu/wp-content/uploads/2011/02/ThreadingTestOutput.png"><img src="http://lsd.luminis.eu/wp-content/uploads/2011/02/ThreadingTestOutput-1024x657.png" alt="ThreadingTestOutput" title="ThreadingTestOutput" width="750" height="480" class="aligncenter size-medium wp-image-1465" /></a></p>
<h4>Source code</h4>
<p>The full source code for this example can be downloaded <a href="http://lsd.luminis.eu/wp-content/uploads/2011/02/ThreadingTest.zip">here</a>.<br />
Thank you for reading, questions will be answered, suggestions are more than welcome!<br />
have fun,<br />
florisz </p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/threading-made-easy-in-net-4-0-22/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Threading made easy in .Net 4.0 (1/2)</title>
		<link>http://lsd.luminis.eu/treading-made-ease-in-net-4-0/</link>
		<comments>http://lsd.luminis.eu/treading-made-ease-in-net-4-0/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 12:27:22 +0000</pubDate>
		<dc:creator>Floris Zwarteveen</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1356</guid>
		<description><![CDATA[.net threading threads system.threading.task twitter parallel 4.0 microsoft dotnet ]]></description>
			<content:encoded><![CDATA[<h3>Threading made Easy (1/2)</h3>
<p>In my opinion it isn’t possible to have these two words in one sentence. I’ve been exposed to thread programming numerous times in the past. Despite the almost heroic nature of being a ‘thread programmer’, I’ve never had the guts to expose this in public. Brag over a few beers about success stories on how well my thread-aware and thread-safe software was running? It has never been part of my vocabulary. One simple reason: it’s way too complicated. Well, at least for me. Even with the aid of thorough design, good examples and extensive mock tests my code remained complicated and incomprehensible. And yes, I tried to refactor, redesign, recode, restructure, whatever, I never could get it right.</p>
<p>Well, up until .Net 4 and its component: System.Threading.Tasks. Included in the very core of the framework. Right out of the box, support for threading for the masses.</p>
<h4>Why threading?</h4>
<p>It is good to step back for one moment. The 1-million-dollar-question to always ask yourself is: do I really need it? The simple answer is: yes. Because why would you let anyone wait while your machine is sitting there doing nothing? Especially when it is not necessary to wait.</p>
<blockquote><p>So: yes I need threading to make software as performant as can be to the best of my abilities as a software engineer.</p></blockquote>
<p>Do I always have to use threading? Of course not. In its most essential form, current CPU’s can do multiple things at the same time (especially when having more cores) and are very fast and therefore often waiting for some other things (like database or web I/O stuff) to end before they can continue. So if you’re in such a situation, and I can assure you, this is most often, threads come to the rescue to really utilize the CPU to its full capacity.</p>
<h4>The example</h4>
<p>Let’s apply threading to a simple example to show how the new .Net threadinglayer can be utilized to increase performance 40-70% in a very easy manner.</p>
<p>Suppose you want to do a multiple query on Twitter (most popular demo environment) in which you need to return the first 100 hits for a couple of subjects. I have tried this with my webbrowser and you have to do some manual work to return such a list in one piece.</p>
<p>Beforehand I do know getting 100 tweets from Twitter isn’t that difficult, especially with their JSON based REST API (that’s a lot of cool keywords in one sentence!). So one task is easy to implement. I also know that getting something from the internet usually sets my CPU in a comfortable waiting state because network transfer is still way slower than my CPU. So the task is also suitable for multiplexing a couple of times.</p>
<h4>Some preparation</h4>
<p>First I have to define my testcases. I don’t want to get bogged down into testclasses (although I do agree it would have been better to use them) because hey, this is demo code anyway.</p>
<p>The thing I want to show you is:<br />
<img class="alignnone size-full wp-image-1390" title="ThreadingScenario" src="http://lsd.luminis.eu/wp-content/uploads/2011/01/ThreadingScenario.png" alt="ThreadingScenario" width="284" height="219" /><br />
In short, I want to show the performance differences between four separate scenarios<br />
-      A non threaded one<br />
-      A classic, pre 4.0, threadpool version<br />
-      A 4.0 version using the new TaskFactory<br />
-      And finally the version using the new Parallel class</p>
<p>These scenarios all do exactly the same thing; only the scheduling of the tasks differs. The thing they have to do is get some data from the web in the following pseudo manner:<br />
<code><br />
foreach subject from the list<br />
search for the last 100 tweets on this subject<br />
</code></p>
<p>The search API in Twitter is pretty straightword. For example, to perform the above for the subject ‘luminis’ the following url will suffice:</p>
<p><code>http://search.twitter.com/search.json?&amp;q=luminis&amp;rpp=100<br />
</code><br />
To get data from the web I’ve defined a small routine which returns a byte array with the required data. Fortunately WCF made getting data from the web pretty straightforward in .Net, this resulted in the very simple basic routine:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> Get<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> url<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> data <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
    WebClient wc <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebClient<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">try</span>
    <span style="color: #000000;">&#123;</span>
        data <span style="color: #008000;">=</span> wc.<span style="color: #0000FF;">DownloadData</span><span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">catch</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// probable time out, for this demo just quit</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">finally</span>
    <span style="color: #000000;">&#123;</span>
        wc.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">return</span> data<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This routine is part of a class called WebContent. This class also has a public property UrlList which can contain the list of urls for which the content must be read.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> List _UrlList <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> List UrlList
<span style="color: #000000;">&#123;</span>
    get
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">return</span> _UrlList<span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>What I have to do now is to iterate over this list and call my simple Get routine for each of the four scenarios.</p>
<h4>#1: The non-threaded version</h4>
<p>The simple version is the one without any threading at all. We do need this one to baseline our tests so we can do a comparison with the threaded counterparts. The only thing we need to do is read all the urls and the code pretty much resembles the pseudo code shown previously:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> GetSequential<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> url <span style="color: #0600FF;">in</span> UrlList<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Get<span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h4>#2: The 2.0 ThreadPool version</h4>
<p>Actually I didn’t want to make the ThreadPool version because as said earlier I don’t get this ‘old’ thread programming very well. But as a reference I’ve hacked a version for which I can’t take any liabilities. It is just here for reference purposes. Note that I need two routines to achieve the same goal. Additionally I’ve changed the thread of the main to [MTAThreadAttribute] otherwise you will receive to message:<br />
<img class="aligncenter size-full wp-image-1393" title="PerfSTAError" src="http://lsd.luminis.eu/wp-content/uploads/2011/01/PerfSTAError.png" alt="PerfSTAError" width="456" height="236" /><br />
Anyway the code looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> GetWithThreadPool<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    _ResetEvents <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ManualResetEvent<span style="color: #000000;">&#91;</span>UrlList.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
    Random rand <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span> UrlList.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        _ResetEvents<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ManualResetEvent<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        ThreadPool.<span style="color: #0000FF;">QueueUserWorkItem</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> WaitCallback<span style="color: #000000;">&#40;</span>DoThreadPoolWork<span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span><span style="color: #000000;">&#41;</span>i<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    WaitHandle.<span style="color: #0000FF;">WaitAll</span><span style="color: #000000;">&#40;</span>_ResetEvents<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> DoThreadPoolWork<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> o<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">int</span> index <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#41;</span>o<span style="color: #008000;">;</span>
&nbsp;
    Get<span style="color: #000000;">&#40;</span>UrlList<span style="color: #000000;">&#91;</span>index<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    _ResetEvents<span style="color: #000000;">&#91;</span>index<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Set</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Pretty impressive but incomprehensible, huh?<br />
It doesn&#8217;t feel right that you have to add all these complex things just to get a bit of multi-threading. To me, the only easy part is the Get call somewhere near the end. All the other stuff is thread overhead. And if you would need more that 25 threads this code won’t work. But let’s not dwell on these passed issues and move over to the 4.0 versions.</p>
<h4>#3: The  4.0 TaskFactory version</h4>
<p>The task factory shows what the thread overhead could be if the framework is more powerful than the 2.0 version. Still it is some overhead but the code looks more like the pseudo code than the previous implementation:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> GetWithTaskFactory<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Task<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> tasks <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Task<span style="color: #000000;">&#91;</span>UrlList.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #FF0000;">int</span> counter <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> url <span style="color: #0600FF;">in</span> UrlList<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        var task <span style="color: #008000;">=</span> Task.<span style="color: #0000FF;">Factory</span>.<span style="color: #0000FF;">StartNew</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=&amp;</span>gt<span style="color: #008000;">;</span>
                                 Get<span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span>, TaskCreationOptions.<span style="color: #0000FF;">LongRunning</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        tasks<span style="color: #000000;">&#91;</span>counter<span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> task<span style="color: #008000;">;</span>
        counter<span style="color: #008000;">++;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Task.<span style="color: #0000FF;">WaitAll</span><span style="color: #000000;">&#40;</span>tasks<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The thing I need to do is to create a task for each subject and, with a lambda expression, call my good old private Get() on this task. Finally I just have to wait until all tasks are finished.</p>
<h4>#4: The 4.0 Parallel version</h4>
<p>The ultimate version is left to the end. The new Parallel class makes it possible to write threaded code without almost no (thread) overhead. It looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> GetParallel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Parallel.<span style="color: #0600FF;">ForEach</span><span style="color: #000000;">&#40;</span>UrlList, url <span style="color: #008000;">=&amp;</span>gt<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#123;</span>
            Get<span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Isn’t that just beautiful? It also resembles the pseudo code pretty well. Okay you have to understand the lambda expression with the anonymous delegate syntax and semantics but if you do it is just an ordinary for-loop. As far as I’m concerned: this is as it should be.</p>
<h4>Performance results</h4>
<p>So far the differences in the source code of the four implementations. To start each of the separate scenarios a little bit of timing code is needed to calculate the total of milliseconds the code runs.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #FF0000;">delegate</span> <span style="color: #0600FF;">void</span> GetContentDelegate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">string</span> DoTimedOperation<span style="color: #000000;">&#40;</span>GetContentDelegate getForumContentDelegate<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    DateTime start <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">// perform the actual operation</span>
    getForumContentDelegate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    DateTime end <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
    TimeSpan elapsed <span style="color: #008000;">=</span> end <span style="color: #008000;">-</span> start<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">return</span> elapsed.<span style="color: #0000FF;">TotalMilliseconds</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;ms&quot;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And with the aid of a delegate the timing function is called four times as in:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> StartSequential_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">lblSequentialTime</span>.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span>
        DoTimedOperation<span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> GetContentDelegate<span style="color: #000000;">&#40;</span>WebContent.<span style="color: #0000FF;">GetSequential</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> StartThreadPool_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">lblThreadPoolTime</span>.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span>
        DoTimedOperation<span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> GetContentDelegate<span style="color: #000000;">&#40;</span>WebContent.<span style="color: #0000FF;">GetWithThreadPool</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> StartTaskFactoryl_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">lblTaskFactoryTime</span>.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span>
        DoTimedOperation<span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> GetContentDelegate<span style="color: #000000;">&#40;</span>WebContent.<span style="color: #0000FF;">GetWithTaskFactory</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> StartParallel_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">lblParallelTime</span>.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span>
        DoTimedOperation<span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> GetContentDelegate<span style="color: #000000;">&#40;</span>WebContent.<span style="color: #0000FF;">GetParallel</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>I ran a few tests on my machine and one of them resulted in the following numbers: (By the way my machine is a Macbook Pro running Windows 7 in a Virtual Box with 1 processor and 2048 Mb memory.)<br />
<img class="aligncenter size-full wp-image-1394" title="PerfResults" src="http://lsd.luminis.eu/wp-content/uploads/2011/01/PerfResults.png" alt="PerfResults" width="284" height="217" /><br />
Of course you have to try this on your own machine but it is safe to say that the performance increase is worth the overhead in thread programming.</p>
<p>I have analyzed the thread behavior with the Performance Monitor (PerfMon). In the analysis I was interested in:<br />
-      # of processor threads (blue)<br />
-      # of logical threads for the process (green)<br />
-      # of physical threads for the process (red)<br />
These are the results of one test I have run:<br />
<img class="aligncenter size-full wp-image-1396" title="Dia1" src="http://lsd.luminis.eu/wp-content/uploads/2011/01/Dia1.jpg" alt="Dia1" width="720" height="434" /><br />
You can see the framework too needs some threads when the non threaded version is started. When the threadpool scenario starts you clearly see the increase in threads. The threadpool is managed by .Net so this amount doesn&#8217;t decrease when the scenario is finished. This does happen with the third scenario. Here the threads are in control of the routine and you can clearly see that the threads are released (at least to the system, the framework has a different view on it). In the fourth scenario again the threads are fully controlled by the framework.<br />
Interesting to see is: in both the threadpool and the parallel scenario only a limited amount of threads are created (approximately 5 or 6) while in the Taskfactory 12 threads are created (for each subject one). It is hard to say what exactly happens behind the scenes. Do all logical threads have a physical thread associated? And do these threads run &#8217;simultaneously&#8217; or not? I have to say I don&#8217;t know.<br />
Then there is one thing I don&#8217;t understand at all. How is it possible (near the end) that the total number of physical threads of the process is higher than the system amount of physical threads?! If somebody can tell me this I would be very hapy!</p>
<h4>Conclusion</h4>
<p>In a next blog I will extend this little example. So far I have concentrated on threads, starting and synchronizing them to show the performance differences. I have experimental proof it is worth taking an effort to learn more on the new .Net 4.0 threading stuff.<br />
The part that is left out is the handling of the data and the presentation of the results.<br />
This part is described in part 2 and can be found <a href="http://lsd.luminis.eu/threading-made-easy-in-net-4-0-22/">here</a>.</p>
<p>have fun, florisz</p>
<p>Download the zip for the full source code <a href="http://lsd.luminis.eu/wp-content/uploads/2011/01/ThreadingTest.zip">here</a>.</p>
<h4>References</h4>
<p><a href="http://apiwiki.twitter.com/w/page/22554756/Twitter-Search-API-Method:-search">Twitter Search API</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.aspx">MSDN on System.Threading.Tasks</a></p>
<p><a href="http://www.codethinked.com/post/2010/01/25/NET-40-and-SystemThreadingTasks.aspx">.Net 4.0 and System.Threading.Tasks</a></p>
<p><a href="http://www.switchonthecode.com/tutorials/csharp-tutorial-using-the-threadpool">Threadpool example</a></p>
<p><a href="http://www.eggheadcafe.com/tutorials/aspnet/21013a52-fe11-4af8-bf8b-50cfd1a51577/task-parallelism-in-c-40-with-systemthreadingtasks.aspx">Task Parallelism in C# 4.0 with System.Threading.Tasks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/treading-made-ease-in-net-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apachecon NA 2010, some trends</title>
		<link>http://lsd.luminis.eu/apachecon-na-2010-some-trends/</link>
		<comments>http://lsd.luminis.eu/apachecon-na-2010-some-trends/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 11:36:37 +0000</pubDate>
		<dc:creator>Angelo van der Sijpt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1302</guid>
		<description><![CDATA[With Apachecon NA 2010 about a month behind us, I&#8217;d like to share some of the trends I picked up there.
Big Data, the cloud
One of the main trends I noticed is the interest in Big Data (mainly Apache Cassandra) and Big Data processing in various shapes and forms (e.g. Apache Lucene, Apache Hadoop). In relation [...]]]></description>
			<content:encoded><![CDATA[<p>With Apachecon NA 2010 about a month behind us, I&#8217;d like to share some of the trends I picked up there.</p>
<h3>Big Data, the cloud</h3>
<p>One of the main trends I noticed is the interest in Big Data (mainly Apache Cassandra) and Big Data processing in various shapes and forms (e.g. Apache Lucene, Apache Hadoop). In relation to many of these, we find a ring of &#8216;cloudness&#8217;: the products tend to allow distribution and replication of data and functionality.</p>
<p>But it doesn&#8217;t stop there. It&#8217;s no surprise to find cloud-references in talks about Apache Tuscany (including a talk on Building cloud native software, which I regrettably missed), but for instance Tomcat is making its move into cloud territory with <a href="http://wso2.com/cloud/stratos/">Stratos</a>.</p>
<h3>OSGi all around</h3>
<p>Of course I have a vested interest in OSGi, and <a href="http://www.slideshare.net/angelovds/device-deployment/">my talk</a> during the OSGi track on friday shows this. However, apart from in its own track, OSGi and OSGi-based technologies popped up in a number of other tracks. To name a few,</p>
<ul>
<li>Apache Sling is an OSGi based web application platform, and showed up in the Content Technologies track,</li>
<li>Apache Geronimo 3.0 (in the Content Technologies track) is now based on OSGi, and </li>
<li>in the Enterprise Track, a number of sessions were decidated to Apache Aries, which focuses on the OSGi Enterprise specification.</li>
</ul>
<p>It is an interesting development that OSGi is now mainly being referenced in the web- and enterprise spaces, whereas it started out as a specification for embedded devices.</p>
<p>Does this mean that OSGi is really getting traction in the software community? Yes and no. I believe the thing that is <em>really</em> getting traction is the notions of modularity on the one hand, and <a href="http://www.osgi.org/blog/2010/03/services.html">µServices</a> on the other. OSGi is currently the main technology that marries those two notions.</p>
<h3>Business is not a dirty word</h3>
<p>I noticed there were roughly three kinds of talks,</p>
<ul>
<li><em>Community talks</em> are all about how Apache works, and how open source software fits into the world around it,</li>
<li><em>Technology talks</em> focus on some Apache project, or a combination of projects, and go into the technical details, and</li>
<li><em>Industry talks</em> that show how the projects are used in industry.</li>
</ul>
<p>The last kind of talk shows how industry, the &#8216;people with the problem&#8217; use open source technology to run their business. No, I probably don&#8217;t really care about the products and services you deliver, but I am very interested in your case studies in using open source in your daily life.</p>
<p>A few days ago, Slashdot ran a story <a href="http://slashdot.org/story/10/12/05/0441216/Paid-Developers-Power-the-Linux-Kernel">Paid Developers Power the Linux Kernel</a>. In the light of sessions on open source in industry (I counted about half a dozen on this year&#8217;s schedule), this is not that surprising: if you&#8217;re a good enough developer to become a committer in an open source project, it&#8217;s very unlikely you&#8217;re working as a janitor during the daytime. All of us work for a corporation in some way, and many of us work on open source project during our paid time. I believe this is a good thing!</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/apachecon-na-2010-some-trends/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MetaEdit+ 4.5 Review</title>
		<link>http://lsd.luminis.eu/metaedit-4-5-review/</link>
		<comments>http://lsd.luminis.eu/metaedit-4-5-review/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 16:11:08 +0000</pubDate>
		<dc:creator>Andriy Levytskyy</dc:creator>
				<category><![CDATA[MDD]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code generator]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[DSM]]></category>
		<category><![CDATA[GOPPRR]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[MDE]]></category>
		<category><![CDATA[MERL]]></category>
		<category><![CDATA[MetaEdit+]]></category>
		<category><![CDATA[metamodel]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[workbench]]></category>

		<guid isPermaLink="false">http://lsd.luminis.eu/?p=1277</guid>
		<description><![CDATA[MetaEdit+ DSM Environment by company MetaCase is a commercial language workbench that in contrast to inflexible CASE tools, enables users to build their own modeling and code generation tools (aka DSM tools). It comes in two main product components:

MetaEdit+ Modeler provides customizable DSM functionality for multiple users, multiple projects, running on all major platforms.
MetaEdit+ Workbench [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1300" title="MetaEdit+" src="http://lsd.luminis.eu/wp-content/uploads/2010/12/metaedit-250x511.png" alt="MetaEdit+" width="255" height="56" />MetaEdit+ DSM Environment by company <a href="http://www.metacase.com" target="_blank">MetaCase</a> is a commercial language workbench that in contrast to inflexible CASE tools, enables users to build their own modeling and code generation tools (aka DSM tools). It comes in two main product components:</p>
<ul>
<li>MetaEdit+ Modeler provides customizable DSM functionality for multiple users, multiple projects, running on all major platforms.</li>
<li>MetaEdit+ Workbench i) allows building custom modeling languages (DSLs), and text generators and 2) includes the functionality of MetaEdit+ Modeler and MetaEdit+ API (the latter is not reviewed in this document).</li>
</ul>
<p>This review is written from the MDE perspective and will cover major MDE functionally related to specification of modeling languages. For a complete picture of MetaEdit+, readers are advised to consider other aspects (e.g. collaboration, versioning, etc&#8230;) as well.</p>
<p>This review covers MetaEdit+ Workbench version 4.5.</p>
<h3>Language Specification</h3>
<p><img class="alignright size-medium wp-image-1295" title="A" src="http://lsd.luminis.eu/wp-content/uploads/2010/12/A-300x282.png" alt="A" width="180" height="169" />MetaEdit+ supports graph-like visual languages represented as diagrams, matrixes or tables. There is a limited support for spatial languages: touch and containment relationships are derived from canvas coordinates of modeling elements. There is no actual tool support to preserve these relationships: for example, as a modeller moves a “container” element, contained elements do not move along as expected, but remain at old coordinates.</p>
<p>In MetaEdit+, languages are specified with a set of specialized tools. In the following, we describe the tools per each aspect of the visual language definition: abstract syntax, concrete syntax, static and dynamic semantics.</p>
<h4>Abstract Syntax</h4>
<p>This aspect is defined with GOPPRR metatypes. GOPPRR is an acronym for metatypes Graph, Object, Property, Port, Role and Relationship. For each metatype, there is a form-based tool, e.g. Object tool allows specification of object types  and Graph tool allows assembling types produced with the other tools into a specification of abstract syntax. GOPPRR tools support single inheritance.</p>
<p>Graph tool also allows linking DSL objects to graphs of other DSLs through decomposition and explosion structures. Furthermore, through sharing language concepts (of any OPPRR metatype) among graphs, DSLs can be integrated so that changes in one model can be automatically reflected in models based on different languages.</p>
<p>An alternative to these form-based tools for abstract syntax specification is a visual metamodeling DSL. However, this functionality is best used as easy start-up leading to automated generation of barebone GOPPRR metamodels. Once a language developer changes a GOPPRR metamodel (which is inevitable), visual metamodeling is best discontinued to avoid manual round-trip between the two metamodels.</p>
<h4>Concrete Syntax</h4>
<p>By default, MetaEdit+ provides generic symbols. However, language developers are free to specify custom symbols for objects, roles and relationships. These symbols are either defined with a WYSIWYG vector drawing tool or imported from vector graphics (SVG) or bitmap files. Symbols can display text, property values and dynamic outputs produced by text generators (more on generators in section M2T Transformation). Moreover, symbols or their parts can be conditionally displayed. Finally, symbols can be reused among different DSLs via a symbol library.</p>
<p>MetaEdit+ does not directly support multiple concrete syntaxes per language, which (the lack of such support) is still a common practice among language workbenches. However, its capability to display symbols based on conditions allows to work around this limitation.</p>
<h4>Static Semantics</h4>
<p>This aspect covers constraints and business rules. The purpose of these rules is to ensure a consistent and valid model.</p>
<p>In general, DSM tools should verify a model against the static semantics of its DSL at different times. These times can be classified as ‘live’ (i.e. when a user is modelling) and ‘batch’ (i.e. invoked on events caused by actions such as user demand, model saving or transformation). Furthermore, tool actions following violation of a constraint can be classified as prevention (i.e. a violating action is canceled and a warning message is displayed) or merely informative (i.e. a violating action is allowed, but model will display clues about invalid constructions until the effect of the action is corrected).</p>
<p>MetaEdit’s Constraint tool (available from the Graph tool) allows ‘live’ checks against constraints and preventive protection of models (‘live’ and ‘preventive’ in the terms of the above classifications). The tool is very expressive and easy to use, but covers only limited number of types of constraints, namely:</p>
<ul>
<li>object connectivity in a relationship</li>
<li>object occurrence in a model</li>
<li>ports involved in a relationship</li>
<li>property uniqueness</li>
</ul>
<p>More advanced constraints have to rely on MERL generator (see section M2T Transformation), which can inform users about invalid constructions during modeling (‘live’ and ‘informative’ in the terms of the above classifications). MERL generator can also be used for ‘batch informative’ and ‘batch preventive’ checks: a checking report can be run on demand or included as preventive check before any other transformation is carried out.</p>
<h4>Dynamic Semantics</h4>
<p>MetaEdit+ can define dynamic semantics through a process of translating DSL concepts to concepts in another target domain with defined dynamic semantics. Examples of target domains in code generation applications are e.g. C++ or Java. A major benefit of language workbenches is that they are capable of automating this and other useful kinds of processes.</p>
<h3>PROCESS AUTOMATION</h3>
<p>MDE applications need capabilities to automate processes in which models are inputs and outputs. MetaEdit+ provides various levels of support for model-to-model (M2M), model-to-text (M2T) (e.g. in code generation applications) and text-to-model (T2M) (import of legacy code, data type definitions, etc. into models) types of transformations. (The latter transformation type is not reviewed.)</p>
<h4>M2T Transformation</h4>
<p>Text (and more specifically code) generation is accomplished with Generator tool that can efficiently navigate models, filter and access information, and output text into external files, Generator Output tool and DSL symbols.  All these tasks are specified with imperative language MERL. While MERL is very concise and efficient for most of these tasks, I think that navigation and access tasks are better accomplished in a declarative way.</p>
<p>MERL generators are defined per graph type (i.e. per DSL) and can be acquired from supertypes of a given graph type via an inheritance hierarchy. If a generator has to be used for different graph types, then the generator should be defined for the common parent graph type. On the other hand, DSL developer can define new or redefine generators already provided by parent graph types.</p>
<p>Finally, MERL provides support for modularization by allowing includes of generators in other generators. Making modular generators pays off well, as there are many reuse opportunities in MetaEdit+: generators can be reused not only for text generation but also in concrete syntax (symbols) and validation/reporting purposes (symbols, generator output tool).</p>
<h4>M2M Transformation</h4>
<p>Models can be transformed 1) programmatically via the SOAP and WebServices-based API of MetaEdit+ (this option requires product component MetaEdit+ API) or 2) through code generation of an intermediate external representation (in the XML format) and consequent import thereof as new model.</p>
<p>These two options amount to a generic support at a minimum level that is commonly provided nearly by all language workbenches. Moreover, code generation of an intermediate representation cannot implement in-place M2M transformations, of which application examples are: model optimization, model layout, <a href="http://lsd.luminis.eu/model-interpretation-for-weighbridge-domain/" target="_blank">model interpretation</a>, model weaving and any repeatable model manipulation in general.</p>
<h3>OTHER</h3>
<ul>
<li>DSL evolution: MetaEdit+ updates existing models instantly yet non-destructively to reflect changes in DSLs.  The update policy ensures that models created with the older DSL versions are not broken and remain usable with existing generators. Instant update is also very useful when fine-tuning a DSL with end users.</li>
<li>According to MetaCase, a MetaEdit+ project can hold over 4 billion objects. A typical project would contain about 40-100 models (graphs).</li>
<li>In the multi-user version, users can simultaneously access and share all models within a Repository. Locking is made at the object-level, so several users could collaboratively work on the same model at the same time.</li>
<li>Multi-user collaboration in MetaEdit+, product line analysis of commonality and variability and proper separation of concerns reduce the need for version control as it is known in software engineering. Therefore MetaEdit+ does not provide its own versioning system. Best practices for versioning with MetaEdit+ can be found <a href="http://www.metacase.com/support/45/documentation/versioning.html" target="_blank">here</a>.</li>
<li>Model interoperability: by default, all models and DSLs can be exported in an XML format. The schemas are very simple, which make it easy to post-process such files if needed. Moreover, the M2T transformation capabilities of MetaEdit+ enable DSL developers to easily create custom export generators.</li>
</ul>
<h3>CONCLUSION</h3>
<p>MetaEdit+ is a versatile language workbench that enables building high quality visual DSLs for any kind of domain, be it technical or business. Another key quality of MetaEdit+ is efficient DSL/GOPPRR tools, which allow light-weight, agile and fast DSL development and evolution. A testament to this quality is the fact that MetaCase is one of few language workbench makers that routinely designs and builds DSLs in improvisation with audience at conferences, workshops, etc. In my opinion, this impressive productivity is possible because GOPPRR tools are based on paradigms that are optimum for DSL development (DSM for DSM so to speak).</p>
<p>Highlights of MetaEdit+ are:</p>
<ul>
<li>Proper level of abstraction: DSL developers are completely shielded from details of how DSM-tools are implemented. DSL development tools focus on essential abstractions for specification of languages and generators.</li>
<li>High-levels of automation: DSM-tools are completely and automatically generated from abstract language specifications.</li>
<li>High quality of tools: each DSL development task has its own dedicated tool.</li>
<li>Numerous enhancements: high integration of tools, non-destructive evolution of languages, inheritance mechanism, reuse opportunities for types, symbols and generators, visual metamodeling, etc.</li>
<li>Very cheap <a href="http://www.metacase.com/introductory_license.html" target="_blank">introductory license</a>.</li>
</ul>
<p>Naturally, there are a few drawbacks as well:</p>
<ul>
<li>No specific support for model-to-model transformation.</li>
<li>Somewhat limited constraints support.</li>
<li>Limited support for spatial relations.</li>
<li>Uncommon user interface.</li>
<li>Form-based GOPPRR tools prevent a global overview of a metamodel.</li>
<li>Expensive  standard licenses.</li>
</ul>
<p>Code generation applications are the oldest tradition in MDE and this is where MetaEdit+ excels. As MDE discovers new applications, my experience is that the code generation specialization becomes restrictive. Admittedly, it is possible to implement some types of M2M transformations with code generation (via intermediate representation). However, the problem with this workaround is that it introduces accidental complexity both to MDE developers and more importantly to end users (that have to keep repeating the generate/import routine, sometimes complicated by model merge).</p>
<p>That said, in my opinion MetaEdit+ gets the big things right. Whether its shortcomings are little things is a subjective matter that is best evaluated in the context of a concrete problem domain.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/metaedit-4-5-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kantoorslang</title>
		<link>http://lsd.luminis.eu/kantoorslang/</link>
		<comments>http://lsd.luminis.eu/kantoorslang/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 09:20:14 +0000</pubDate>
		<dc:creator>Robert Zwerus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[social]]></category>
		<category><![CDATA[jargon]]></category>
		<category><![CDATA[kantoor]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[slang]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=1191</guid>
		<description><![CDATA[
De laatste tijd heb ik een lijstje gemaakt met uitspraken die volgens mij vrijwel nooit buiten kantoormuren geuit worden:

doorakkeren
inschieten
oppakken
opschalen
verwachting neerleggen
doorpakken
aanvliegen
ergens een ei over leggen
issue ergens beleggen
ergens op acteren
iets platslaan
aan de pruttel helpen
de hele spullenboel
doorsnijding
propositie

Wie heeft leuke toevoegingen?
]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://upload.wikimedia.org/wikipedia/commons/8/8c/Office_1719.jpg" alt="Office 1719" width="300" height="395" /></p>
<p>De laatste tijd heb ik een lijstje gemaakt met uitspraken die volgens mij vrijwel nooit buiten kantoormuren geuit worden:</p>
<ul>
<li>doorakkeren</li>
<li>inschieten</li>
<li>oppakken</li>
<li>opschalen</li>
<li>verwachting neerleggen</li>
<li>doorpakken</li>
<li>aanvliegen</li>
<li>ergens een ei over leggen</li>
<li>issue ergens beleggen</li>
<li>ergens op acteren</li>
<li>iets platslaan</li>
<li>aan de pruttel helpen</li>
<li>de hele spullenboel</li>
<li>doorsnijding</li>
<li>propositie</li>
</ul>
<p>Wie heeft leuke toevoegingen?</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/kantoorslang/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PhoneGap, een alternatief voor native mobiele applicaties</title>
		<link>http://lsd.luminis.eu/phonegap/</link>
		<comments>http://lsd.luminis.eu/phonegap/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 06:55:32 +0000</pubDate>
		<dc:creator>Erik Sanders</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[mobility]]></category>
		<category><![CDATA[Google Android]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=1005</guid>
		<description><![CDATA[PhoneGap, een alternatief voor native mobiele applicaties
PhoneGap is een interessante open source alternatief voor het schrijven van native applicaties voor elk (mobiel) platform dat er is. In het kort komt het erop neer dat PhoneGap zorgt dat je een HTML applicatie met javascript.  De specifiek API, zoals location, contact, e.d. worden afgeschermd door een standaard API [...]]]></description>
			<content:encoded><![CDATA[<h1>PhoneGap, een alternatief voor native mobiele applicaties</h1>
<p>PhoneGap is een interessante open source alternatief voor het schrijven van native applicaties voor elk (mobiel) platform dat er is. In het kort komt het erop neer dat PhoneGap zorgt dat je een HTML applicatie met javascript.  De specifiek API, zoals location, contact, e.d. worden afgeschermd door een standaard API van PhoneGap.</p>
<h3>iPhone</h3>
<p><span style="font-size: 13.3333px;">Voor de iPhone kan de HTML applicatie gewoon worden aangeboden via de appstore. Dit is dan ook direct de truc waardoor er voldoende rechten zijn om de hardware aan te spreken. Er zijn al vele applicatie geplaatst in de appstore (zie een selectie in<a href="http://www.phonegap.com/apps" target="_blank"> www.phonegap.com/apps</a>).  Er is tevens een <a href="http://phonegap.pbworks.com/Getting-Started-with-PhoneGap-(iPhone)" target="_blank">getting started</a> en er zijn  extra <a href="http://github.com/purplecabbage/PhoneGap-Plugins">plugins</a> beschikbaar</span></p>
<h3>Ondersteunde platformen</h3>
<p>Naast iPhone wordt zowel Android, Blackberry, Symbian, Palm, N900 en Windows Mobile. Ook Windows Mobile 7 is zodra dit uitkomt eenvoudig te ondersteunen en ze zullen ook geen blokkade opwerpen in het voordeel van silverlight. Interesante gedachte is natuurlijk ook de iets minder mobiele system met Linux, Windows MacOS hebben ook allemaal een browser.</p>
<table style="float:lefts" border="0" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td></td>
<td>IPHONE</td>
<td>ANDROID</td>
<td>BLACKBERRY</td>
<td>SYMBIAN</td>
<td>PALM</td>
</tr>
<tr>
<td>GEO   LOCATION</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
</tr>
<tr>
<td>VIBRATION</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
</tr>
<tr>
<td>ACCELEROMETER</td>
<td>√</td>
<td>√</td>
<td>OS 4.7</td>
<td>√</td>
<td>√</td>
</tr>
<tr>
<td>SOUND</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
</tr>
<tr>
<td>CONTACT   SUPPORT</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>√</td>
<td>N/A</td>
</tr>
</tbody>
</table>
<p>Voor meer informatie zie <a href="http://www.phonegap.com" target="_blank">www.phonegap.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.eu/phonegap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
