<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2550930328775670949</id><updated>2011-12-05T15:44:35.811+01:00</updated><category term='MDA'/><category term='performance'/><category term='hashmap'/><category term='Model Driven'/><category term='MDSD'/><category term='memory'/><category term='java'/><category term='Software Architecture'/><category term='DSL'/><category term='Refactoring'/><title type='text'>actifsource</title><subtitle type='html'>actifsource is your model-driven code generator that tightly integrates into the popular Eclipse IDE.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-5228871430987322606</id><published>2010-08-25T17:18:00.010+02:00</published><updated>2010-09-17T13:14:33.082+02:00</updated><title type='text'>BinaryTrees For Rescue</title><content type='html'>When ArrayLists become big reverse lookups like indexOf, lastIndexOf, contains and the modifications methods can slow down your program. When order is not important, you might use a HashMap. In some other cases you have a constant key-value, that can be use in a TreeMap. If you need to have to update the index however there is no real alternative. What I'm missing in the java collections is a balanced tree, allowing me to traverse it's structure. The NavigableSet-Interface available since Java 6 only allows to traverse the elements. There are no methods to access the tree-structure. I wonder why the tree used in TreeMap wasn't made available in a separate Red-Black-Tree class.&lt;br /&gt;&lt;br /&gt;As mentioned before trees can be very useful when search through big datasets. Imagine you have a texteditor with more than 10000 lines of text and you need a mapping from lineNumber to line and line to lineNumber. One possibility is to put all lines as keys in a map and use the index as a value, but than you have to update the map every time, you insert a new line. Using a tree, you can insert the lines at a certain position and put the treenode instead of the index into the map. Now you can lookup up the treenode for a line. Calculating the index of a treenode is not difficult:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/THZ635by9tI/AAAAAAAAAH0/ZfBFuhR4_OM/s1600/IndexTree.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 160px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/THZ635by9tI/AAAAAAAAAH0/ZfBFuhR4_OM/s320/IndexTree.png" alt="" id="BLOGGER_PHOTO_ID_5509726294863181522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To speed up the calculation you can cache the node-count of each subtree in the corresponding rootnode and only recalculate it, when a subtree node changes. This way a lookup of a treenode by it's current index or calculating the a treenode index should be very fast enough. &lt;br /&gt;&lt;br /&gt;The calculation of the index can be easy adapted to similar cases. For example if you have a texteditor supporting different line heights, calculating the y-Offset of a single line is expensive. Calculating the y-offset of a line requires to sum up all height of the previous lines. Having all lines in an Arraylist means to iterate through the hole list beginning from the first line. You may think about caching the line-offset in a treemap, but than you have to clear all entries after the modified line. In worst case if the first line changes, the while cache is invalid. With a tree, you can store the sum of heights in the treenodes. If the height of one line changes, you only have to recalculate the value of parent nodes. Caluating the y-Offset is now much cheaper, just sum up the height of the lines in all left-children and the height of the line stored in the node, when following a right-child. The only difference to the index calculation is that, that a treenode adds the height instead of the constant node count 1 when including it's own value.&lt;br /&gt;&lt;br /&gt;Comparing the speed of an arraylist with the speed of the tree, isn't an easy task. There are many things to consider:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;a) &lt;/strong&gt;if the dataset is rarely modified and the dataset isn't to big, a map can be used to improve the reverse lookup&lt;br /&gt;&lt;strong&gt;b) &lt;/strong&gt;the speed for an indexOf/lastIndexOf/contains lookup an the arraylist strongly depends on the speed of the equals and hashcode method. For example for integers this is very fast.&lt;br /&gt;&lt;strong&gt;c) &lt;/strong&gt;the number of different elements, if you have only 10 different elements in the list and they are random, the results of indexOf/lastIndexOf/contains will need much less comparisons&lt;br /&gt;&lt;strong&gt;d) &lt;/strong&gt;a tree needs more memory&lt;br /&gt;&lt;strong&gt;e) &lt;/strong&gt;for looking up an element by an index there is nothing faster than an array and same applies for creating complete copies it.&lt;br /&gt;&lt;br /&gt;I think the main reason for not including a balanced binary tree in the java collection as a separate class, is that the arraylist in most cases is fast enough. Wether to use a tree, hashmap, arraylist or linkedlist dependends on what you want to do. There is no golden hammer, that solves all your problems.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-5228871430987322606?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/5228871430987322606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/08/binarytrees-for-rescue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5228871430987322606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5228871430987322606'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/08/binarytrees-for-rescue.html' title='BinaryTrees For Rescue'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_NyhaJypG-ZA/THZ635by9tI/AAAAAAAAAH0/ZfBFuhR4_OM/s72-c/IndexTree.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-1294761686310611690</id><published>2010-08-08T16:12:00.010+02:00</published><updated>2010-08-08T17:01:37.948+02:00</updated><title type='text'>DCI and actifsource</title><content type='html'>In my last post I introduced the modified DCI meta model. Let's have a look at a simple example.&lt;br /&gt;&lt;br /&gt;The use case we would like to implement is to transfer money from a money source to a money sink. MoneySource and MoneySink are specific roles, played by an appropriate bank account.&lt;br /&gt;&lt;br /&gt;The example is built up on the following entities:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TF682c7hMrI/AAAAAAAAAFI/3yBX66YZfO4/s1600/DCI_Entities.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 333px; height: 328px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TF682c7hMrI/AAAAAAAAAFI/3yBX66YZfO4/s400/DCI_Entities.png" alt="" id="BLOGGER_PHOTO_ID_5503043438358114994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UseCase: TransferMoney&lt;/span&gt;&lt;br /&gt;From a users point of view the use case is the most important artifact in the code. That's because the use case contains business relevant code.&lt;br /&gt;&lt;br /&gt;The following UseCase shall transfer money from a MoneySource to a MoneySink. Furthermore the amount of money shall be passed to the use case as an argument.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TF6-HbWvqyI/AAAAAAAAAFQ/VokZlR2LfP4/s1600/DCI_UseCase_TransferMoney.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 270px; height: 206px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TF6-HbWvqyI/AAAAAAAAAFQ/VokZlR2LfP4/s400/DCI_UseCase_TransferMoney.png" alt="" id="BLOGGER_PHOTO_ID_5503044829504842530" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Role: MoneySource and MoneySink&lt;/span&gt;&lt;br /&gt;Let's have a closer look at the roles needed. The MoneySource has an interaction balance() to ask for the current balance. Furthermore the role supports withdraw() to withdraw an amount.&lt;br /&gt;&lt;br /&gt;Note that we specify that this role might be played by an InvestmentAccount or a SavingsAccount.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TF7AhE3o0AI/AAAAAAAAAFo/fmMXqJit-lA/s1600/DCI_Role_MoneySource.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 396px; height: 384px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TF7AhE3o0AI/AAAAAAAAAFo/fmMXqJit-lA/s400/DCI_Role_MoneySource.png" alt="" id="BLOGGER_PHOTO_ID_5503047469168644098" border="0" /&gt;&lt;/a&gt;MoneySink on the other hand side supports the interaction deposit() to deposit an amount.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TF6_Dmr6oFI/AAAAAAAAAFg/5rnhVpj35gw/s1600/DCI_Role_MoneySink.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 378px; height: 262px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TF6_Dmr6oFI/AAAAAAAAAFg/5rnhVpj35gw/s400/DCI_Role_MoneySink.png" alt="" id="BLOGGER_PHOTO_ID_5503045863338582098" border="0" /&gt;&lt;/a&gt;Note that this role might be played only by the SavingsAccount.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Data: InvestmentAccount and SavingsAccount&lt;/span&gt;&lt;br /&gt;The InvestmentAccount shall have a Balance member to store the actual  balance. Furthermore the method withdraw() supports withdrawal. Therefore it might play the MoneySource role.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/TF7CHbCAkdI/AAAAAAAAAFw/k7SZHmC2m4o/s1600/DCI_Data_InvestmentAccount.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 365px; height: 299px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/TF7CHbCAkdI/AAAAAAAAAFw/k7SZHmC2m4o/s400/DCI_Data_InvestmentAccount.png" alt="" id="BLOGGER_PHOTO_ID_5503049227464380882" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The SavingsAccount supports withdrawal and deposit. Therefore it might play the MoneySink or MoneySource role.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TF7CI42N8mI/AAAAAAAAAF4/O6QDHXk2ILA/s1600/DCI_Data_SavingsAccount.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 347px; height: 400px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TF7CI42N8mI/AAAAAAAAAF4/O6QDHXk2ILA/s400/DCI_Data_SavingsAccount.png" alt="" id="BLOGGER_PHOTO_ID_5503049252647858786" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Context: TransferMoneyContext&lt;/span&gt;&lt;br /&gt;The context now puts it all together. Every context has to specify exactly one UseCase. In the following example we choose the TransferMoney UseCase.&lt;br /&gt;&lt;br /&gt;Since the UseCase TransferMoney declares the usage of the Roles  MoneySource and MoneySink actifsource asks us to provide the data which  can play the roles.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/TF7Efn3hXJI/AAAAAAAAAGI/W9-5ekcvSOE/s1600/DCI_Context_TransferMoneyContext_1.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 358px; height: 150px;" src="http://4.bp.blogspot.com/_txlKc91hcCk/TF7Efn3hXJI/AAAAAAAAAGI/W9-5ekcvSOE/s400/DCI_Context_TransferMoneyContext_1.png" alt="" id="BLOGGER_PHOTO_ID_5503051842250169490" border="0" /&gt;&lt;/a&gt;Using content assist to selected the data object for the MoneySource role we can choose between the InvestmentAccount and the SavingsAccount. As we have seen before both accounts have a withdraw member and are therefore able to play the MoneySource role. For this example lets choose the InvestmentAccount.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TF7Ef9wZyII/AAAAAAAAAGQ/kkK1CYoNP6w/s1600/DCI_Context_TransferMoneyContext_2.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 144px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TF7Ef9wZyII/AAAAAAAAAGQ/kkK1CYoNP6w/s400/DCI_Context_TransferMoneyContext_2.png" alt="" id="BLOGGER_PHOTO_ID_5503051848125892738" border="0" /&gt;&lt;/a&gt;Last but not least we have to specify the data for the MoneySink role. Using content assist on the data field only allows the SavingsAccount. Thats because only the SavingsAccount allows to deposit an amount.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TF7EgRcJQFI/AAAAAAAAAGY/nGHt9E5aj6w/s1600/DCI_Context_TransferMoneyContext_3.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 176px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TF7EgRcJQFI/AAAAAAAAAGY/nGHt9E5aj6w/s400/DCI_Context_TransferMoneyContext_3.png" alt="" id="BLOGGER_PHOTO_ID_5503051853409632338" border="0" /&gt;&lt;/a&gt;The TransferMoneyContext has been declared for the UseCase TransferMoney. Since TransferMoney stated to work with the Roles MoneySource and MoneySink we have to provide Data which can play this roles.&lt;br /&gt;&lt;br /&gt;Thanks to the strong actifsource type system it becomes possible that the content assist allows only Data which can play the role needed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TF7DW1KnWWI/AAAAAAAAAGA/sI2_4MiOlts/s1600/DCI_Context_TransferMoneyContext.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 251px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TF7DW1KnWWI/AAAAAAAAAGA/sI2_4MiOlts/s400/DCI_Context_TransferMoneyContext.png" alt="" id="BLOGGER_PHOTO_ID_5503050591689464162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/TF7CHbCAkdI/AAAAAAAAAFw/k7SZHmC2m4o/s1600/DCI_Data_InvestmentAccount.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-1294761686310611690?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/1294761686310611690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/08/dci-and-actifsource.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/1294761686310611690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/1294761686310611690'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/08/dci-and-actifsource.html' title='DCI and actifsource'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_txlKc91hcCk/TF682c7hMrI/AAAAAAAAAFI/3yBX66YZfO4/s72-c/DCI_Entities.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-5743045325356739430</id><published>2010-08-08T15:44:00.004+02:00</published><updated>2010-08-08T16:01:36.970+02:00</updated><title type='text'>The DCI Meta Model</title><content type='html'>In my previous blog I promised to work out a meta model to realize the DCI architecture. As explained before I've made a slight modification: a UseCase is modeled as its own entity.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TF61oD-uR2I/AAAAAAAAAFA/VLpfaoKYu6A/s1600/DCI_MetaModel.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 370px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TF61oD-uR2I/AAAAAAAAAFA/VLpfaoKYu6A/s400/DCI_MetaModel.png" alt="" id="BLOGGER_PHOTO_ID_5503035494561105762" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;UseCase&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;A UseCase is business relevant code which needs different actors (data objects playing roles) to work on.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Context&lt;/span&gt;&lt;br /&gt;The context manages the UseCase an the data objects which are able to play the roles needed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Role&lt;/span&gt;&lt;br /&gt;A role is an interface which can have 1..N interaction (an interaction is realized as an abstract method on the role interface).&lt;br /&gt;&lt;br /&gt;Every role might be realized for any suitable data object. A role realization for a specific data object is called Adapter.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;RoleData&lt;/span&gt;&lt;br /&gt;Setting up a context it must be determined which data object plays the roles needed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Data&lt;/span&gt;&lt;br /&gt;Data objects contain members and method. Members are simple data fields an result in an appropriate getter function. The method can be freely chosen and realize a more sophisticated access to the members.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-5743045325356739430?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/5743045325356739430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/08/dci-meta-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5743045325356739430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5743045325356739430'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/08/dci-meta-model.html' title='The DCI Meta Model'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_txlKc91hcCk/TF61oD-uR2I/AAAAAAAAAFA/VLpfaoKYu6A/s72-c/DCI_MetaModel.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-4880266285674546711</id><published>2010-08-08T15:21:00.003+02:00</published><updated>2010-08-08T15:43:25.405+02:00</updated><title type='text'>The DCI Architecture</title><content type='html'>In his new book "Lean Architecture: for Agile Software Development" James O. Coplien shows up with a new programming paradigm: The DCI Architecture.&lt;br /&gt;&lt;br /&gt;Before reading this blog I suggest to have a look a the DCI vision document:&lt;br /&gt;&lt;a href="http://www.artima.com/articles/dci_vision.html"&gt;http://www.artima.com/articles/dci_vision.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Let me try to explain DCI in a nutshell.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote&gt;The idea of DCI is to separate data from business code for better readability while the business code is directly expressed as use case.&lt;br /&gt;&lt;/blockquote&gt;DCI stands for Data, Context and Interaction.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Data&lt;/span&gt;&lt;br /&gt;Data means POD (plain old data) objects without any business relevant methods.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Context&lt;/span&gt;&lt;br /&gt;A context is a place to retrieve and/or setup a necessary data.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Interaction&lt;/span&gt;&lt;br /&gt;An interaction is a complex function applied on the data of the context.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementing DCI&lt;/span&gt;&lt;br /&gt;Implementing DCI is not an easy task since traits are needed. Coplien shows a C++ implementation using template traits as known from the STL. Nevertheless the DCI architecture asks for tool support.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The modified DCI Architecture&lt;/span&gt;&lt;br /&gt;My goal is to realize the DCI architecture using actifsource. Therefore an appropriate meta-model is needed.&lt;br /&gt;&lt;br /&gt;I decided to keep the DCI idea but modify the model a little bit.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TF6xq1pBvSI/AAAAAAAAAE4/N-fnCNd4RRs/s1600/DCI_MetaModel_Modified.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 256px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TF6xq1pBvSI/AAAAAAAAAE4/N-fnCNd4RRs/s400/DCI_MetaModel_Modified.png" alt="" id="BLOGGER_PHOTO_ID_5503031144205106466" border="0" /&gt;&lt;/a&gt;My idea: a UseCase needs 1..N actors (Role) to be implemented. Every role is realized on a POD (plain old data) object.&lt;br /&gt;&lt;br /&gt;A context is needed to setup a UseCase and all Data objects which can play the roles needed.&lt;br /&gt;&lt;br /&gt;Since a role can be played by any suitable data it seems quite natural that we have to provide kind of an adapter for every Role/Data relationship.&lt;br /&gt;&lt;br /&gt;Because I'd like to realize DCI with the actifsource code generator setting up the adapters is no big deal. Instead of hand coding adapters are generated as needed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-4880266285674546711?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/4880266285674546711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/08/dci-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4880266285674546711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4880266285674546711'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/08/dci-architecture.html' title='The DCI Architecture'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_txlKc91hcCk/TF6xq1pBvSI/AAAAAAAAAE4/N-fnCNd4RRs/s72-c/DCI_MetaModel_Modified.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-4904697438329138646</id><published>2010-07-19T15:41:00.013+02:00</published><updated>2010-07-19T17:21:20.672+02:00</updated><title type='text'>Advanced usage of Visitor-Pattern</title><content type='html'>Have you ever used the Visitor Pattern to resolve the specific type of a collection of objects? What you usually do is defining a common interface and add an accept()-method taking the visitor interface and in the implementation invoke the visit()-method from the visitor.&lt;br /&gt;&lt;br /&gt;Here is an example for following hierarchy&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERokTF5sKI/AAAAAAAAAHs/p9LS2BpvCHM/s1600/Hierarchy.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 181px; height: 133px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERokTF5sKI/AAAAAAAAAHs/p9LS2BpvCHM/s320/Hierarchy.png" alt="" id="BLOGGER_PHOTO_ID_5495632418108453026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The INodeElement might look like this:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERZsSCFP-I/AAAAAAAAAGs/hGGeDmGIRGY/s1600/INodeElement.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 234px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERZsSCFP-I/AAAAAAAAAGs/hGGeDmGIRGY/s320/INodeElement.png" alt="" id="BLOGGER_PHOTO_ID_5495616062588534754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and the IHeadElement linke this&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/TERZ5b10TcI/AAAAAAAAAG0/NSibFnieSEE/s1600/IHeadElement.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 78px;" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/TERZ5b10TcI/AAAAAAAAAG0/NSibFnieSEE/s320/IHeadElement.png" alt="" id="BLOGGER_PHOTO_ID_5495616288559746498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Later on, in your implementation code you can use the visitor to lookup the concrete type&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERaP4XXAmI/AAAAAAAAAG8/lCuGNK5G1wk/s1600/HeadElementDemo.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 242px; height: 320px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERaP4XXAmI/AAAAAAAAAG8/lCuGNK5G1wk/s320/HeadElementDemo.png" alt="" id="BLOGGER_PHOTO_ID_5495616674173747810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see there is no typecast needed, so you never get a ClassCastException. However if you look at the example, one major drawback of the visitor pattern is that if the hierarchy is not matching exactly, you have a bunch of empty methods. These methods can lead to confusion and doing nothing or throwing an exception isn't much better than a ClassCastException.&lt;br /&gt;&lt;br /&gt;If you have the control over the source, you can easily introduce a new more specific type in your hierarchy to workaround this.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TERgCeP6W7I/AAAAAAAAAHE/LrwRdrUAN8A/s1600/IHeadElementChild.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 123px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TERgCeP6W7I/AAAAAAAAAHE/LrwRdrUAN8A/s320/IHeadElementChild.png" alt="" id="BLOGGER_PHOTO_ID_5495623040894655410" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now you can tag the child elements (in this case we have only one)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERgN03zM9I/AAAAAAAAAHM/f_cNskRqegY/s1600/ITitleElement_Tagged.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 32px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERgN03zM9I/AAAAAAAAAHM/f_cNskRqegY/s320/ITitleElement_Tagged.png" alt="" id="BLOGGER_PHOTO_ID_5495623235946099666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and the return type of the list can be changed to a more specific one&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/TERgf_MBweI/AAAAAAAAAHU/IDiZ_NnNQt4/s1600/IHeadElement_ChildTagging.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 128px;" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/TERgf_MBweI/AAAAAAAAAHU/IDiZ_NnNQt4/s320/IHeadElement_ChildTagging.png" alt="" id="BLOGGER_PHOTO_ID_5495623547952939490" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Using the new more specific visitor, there are no more unnecessary methods&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERhWrcAamI/AAAAAAAAAHc/TtFtIajTry8/s1600/Demo_ChildVisitor.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 189px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TERhWrcAamI/AAAAAAAAAHc/TtFtIajTry8/s320/Demo_ChildVisitor.png" alt="" id="BLOGGER_PHOTO_ID_5495624487544056418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Problem solved? Yes, if you have the freedom to modify each element for tagging it, when ever you create a child list. Otherwise you should look for a better solution.&lt;br /&gt;&lt;br /&gt;Think a short time about, what you really want to do. You want to restrict the list to adding elements only of specific types and allow to query them later, while making sure that no type is forgotten when the code changes. Another possibility to add a visitor is to wrap the list element. To do so, remove the IHeadElementChild interface and the corresponding accept-method from the ITitelElement. Now add an implemention for the IHeadElementChild interface. Create factory method for each element allow in the childlist.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/TERmMVr8pCI/AAAAAAAAAHk/mXhFLe-nJJ4/s1600/HeadElementChildWrapper.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 195px;" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/TERmMVr8pCI/AAAAAAAAAHk/mXhFLe-nJJ4/s320/HeadElementChildWrapper.png" alt="" id="BLOGGER_PHOTO_ID_5495629807464784930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the implementation of the IHeadElement always add the wrapper to the list, everything else can be left as it is. Now you are completely independent of the class hierarchy. Note that this solution will also work with classes provided by foreign frameworks.&lt;br /&gt;&lt;br /&gt;If you already used actifsource to describe and generate your class hierarchy, you can leave the whole work to the generator and gain the advantage of more type-safety and less casts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-4904697438329138646?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/4904697438329138646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/07/advanced-usage-of-visitor-pattern.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4904697438329138646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4904697438329138646'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/07/advanced-usage-of-visitor-pattern.html' title='Advanced usage of Visitor-Pattern'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_NyhaJypG-ZA/TERokTF5sKI/AAAAAAAAAHs/p9LS2BpvCHM/s72-c/Hierarchy.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-4849845571415360902</id><published>2010-07-05T10:56:00.011+02:00</published><updated>2010-07-08T17:03:47.303+02:00</updated><title type='text'>Modeling Software Architecture</title><content type='html'>In my last blog &lt;a href="http://actifsource.blogspot.com/2010/07/on-semantics-of-explicit-dependency.html"&gt;On the semantics of explicit dependency relations&lt;/a&gt; I explained the concept of &lt;span style="font-style: italic;"&gt;explicit dependency relations&lt;/span&gt; between domain-specific components. The big advantage shows up when modeling on an architectural level.&lt;br /&gt;&lt;br /&gt;A complex system is divided in layers/tiers and packages to manage code artifacts. This technical architecture provides an overview on the implementation.&lt;br /&gt;&lt;br /&gt;On the other hand we find the business architecture where packages, areas, functionality, epics, etc. are used to structure domain objects.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;On the semantics of projects and packages&lt;/span&gt;&lt;br /&gt;Both the technical and the business architecture have one thing in common: they are structured not only with packages but also with projects. Modern IDE's as Eclipse, MS Visual Studio or InteliJ's Idea animate developers to separate different concerns in different projects.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;All artifacts of a software system are structured using projects and packages.&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;But architecture lays above projects. Architecture describes how a system is divided into projects. This fact leads to the problem, that architecture can never be described by its projects alone.&lt;br /&gt;&lt;br /&gt;It seems that describing architecture needs kind of an &lt;span style="font-style: italic;"&gt;Über-Project&lt;/span&gt; which contains the overview how projects are interrelated. This overview shows packages and their dependencies as shown in my blog before.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;There has to be an overview how projects are interrelated. This overview is the most important artifact to understand the technical architecture or business architecture.&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;The tricky thing: The overview provides an entry point whereat the details are managed in the projects. But nevertheless this architectural project should contain all the information to get a complete overview. This includes also detail information contained in the particular projects.&lt;br /&gt;&lt;br /&gt;Let's assume that all green packages are modeled in the architecture overview while the red packages are realized as projects.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/TDGoTBrAYOI/AAAAAAAAAEw/bxeGPWT8rms/s1600/Blog_ModelingArchitecture_1.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 368px; height: 400px;" src="http://4.bp.blogspot.com/_txlKc91hcCk/TDGoTBrAYOI/AAAAAAAAAEw/bxeGPWT8rms/s400/Blog_ModelingArchitecture_1.png" alt="" id="BLOGGER_PHOTO_ID_5490354465561141474" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;The architectural overview seems to define packages which contain other packages&lt;/li&gt;&lt;li&gt;At a certain level the architectural overview seems to &lt;span style="font-style: italic;"&gt;reference&lt;/span&gt; packages from other projects to illustrate the dependencies&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Packages as resources&lt;/span&gt;&lt;br /&gt;In the current version of actifsource packages are reflected as file system folders. But it seems obvious that packages are much more then folders.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Package-structures have a project-specific meta model&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Packages declare dependencies to other packages (according the meta model)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Package structures may be distributed over several projects (package references)&lt;/li&gt;&lt;li&gt;Packages can be mapped to file system folders&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Packages are resources that contain other resources. Modeling packages as folders is just one way. Packages might also be modeled in the architectural overview without a folder representation. And package hierarchy structures are not limited to one project but distributed over many projects.&lt;br /&gt;&lt;br /&gt;In one of my next articles I try to examine the technicalities.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-4849845571415360902?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/4849845571415360902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/07/modeling-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4849845571415360902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4849845571415360902'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/07/modeling-architecture.html' title='Modeling Software Architecture'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_txlKc91hcCk/TDGoTBrAYOI/AAAAAAAAAEw/bxeGPWT8rms/s72-c/Blog_ModelingArchitecture_1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-8825017371146639373</id><published>2010-07-03T11:16:00.009+02:00</published><updated>2010-07-08T17:00:45.841+02:00</updated><title type='text'>On the semantics of explicit dependency relations</title><content type='html'>Meta-modeling leads to components built along the own-relations (compositions) and to component-interdependencies along &lt;a href="http://actifsource.blogspot.com/2010/07/structural-vs-functional-use-relations.html"&gt;structural use-relations&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Component interdependencies might appear deeply nested in the component. Remember that component comes from the Latin word "componere" which means being composed. The following example shows a use-relation between A.B and X.Y.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TC8M3kvFX1I/AAAAAAAAAEI/Fwxkywna4Jk/s1600/Blog_ExplicitDependencyRelation_1.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 268px; height: 117px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TC8M3kvFX1I/AAAAAAAAAEI/Fwxkywna4Jk/s400/Blog_ExplicitDependencyRelation_1.png" alt="" id="BLOGGER_PHOTO_ID_5489620619681423186" border="0" /&gt;&lt;/a&gt;Just looking at the components without knowing the internals we can say that there is an implicit dependency between the two components A and X.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TC8M3zhu4bI/AAAAAAAAAEQ/PtmE2Xsjg4k/s1600/Blog_ExplicitDependencyRelation_2.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 268px; height: 42px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TC8M3zhu4bI/AAAAAAAAAEQ/PtmE2Xsjg4k/s400/Blog_ExplicitDependencyRelation_2.png" alt="" id="BLOGGER_PHOTO_ID_5489620623651955122" border="0" /&gt;&lt;/a&gt;If we could make this dependency relation explicit there would be a way to constrain the A.B-X.Y relations on higher level.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/TC8M4JgYfkI/AAAAAAAAAEY/aMUNCRLNtCA/s1600/Blog_ExplicitDependencyRelation_3.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 344px; height: 117px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/TC8M4JgYfkI/AAAAAAAAAEY/aMUNCRLNtCA/s400/Blog_ExplicitDependencyRelation_3.png" alt="" id="BLOGGER_PHOTO_ID_5489620629551873602" border="0" /&gt;&lt;/a&gt;This possibility would allow you to control the component-interdependencies - even if they are nested deeply in the component structure.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Technical Architecture&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You may argue that component are not complex enough to control their use-relation by an explicit dependency. But imagine a software architecture which is based on layers and packages:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/TC8ScOEce2I/AAAAAAAAAEg/_Wo1NriCICc/s1600/Blog_ExplicitDependencyRelation_4.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 382px; height: 363px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/TC8ScOEce2I/AAAAAAAAAEg/_Wo1NriCICc/s400/Blog_ExplicitDependencyRelation_4.png" alt="" id="BLOGGER_PHOTO_ID_5489626746810301282" border="0" /&gt;&lt;/a&gt;All packages and subpackages are somehow related to each other. Since the above diagram shows the technical architecture of our system the artifacts placed in the packages are templates (when generating) or simply code.&lt;br /&gt;&lt;br /&gt;Just imagine you could explicitly define the dependencies between the packages. And now imagine that every template inter-dependency (one generic class using other generic classes) is checked immediately by the actifsource real-time validator.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Providing such a system your technical architecture would be documented soundly. And moreover actifsource would ensure that your code follows perfectly along the architecture.&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Business Architecture&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another very interesting application of dependency relations is found when designing the business architecture. Coping with a complex business domain the relating business objects have to be structured to keep the overview.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/TC8cFy8rYQI/AAAAAAAAAEo/PfedvBDomyQ/s1600/Blog_ExplicitDependencyRelation_5.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 382px; height: 363px;" src="http://4.bp.blogspot.com/_txlKc91hcCk/TC8cFy8rYQI/AAAAAAAAAEo/PfedvBDomyQ/s400/Blog_ExplicitDependencyRelation_5.png" alt="" id="BLOGGER_PHOTO_ID_5489637356689121538" border="0" /&gt;&lt;/a&gt;Grouping domain-objects in packages and defining dependencies between the packages allows you to control use-relations between components from a higher level.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Providing such a system would allow you to group domain objects together for a perfect overview. Moreover actifsource would ensure that any relationship between components follows the well defined business architecture.&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Modeling &lt;span style="font-style: italic;"&gt;explicit dependencies&lt;/span&gt; allows you to control use-relations from a higher view. This view is what we usually call the &lt;span style="font-style: italic;"&gt;architecture overview&lt;/span&gt;. &lt;span style="font-weight: bold;"&gt;actifsource could not only provide sound documentation of the architecture (technical and business) but also ensure at real-time that no artifact breaks the dependency rules.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The secret to this functionality lies in &lt;span style="font-style: italic;"&gt;typed folders&lt;/span&gt; as Micha described in his blog &lt;a href="http://actifsource.blogspot.com/2010/05/grouping-is-domain-specific-as-well.html"&gt;Grouping Is Domain Specific Too&lt;/a&gt;. In one of my next blogs I try to workout the tricky details.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-8825017371146639373?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/8825017371146639373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/07/on-semantics-of-explicit-dependency.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/8825017371146639373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/8825017371146639373'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/07/on-semantics-of-explicit-dependency.html' title='On the semantics of explicit dependency relations'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_txlKc91hcCk/TC8M3kvFX1I/AAAAAAAAAEI/Fwxkywna4Jk/s72-c/Blog_ExplicitDependencyRelation_1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-5323849834944524458</id><published>2010-07-02T16:45:00.021+02:00</published><updated>2010-07-03T10:34:38.229+02:00</updated><title type='text'>Writing C# using actifsource and eclipse</title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;When people from the dotNet world hear about actifsource running on eclipse, they always ask us if it is possible to generate c# code for example. Today I want to show you how to create a c# application in eclipse using the &lt;a href="http://emonic.sourceforge.net/"&gt;emonic&lt;/a&gt; plugin.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;First you have to install some prerequisites:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://nant.sourceforge.net/"&gt;nant&lt;/a&gt; - which is used to build the c# projects&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.go-mono.com/mono-downloads/download.html"&gt;mono&lt;/a&gt; or &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992&amp;amp;displaylang=en"&gt;Microsoft .NET Framwork&lt;/a&gt; - providing the tools and resources to run and build c#-projects&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;After you have installed them you need to setup emonic:&lt;/p&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 275px;" id="BLOGGER_PHOTO_ID_5489321994086208866" alt="" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/TC39RRs_VWI/AAAAAAAAAEk/Iijvx904q7s/s320/install+emonic.png" border="0" /&gt;&lt;br /&gt;&lt;p&gt;I only installed the "Eclipse Mono Integration", the debugger doesn't want to install at the moment and the other features are not required for this demo. When you have finished the installation, you first need to setup .NET preferences. Select the nant-binary-file:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 254px;" id="BLOGGER_PHOTO_ID_5489322882526443506" alt="" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/TC3-E_Zpd_I/AAAAAAAAAEs/J7fy2E68XzY/s320/setup+nant.png" border="0" /&gt;&lt;/p&gt;&lt;p&gt;and afterwards add a .NET-Framework Implementation. For example I used mono and chose the following settings:&lt;/p&gt;&lt;br /&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 254px;" id="BLOGGER_PHOTO_ID_5489323458630753826" alt="" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TC3-mhjnniI/AAAAAAAAAE8/OLs5vS5zfWc/s320/setup+frameworks.png" border="0" /&gt;&lt;br /&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 198px;" id="BLOGGER_PHOTO_ID_5489323286200053298" alt="" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/TC3-cfM77jI/AAAAAAAAAE0/oJzCUSpQA8U/s320/add_mono.png" border="0" /&gt;&lt;br /&gt;&lt;p&gt;Now create an actifsource projects for your meta model and the actifsource templates. I used the actifsource core model as meta model and wrote a simple data class template. The template is nothing special, but instead of writing java code, I wrote c# code:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 190px; display: block; height: 320px;" id="BLOGGER_PHOTO_ID_5489324793815967858" alt="" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TC3_0PglKHI/AAAAAAAAAFE/f0aSZoLx0xE/s320/cSharpDataClassTemplateProject.png" border="0" /&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4A9F0Nc9I/AAAAAAAAAFc/QthwQ-Dm3Q4/s1600/cSharpDataClassTemplate.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 248px;" id="BLOGGER_PHOTO_ID_5489326045344396242" alt="" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4A9F0Nc9I/AAAAAAAAAFc/QthwQ-Dm3Q4/s320/cSharpDataClassTemplate.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note that I have created a separate actifsource project for the actifsource template and generation specific resources. With our multi model concept, there is no need to modify your meta model project, just create an extension project. Since the actifsource project containing the template is a Java Project and mixing Java Code with C# Code is not recommended, switch to .NET-Perspective and create a separate .NET-Project.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4DNnArvdI/AAAAAAAAAFk/ePWkN-ZhMGk/s1600/open+perspective.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 263px; height: 320px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4DNnArvdI/AAAAAAAAAFk/ePWkN-ZhMGk/s320/open+perspective.png" alt="" id="BLOGGER_PHOTO_ID_5489328528156245458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4Dct_fiLI/AAAAAAAAAFs/WBPaIWEUNJU/s1600/createDotNetProject.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 309px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4Dct_fiLI/AAAAAAAAAFs/WBPaIWEUNJU/s320/createDotNetProject.png" alt="" id="BLOGGER_PHOTO_ID_5489328787728337074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I used "Mono 2.0" as target, you may use another target framework. This setting is important, since generics for example are not available in "Mono 1.0".&lt;br /&gt;&lt;br /&gt;For generating the data classes I first need some actifsource classes. I just reused one of my last examples and put it into a newly created asrc folder in the dotNet project.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4E-QpAvRI/AAAAAAAAAF8/Pg37ydlKqgA/s1600/dataClass.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 200px; height: 320px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4E-QpAvRI/AAAAAAAAAF8/Pg37ydlKqgA/s320/dataClass.png" alt="" id="BLOGGER_PHOTO_ID_5489330463476595986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now there are only a few steps to do, add a project dependency to the template-project and define the target folder.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/TC4Fyi-EWqI/AAAAAAAAAGE/sCP4_0GFjSw/s1600/cSharpProjectConfiguration.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 230px;" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/TC4Fyi-EWqI/AAAAAAAAAGE/sCP4_0GFjSw/s320/cSharpProjectConfiguration.png" alt="" id="BLOGGER_PHOTO_ID_5489331361749949090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The c# files will be generated immediately after pressing "ok". In emonic to make them compile, you have to right click on them and add each file to the build.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4InF39SZI/AAAAAAAAAGM/_lvLvhbPYiQ/s1600/runAsDotNetApplication.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 32px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TC4InF39SZI/AAAAAAAAAGM/_lvLvhbPYiQ/s320/runAsDotNetApplication.png" alt="" id="BLOGGER_PHOTO_ID_5489334463496014226" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When doing this the first time, you need to set a build target:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/TC4ECQgimBI/AAAAAAAAAF0/FuXh7OWI5UQ/s1600/buildExe.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 312px; height: 320px;" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/TC4ECQgimBI/AAAAAAAAAF0/FuXh7OWI5UQ/s320/buildExe.png" alt="" id="BLOGGER_PHOTO_ID_5489329432648914962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Finally I added a small demo application which creates two instances of the class "Person", fills them and queries the data for writing it to the console.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TC4Jgvhuk7I/AAAAAAAAAGU/ERmM230-fQ0/s1600/exampleMain.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 314px; height: 320px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TC4Jgvhuk7I/AAAAAAAAAGU/ERmM230-fQ0/s320/exampleMain.png" alt="" id="BLOGGER_PHOTO_ID_5489335453929608114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To run the application one needs to right-click on the exe-file and select run .NET-Application.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/TC4KD_213NI/AAAAAAAAAGc/csoem6DXYAM/s1600/runAsDotNetApplication.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 32px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/TC4KD_213NI/AAAAAAAAAGc/csoem6DXYAM/s320/runAsDotNetApplication.png" alt="" id="BLOGGER_PHOTO_ID_5489336059608554706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That's it. If you don't want to add each file, you need to edit the build script and make use of wildcards. One drawback using wildcards is that the emonic builder doesn't seem to detect file changes for these resources.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-5323849834944524458?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/5323849834944524458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/07/writing-c-using-actifsource-and-eclipse.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5323849834944524458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5323849834944524458'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/07/writing-c-using-actifsource-and-eclipse.html' title='Writing C# using actifsource and eclipse'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_NyhaJypG-ZA/TC39RRs_VWI/AAAAAAAAAEk/Iijvx904q7s/s72-c/install+emonic.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-7378746803524475396</id><published>2010-07-02T16:27:00.011+02:00</published><updated>2010-07-02T17:53:59.262+02:00</updated><title type='text'>Structural vs. Functional use-Relations</title><content type='html'>In my last blog I talked about &lt;a href="http://actifsource.blogspot.com/2010/06/on-semantics-of-permanent-use-relations.html"&gt;the semantics of permanent use-relations&lt;/a&gt;. In the meantime &lt;a href="http://www.blogger.com/profile/05154197551733318608"&gt;Micha&lt;/a&gt; had the idea not to differ between &lt;span style="font-style: italic;"&gt;permanent and temporary relations&lt;/span&gt; but between &lt;span style="font-style: italic; font-weight: bold;"&gt;structural and functional relations&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The idea remain the same. Some use-relations are important for the overall &lt;span style="font-style: italic;"&gt;component structure&lt;/span&gt; and some are not. Let's have a look at some examples.&lt;br /&gt;&lt;br /&gt;First of all, let's have a look at the following structure. Component owns Command owns Argument. But the Argument itself has a use-Relations to type. Imagine a function declaration &lt;span style="font-family:courier new;"&gt;f(int a, float b)&lt;/span&gt; where the argument &lt;span style="font-family:courier new;"&gt;a&lt;/span&gt; has a type &lt;span style="font-family:courier new;"&gt;int&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;b&lt;/span&gt; has type &lt;span style="font-family:courier new;"&gt;float&lt;/span&gt;. The relation of a method argument to its type is simply &lt;span style="font-weight: bold;"&gt;functional&lt;/span&gt; an will never appear as a relation in an UML diagram.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/TC36iS-1FDI/AAAAAAAAADY/RRMmQ1qB3Dk/s1600/Blog_StructuralVsFunctional_1.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 34px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/TC36iS-1FDI/AAAAAAAAADY/RRMmQ1qB3Dk/s400/Blog_StructuralVsFunctional_1.png" alt="" id="BLOGGER_PHOTO_ID_5489318987952362546" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The second example show a meta-model which declares that components may extend/subclass other components. This relationship is clearly &lt;span style="font-weight: bold;"&gt;structural&lt;/span&gt; because it's important from the component's view. Just imagine the specialization relation in a UML diagram.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/TC36n7FV84I/AAAAAAAAADg/PsRs5tqhiLI/s1600/Blog_StructuralVsFunctional_2.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 136px; height: 80px;" src="http://4.bp.blogspot.com/_txlKc91hcCk/TC36n7FV84I/AAAAAAAAADg/PsRs5tqhiLI/s400/Blog_StructuralVsFunctional_2.png" alt="" id="BLOGGER_PHOTO_ID_5489319084616446850" border="0" /&gt;&lt;/a&gt;Quite special on the above relation is the fact that it's never necessary to name the role of the extends relation more specifically. Extends remains extends no matter what is extended.&lt;br /&gt;&lt;br /&gt;The next example shows a meta-model for a component which has a collaboration relation to other components. The difference to the above design is that the collaboration relation has a role which has further information (i.e. at least a name.) For that reason the role has to be designed as an own class on the meta level called Collaborator in the subsequent example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TC36rKW7Q1I/AAAAAAAAADo/tLDKCZy0S4M/s1600/Blog_StructuralVsFunctional_3.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 268px; height: 79px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TC36rKW7Q1I/AAAAAAAAADo/tLDKCZy0S4M/s400/Blog_StructuralVsFunctional_3.png" alt="" id="BLOGGER_PHOTO_ID_5489319140256334674" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/TC36n7FV84I/AAAAAAAAADg/PsRs5tqhiLI/s1600/Blog_StructuralVsFunctional_2.png"&gt;&lt;br /&gt;&lt;/a&gt;Let me give a résumé: First of all we distinguish structural and functional use-relation. As a rule of thumb only structural use-relations matters for the overall component structure.&lt;br /&gt;&lt;br /&gt;Taking a closer look at structural use-relations one notice that there are relations with and without roles. If no role is needed the design is simple as seen above. If A extends B the extends relation between A and B needs no further information.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TC4Cd73F_LI/AAAAAAAAADw/5EPGRpplAaE/s1600/Blog_StructuralVsFunctional_4.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 287px; height: 48px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TC4Cd73F_LI/AAAAAAAAADw/5EPGRpplAaE/s400/Blog_StructuralVsFunctional_4.png" alt="" id="BLOGGER_PHOTO_ID_5489327709119446194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;But if we do need to distinguish roles for a structural use-relation this role has to be modeled in a separate class providing at least a name. In the example below component A uses B1 as xAxis and B2 as yAxis. Note that xAxis and yAxis are instances of Collaborator.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TC4CeKxsleI/AAAAAAAAAD4/iRxW4WNMv78/s1600/Blog_StructuralVsFunctional_5.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 287px; height: 117px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TC4CeKxsleI/AAAAAAAAAD4/iRxW4WNMv78/s400/Blog_StructuralVsFunctional_5.png" alt="" id="BLOGGER_PHOTO_ID_5489327713123341794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It's quite interesting that the class Collaborator of the meta-model is visualized as a role in the instance-model. Since the decision if a structural use-relation needs a role or not is taken by the designer, we have to distinguish&lt;span style="font-weight: bold;"&gt; 3 different modes for use-relations&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;functional use-relation&lt;/li&gt;&lt;li&gt;structural use-relation without a role&lt;br /&gt;&lt;/li&gt;&lt;li&gt;structural use-relation with a role&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;If we specify the use-relation mode on the use relation it becomes possible to visualize components and their interdependencies soundly.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To conclude this blog let's think if this concept might work for a generic diagram editor which can visualize meta-model and model at the same time. For this reason let's have a look at the following simplified UML meta-model (which can be seen as meta-meta-model for our example).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/TC4GYZ6fbuI/AAAAAAAAAEA/Byf5dzI-Tjo/s1600/Blog_StructuralVsFunctional_6.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 169px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/TC4GYZ6fbuI/AAAAAAAAAEA/Byf5dzI-Tjo/s400/Blog_StructuralVsFunctional_6.png" alt="" id="BLOGGER_PHOTO_ID_5489332012154056418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The type-relation from Argument to Class is a &lt;span style="font-weight: bold;"&gt;functional use-relation&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The extends relation from class to class is a &lt;span style="font-weight: bold;"&gt;structural use-relation without a role&lt;/span&gt;&lt;/li&gt;&lt;li&gt;The type-relation from Member to Class is a &lt;span style="font-weight: bold;"&gt;structural use-relation with a role&lt;/span&gt; (Member play the role)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;At the moment it seems to me that our concept can be applied to all types of models. And this would be greatly simplify the development of the diagram editor.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TC36rKW7Q1I/AAAAAAAAADo/tLDKCZy0S4M/s1600/Blog_StructuralVsFunctional_3.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-7378746803524475396?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/7378746803524475396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/07/structural-vs-functional-use-relations.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7378746803524475396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7378746803524475396'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/07/structural-vs-functional-use-relations.html' title='Structural vs. Functional use-Relations'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_txlKc91hcCk/TC36iS-1FDI/AAAAAAAAADY/RRMmQ1qB3Dk/s72-c/Blog_StructuralVsFunctional_1.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-5192453621416696879</id><published>2010-06-27T10:50:00.005+02:00</published><updated>2010-06-27T21:32:36.204+02:00</updated><title type='text'>On the semantics of permanent use-relations</title><content type='html'>3 weeks ago I have written a blog with the Title &lt;a href="http://actifsource.blogspot.com/2010/06/domain-specific-presentation-is.html"&gt;Domain-Specific Presentation is Component Visualization&lt;/a&gt;. The idea was to provide a &lt;span style="font-style: italic;"&gt;domain-specific component visualization&lt;/span&gt; which is aware of the different types of components and their relations.&lt;br /&gt;&lt;br /&gt;Since then I've asked myself if there isn't any UML-way to visualize domain-specific components. I know how this sounds like: UML is generic by its very nature but not domain-specific. But let's give it a try anyway.&lt;br /&gt;&lt;br /&gt;Before starting I have have to explain one thing first: actifsource distinguish only between two types of relations: the own-relation and the use-relation. The own-relation defines a strong coupling. If A owns B, B must not exist without A. The use-relation on the other hand doesn't imply any &lt;span style="font-style: italic;"&gt;life-time semantics&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;As I explained in my blog &lt;a href="http://actifsource.blogspot.com/2010/05/software-architecture-and-components.html"&gt;Software Architecture and Components&lt;/a&gt;, domain-specific components are defined implicitly around the own-relations of their meta-model.&lt;br /&gt;&lt;br /&gt;Looking at the &lt;a href="http://en.wikipedia.org/wiki/Composite_structure_diagram"&gt;&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Component_diagram"&gt;UML Component Diagram&lt;/a&gt; we find out that relations between components are realized as &lt;span style="font-style: italic;"&gt;delegation connectors&lt;/span&gt; which connects a port to an element of the component.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/TCcXlLNZubI/AAAAAAAAADQ/VnkkzLwitPY/s1600/800px-Policy_Admin_Component_Diagram.PNG"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 268px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/TCcXlLNZubI/AAAAAAAAADQ/VnkkzLwitPY/s400/800px-Policy_Admin_Component_Diagram.PNG" alt="" id="BLOGGER_PHOTO_ID_5487380598405839282" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;And now the interesting question: does every use-relation between components lead to a port?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To answer this question, lets have a look at the meta-model of a UML class. A class can be seen as a component as well, composing&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a name attribute&lt;/li&gt;&lt;li&gt;member variables&lt;/li&gt;&lt;li&gt;member functions&lt;/li&gt;&lt;/ul&gt;Lets have a closer look at member variables which can express to different relations:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;own relation&lt;/li&gt;&lt;li&gt;use relation&lt;/li&gt;&lt;/ul&gt;Unfortunately, using 3rd GL's the semantic isn't always that clear. Programming in C++ I use pointers to imply use-relations and references or value-objects to imply own-relations whenever possible.&lt;br /&gt;&lt;br /&gt;Before continuing the discussion, let's have a look at member functions. Functions consist of named and typed arguments. The types are modeled as a use-relation to other existing types.&lt;br /&gt;&lt;br /&gt;So, what is the difference between the use-relation of member-variables to other types and the use-relation of typed arguments of a member function?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The use-relations of member-variables define the permanent relations between components while the use-relations of typed arguments of a function definition simply simply define a temporary relation.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Obviously we have to distinguish between two different of use-relations:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;use-relations which define permanent relations between components&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;use-relations which define temporary relations between components&lt;/li&gt;&lt;/ul&gt;For a &lt;span style="font-style: italic;"&gt;valuable component relation overview&lt;/span&gt; we are interested only in permanent relations between components which leads to the following definition:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Permanent use-relations shall be shown as ports in a component diagram. &lt;/span&gt;&lt;/blockquote&gt;In my next blog I try to explain how composite structures shall be visualized using the &lt;a href="http://en.wikipedia.org/wiki/Composite_structure_diagram"&gt;UML Composite Structure Diagram&lt;/a&gt; combined with the idea of ports for permanent use-relations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-5192453621416696879?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/5192453621416696879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/on-semantics-of-permanent-use-relations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5192453621416696879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5192453621416696879'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/on-semantics-of-permanent-use-relations.html' title='On the semantics of permanent use-relations'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_txlKc91hcCk/TCcXlLNZubI/AAAAAAAAADQ/VnkkzLwitPY/s72-c/800px-Policy_Admin_Component_Diagram.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-9097850523121962854</id><published>2010-06-25T14:39:00.013+02:00</published><updated>2010-06-26T10:09:21.362+02:00</updated><title type='text'>Be careful when using access modifier</title><content type='html'>When working with frameworks provided by others, I sometimes get a little bit frustrated. Using the "normal" features provided by a framework in general is no problem. But when I have to access more information and go deeper into the code, I often find package-private and private modifiers protecting the code I like to reuse. Most often the problem is not at the method level, the method needed to call is public. In many cases even the constructor of the class is public, the problem begins with the arguments of the constructor or the method.&lt;br /&gt;&lt;br /&gt;Oft one of the arguments is a class declared package-private or is public but has a package-private constructor. This forces me to search for a factory-method, which is often hidden deep by other such constructs. Meaning the code is strongly coupled to the framework.&lt;br /&gt;&lt;br /&gt;Here is a small example:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TCSxmPtbLZI/AAAAAAAAAEU/5ksP7IRoBjk/s1600/strong_binding.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 279px; display: block; height: 320px;" id="BLOGGER_PHOTO_ID_5486705516654308754" alt="" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TCSxmPtbLZI/AAAAAAAAAEU/5ksP7IRoBjk/s320/strong_binding.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I hate such code, especially if there is no special reason why the factory has a package-private constructor. Maybe there is an misunderstanding between information hiding and class design.&lt;br /&gt;&lt;br /&gt;In cases where the code doesn't access any data from the framework there is no need to make the constructor package-private. It doesn't matter, if there is a second factory used by someone else. If you really need to have to use package-private, please make use of interfaces. This way it remains still possible to reuse the class by creating a new factory implementation:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/TCSxtIlcsaI/AAAAAAAAAEc/kXkukPzBz8E/s1600/weak_binding.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 313px; display: block; height: 320px;" id="BLOGGER_PHOTO_ID_5486705635000889762" alt="" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/TCSxtIlcsaI/AAAAAAAAAEc/kXkukPzBz8E/s320/weak_binding.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I always wonder how the test code for such strong coupled code looks like. If you use interfaces unit testing is an easy task. You might use a mock framework like &lt;a href="http://easymock.org/"&gt;easymock&lt;/a&gt;. Using interfaces your class can be tested independent from the factory implementation and without creating an instance of the framework class.&lt;br /&gt;&lt;br /&gt;For easier testing and better reusability, I suggest to use public-interfaces for a reasonable decoupling whenever possible.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-9097850523121962854?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/9097850523121962854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/be-careful-when-using-access-modifier.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/9097850523121962854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/9097850523121962854'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/be-careful-when-using-access-modifier.html' title='Be careful when using access modifier'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_NyhaJypG-ZA/TCSxmPtbLZI/AAAAAAAAAEU/5ksP7IRoBjk/s72-c/strong_binding.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-6363307350386989500</id><published>2010-06-24T11:37:00.005+02:00</published><updated>2010-06-24T11:48:11.431+02:00</updated><title type='text'>Abolish the Mutants! .. or do we need Setable and Mapable Interfaces?</title><content type='html'>&lt;div style="text-align: justify;"&gt;No, this is not about a &lt;a href="http://en.wikipedia.org/wiki/X-Men_%28film_series%29"&gt;well-known film series&lt;/a&gt;. This is about software development! Forgive me for the lurid title :-)&lt;a href="http://dict.leo.org/ende?lp=ende&amp;amp;p=Ci4HO3kMAA&amp;amp;search=lurid&amp;amp;trestr=0x8004"&gt;&lt;/a&gt;  &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Some weeks ago I was writing about an &lt;a href="http://actifsource.blogspot.com/2010/05/java-collection-framework-and.html"&gt;unexpected behaviour when you use Map.Entry objects in HashSets&lt;/a&gt;. The problem was emerging because the code assumed an object to be immutable that was not. More generally, we can ask: What elements can we put into a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Set&lt;/span&gt; or use as the key of a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Map&lt;/span&gt;?&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In the javadoc to &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Map&lt;/span&gt; we find following warning:&lt;/div&gt;&lt;blockquote&gt;Note: great care must be exercised if mutable objects are used as map&lt;br /&gt;keys.&amp;nbsp; The behavior of a map is not specified if the value of an object is&lt;br /&gt;changed in a manner that affects &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;equals&lt;/span&gt; comparisons while the&lt;br /&gt;object is a key in the map.&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;Unfortunately, we usually do not immediately see wheter an object can be changed in such a way or not and therefore are clueless whether we are allowed to use it as the key of a mapping. We need to check the implementation of the class and possible sub-classes. If we are dealing with an interface we would have to check all implementations which is an impossible task as new implementations might be added in the future.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The inventors of the java collection library could have diminished this problem by introducing an interface &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Setable&lt;/span&gt; resp. &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Mapable&lt;/span&gt; which mark whether a class is designed for being put into a set resp. for being the key in a map. &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Map&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Set&lt;/span&gt; could then allow only objects implementing these interfaces. However, these interface names are rather cumbersome and as they choose not to do this, we need to find another way of dealing with this issue.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;Universum java est omnis divisa in partes tres &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If we look at the universe of all java objects we can group them into three distinct sets:&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Immutable objects&lt;/li&gt;&lt;li&gt;Entities&lt;/li&gt;&lt;li&gt;Neither 1 nor 2&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Immutable &lt;/b&gt;&lt;b&gt;objects&lt;/b&gt; are objects which never change their internal state. They are created fully-initialized, their hash code never changes and the equality relation formed by their &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;equals&lt;/span&gt; method remains the same in their full livetime. They are perfect set members and hash keys!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Entities&lt;/b&gt; can change their internal state over time but they have a constant identity-giving property. Every java class which does not override &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;equals&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hashCode&lt;/span&gt; from &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.lang.Object &lt;/span&gt;fullfills this requirement: It's identity is given by it's address in memory (which is only accessable to the jvm but nonetheless it is consistently defined). In other cases, the entity's identity is given by some id which might be a final &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;long&lt;/span&gt; field or some special guid. The &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;equals&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hashCode&lt;/span&gt; methods must then be defined on this id only and not on any other fields. This makes entities suitable for sets and maps.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The remaining objects which are neither immutable nor entities can change their identity over time. I will therefore call them &lt;b&gt;mutants&lt;/b&gt; for now. We should use them in sets and maps only if we can somehow &lt;i&gt;guarantee&lt;/i&gt; that they will never &lt;i&gt;mutate&lt;/i&gt; (change their identity) the &lt;i&gt;entire time&lt;/i&gt; while they are used in the sets or maps!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;Avoid Mutants!&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Unfortunately, there are many mutants hiding in the java libraries:&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.List&lt;/span&gt; and all its implementations&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Set&lt;/span&gt; and all its implementations&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Map&lt;/span&gt; and all its implementations&lt;/li&gt;&lt;li style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.BitSet&lt;/li&gt;&lt;li style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Date&lt;/li&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;So, what can you do if you  want to use a list of elements safely as key to a map, for example? &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;public class Registry {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; private Map&amp;lt;List&amp;lt;String&amp;gt;, String&amp;gt; map = new HashMap&amp;lt;List&amp;lt;String&amp;gt;, String&amp;gt;();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; public void put(List&amp;lt;String&amp;gt; strings, String value) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; &amp;nbsp; // oops, unsafe! &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.put(strings, value);&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The list of strings is a potential mutant!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;  public void put(List&amp;lt;String&amp;gt; strings, String value) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; &amp;nbsp; //  oops, still unsafe! &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;  map.put(Collections.unmodifiableList(strings), value);&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;  }&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Wrapping the mutant into an unmodifiable list will still not work as the caller of the method still has a reference to the list and can therefore modify it!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;  public void put(List&amp;lt;String&amp;gt; strings, String value) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;  map.put(createImmutableCopy(strings), value);&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp;  }&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; private List&amp;lt;String&amp;gt; createImmutableCopy(List&amp;lt;String&amp;gt; strings) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; &amp;nbsp; return Collections.unmodifiableList(new ArrayList&amp;lt;String&amp;gt;(strings)); &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; text-align: justify;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;We need to both copy the list and put it into a unmodifiable wrapper! Now we can guarantee that this list will never change again because there are no references to the wrapped &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ArrayList&lt;/span&gt; except by the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Collections.UnmodifiableList&lt;/span&gt; wrapper which guards it from modifications. Note that we have this guarantee only because we know that the list is an direct result from our helper function. If we pass the list to some other method it will have to be treated as potential mutant there again...&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;As you see, mutants cause a lot of trouble and work to ensure they do not change their identity again. Therefore my demand is cleary: &lt;b&gt;Do not write any mutant classes!&lt;/b&gt; By cleverly compositing immutable classes and entitiy classes you can always avoid the danger-bringing mutants.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-6363307350386989500?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/6363307350386989500/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/need-for-setable-and-mapable-interfaces.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6363307350386989500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6363307350386989500'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/need-for-setable-and-mapable-interfaces.html' title='Abolish the Mutants! .. or do we need Setable and Mapable Interfaces?'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-5763810339316888772</id><published>2010-06-18T17:30:00.001+02:00</published><updated>2010-06-18T19:30:01.493+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DSL'/><title type='text'>Generating an internal DSL from an external DSL</title><content type='html'>We have learned that when we create sound explicit intension revealing APIs the number of &lt;a href="http://www.osnews.com/story/19266/WTFs_m"&gt;WTF&lt;/a&gt;s per minute is reduced and the programmer's developer life is a bit easier.&lt;br /&gt;&lt;br /&gt;Further we can introduce a steep learning curve and make less faults due to accidental missusage of the API.&lt;br /&gt;&lt;br /&gt;Making &lt;a href="http://martinfowler.com/dslwip/InternalOverview.html"&gt;internal DSL&lt;/a&gt;s formulated in our general purpose programming language is one way to aproach this but writing an internal DSL is not an easy task and violates the &lt;a href="http://en.wikipedia.org/wiki/KISS_principle"&gt;KISS&lt;/a&gt; principle.&lt;br /&gt;&lt;br /&gt;But since you want to make the life of our developers a bit easier and even more fun it makes sense to create such an internal DSL where the developer can declaratively describe what is needed from the API.&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;actualValue = ... // this value should be detected by the framework&lt;br /&gt;Detector detector = actualValueFramework.bind(new DetectorModule {&lt;br /&gt; @Override&lt;br /&gt; public void configure(DetectorExpressionBuilder detector) {&lt;br /&gt;  detector.detect()&lt;br /&gt;   .withEvent().change()&lt;br /&gt;   .andInterval().humanVisual()&lt;br /&gt;   .andPersistency().disc();&lt;br /&gt; }&lt;br /&gt;}).to(actualValue);&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;Listing 1&lt;br /&gt;&lt;br /&gt;My prefered internal DSL style in Java is shown in listing 1 and is known as &lt;a href="http://martinfowler.com/dslwip/MethodChaining.html"&gt;Method Chaining&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;With code completion from the IDE this is very neat since the proposed possibilities from the completion express the further declaration steps. The developer can explore the API without any prior knowledge of its usage.&lt;br /&gt;&lt;br /&gt;So this way I can achieve the goals mentioned above. Exploring is fun. Code completion while exploring makes it easy. Finding words from the problem domain makes it intension revealing.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;But how can I make my own life easier and even more fun?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have learned that the internal DSLs in Java can have a generic domain model, a meta-model. There is always a variation-point and its variations. Variations can be defined using polymorphism. A generic domain model must therefore give me the ability to express my API this way.&lt;br /&gt;&lt;br /&gt;In the example above I have an &lt;a href="http://www.infoq.com/articles/ddd-in-practice"&gt;Domain-Event&lt;/a&gt; that can be either Change, reach an Upper or Lower Limit. Then there is an interval that can be a millisecond, humanVisual oder oneMinute. The persistency can be disc or memory.&lt;br /&gt;&lt;br /&gt;Event, interval and persistency are the variation-points where as change, upper, lower, millisecond, humanVisual, oneMinute, disc and memory are variations.&lt;br /&gt;&lt;br /&gt;Using actifSource I created an &lt;a href="http://martinfowler.com/dslwip/ExternalOverview.html"&gt;external DSL&lt;/a&gt; that lets me express this variability in a generic domain model and write a code generator that generates &lt;a href="http://martinfowler.com/dslwip/ExpressionBuilder.html"&gt;ExpressionBuilders&lt;/a&gt; from the specific domain model.&lt;br /&gt;&lt;br /&gt;Now it is no more hard to write such type of internal DSL where your specific domain model can be expressed in a declarative descriptive way.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How is it done using actifSource?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the generic domain model class ExpressionBuilder is defined one property called &lt;span style="font-style: italic;"&gt;operation&lt;/span&gt; and one called &lt;span style="font-style: italic;"&gt;expression&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The property &lt;span style="font-style: italic;"&gt;operation &lt;/span&gt;is from type Operation and &lt;span style="font-style: italic;"&gt;expression &lt;/span&gt;is from type Class.&lt;br /&gt;&lt;br /&gt;Operation is a NamedResource and here the operation name is used as a starting point of the expression. As in listing 1 the &lt;span style="font-family: courier new;"&gt;detector.&lt;span style="font-weight: bold;"&gt;detect&lt;/span&gt;()&lt;/span&gt; method. The Class contains a Class Instance having defined its own properties. Each property's Range is from an abstract class.&lt;br /&gt;&lt;br /&gt;The Class is the variation-point where as the Class Instance is the variation.&lt;br /&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;public PersistencyExpression withPersistency(){&lt;br /&gt; return new PersistencyExpression();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;Listing 2&lt;br /&gt;&lt;br /&gt;The generator reads each property and defines a with-Method as shown in Listing 2 for&lt;br /&gt;i.e. the Persistency variation-point.&lt;br /&gt;&lt;br /&gt;Further the generator generates an ExpressionBuilder by looking up all instances of the type defined as Range on the property and creates methods.&lt;br /&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;public class PersistencyExpression{&lt;br /&gt; public AndProperties memory(){&lt;br /&gt;  persistency = new Memory();&lt;br /&gt;  return new AndProperties();&lt;br /&gt; }  &lt;br /&gt; public AndProperties disc(){&lt;br /&gt;  persistency = new Disc();&lt;br /&gt;  return new AndProperties();&lt;br /&gt; }  &lt;br /&gt;}&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;Listing 3&lt;br /&gt;&lt;br /&gt;The end declaration of the internal DSL expression is also generated as shown in listing 4.&lt;br /&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;public Detector build(){&lt;br /&gt; DetectorImpl build = new DetectorImpl();&lt;br /&gt; &lt;br /&gt; if(persistency!=null){&lt;br /&gt;  build.setPersistency(persistency);&lt;br /&gt; }&lt;br /&gt; if(interval!=null){&lt;br /&gt;  build.setInterval(interval);&lt;br /&gt; }&lt;br /&gt; if(range!=null){&lt;br /&gt;  build.setRange(range);&lt;br /&gt; }&lt;br /&gt; if(event!=null){&lt;br /&gt;  build.setEvent(event);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; return build;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;Listing 4&lt;br /&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;public class ActualValueFrameworkImpl ...&lt;br /&gt;   public BindTo bind(final DetectorModule detectorModule) {&lt;br /&gt;      return new BindTo(){&lt;br /&gt;&lt;br /&gt;         @Override&lt;br /&gt;         public Disposable to(final ActualValue actualValue) {&lt;br /&gt;            DetectorExpressionBuilder detect = new DetectorExpressionBuilder();&lt;br /&gt;            detectorModule.configure(detect);&lt;br /&gt;            return detect.build();&lt;br /&gt;   }&lt;br /&gt;  };&lt;br /&gt; }&lt;br /&gt; ...&lt;br /&gt;}&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;Listing 5&lt;br /&gt;&lt;br /&gt;Now the framework method looks like listing 5.&lt;br /&gt;&lt;br /&gt;If this is a proper usage of modeling or not... it does make my life easier an I can generate several internal DSLs using this aproach and have nothing else to do as to declaratively define it and press generate.&lt;br /&gt;&lt;br /&gt;Happy modeling, Nils&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-5763810339316888772?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/5763810339316888772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/generating-internal-dsl-from-external.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5763810339316888772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5763810339316888772'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/generating-internal-dsl-from-external.html' title='Generating an internal DSL from an external DSL'/><author><name>nils</name><uri>http://www.blogger.com/profile/10104925986418167411</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/-3BfBrdIHnBI/TpVVthj6TEI/AAAAAAAABPc/-jV5gpBujHk/s220/Foto.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-594420417323511096</id><published>2010-06-18T14:40:00.006+02:00</published><updated>2010-06-21T11:01:27.337+02:00</updated><title type='text'>Plugin Dependency Management outside Eclipse</title><content type='html'>Today I searched for a solution to simplify using the actifsource ant task. Until now, all actifsource scopes (either an eclipse project or a bundle) have to be defined using a special actifsource ant-task, which takes a classpath. When making heavy usage of bundles, these classpaths can really become long and updating them by hand is not very convenient.&lt;br /&gt;&lt;br /&gt;One idea I had to improve this is to define the plugin-directory directly and only point to the required bundles by their symbolic names. To do this we need to load the plugin outside of eclipse. The first place to start was to have a deeper look into equinox and see if there is a way to simply load all plugins and use them to load the required classes. At the moment we don't need to activate the bundles.&lt;br /&gt;&lt;br /&gt;Sadly the equinox framework seems to strongly rely on some properties and requires the existence configuration files on the files ystem. Reusing the implementations like BaseAdaptor, Framework, HookRegistry and BaseStorage isn't really an option since they are strongly bound together. Some of the classes have only package private constructors, others have public constructors but taking one of the private classes as parameter. Time to search another solution. OSGi is an open standard and every implementation should be able to load the bundles.&lt;br /&gt;&lt;br /&gt;The solution I found, was &lt;a href="http://felix.apache.org/"&gt;Apache Felix&lt;/a&gt;. It was said to be easy in setup and when I tried an example I was really glad to find out that this is true.&lt;br /&gt;&lt;br /&gt;The following code allows me to load a bundle located in the plugin directory:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new; font-size: 85%;"&gt;Felix felix = new Felix(Collections.emptyMap());&lt;br /&gt;try {&lt;br /&gt;felix.start();&lt;br /&gt;} catch (BundleException e) {&lt;br /&gt;e.printStackTrace();&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;File bundleDir = new File("C:\\eclipseLocation\\plugins");&lt;br /&gt;Bundle bundle = felix.getBundleContext().installBundle("locationId", new FileInputStream(new File(bundleDir, "bundle.jar")));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is really short. Using this approach to load all bundles from the bundle-Directory would allow us to search for the bundles by their symbolic name and directly refer to them. No more classpath setup in every ant-file. Maybe we could also load some extension point definitions and and simplify the whole registration of generator tasks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-594420417323511096?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/594420417323511096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/plugin-dependency-management-outside.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/594420417323511096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/594420417323511096'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/plugin-dependency-management-outside.html' title='Plugin Dependency Management outside Eclipse'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-6946351921300601385</id><published>2010-06-15T11:49:00.000+02:00</published><updated>2010-06-15T11:49:12.333+02:00</updated><title type='text'>GWT And Data Persistence</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;After trying out the &lt;a href="http://code.google.com/intl/de-CH/webtoolkit/doc/latest/tutorial/"&gt;tutorials from the Google Web Toolkit&lt;/a&gt; I created some small application where I needed to persist some data on the server. I was searching how to do this for quite some while so I thought it would be a nice idea to share what I found out about it. Basically, you can store data easily using Java Data Objects (&lt;a href="http://code.google.com/intl/de-CH/appengine/docs/java/gettingstarted/usingdatastore.html"&gt;JDO&lt;/a&gt;) but there are some things that you have to pay attention to.&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;JDO uses annotations to mark the fields and classes that are persistable:&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@PersistenceCapable&lt;br /&gt;public class Book extends Entity {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&amp;nbsp; @Persistent&lt;br /&gt;&amp;nbsp; private java.lang.String title;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; @Persistent&lt;br /&gt;&amp;nbsp; private java.lang.String iSBN;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&amp;nbsp; @Persistent&lt;br /&gt;&amp;nbsp; private double price;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; @Persistent&lt;br /&gt;&amp;nbsp; private java.lang.String description;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; // ...&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;}&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family: inherit; font-size: small;"&gt;When you are working with GWT you usually implement services on the Server. This is done by extending&lt;/span&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;RemoteServiceServlet&lt;/span&gt; &lt;span style="font-size: small;"&gt;and implementing your service interface. That is the place where I wanted to persist the data which gets changed by service calls. To do this, you need a so-called &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;PersistenceManager&lt;/span&gt;.&lt;span style="font-size: small;"&gt; I wrote a helper class which contains a singleton access to a &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;PersistenceManagerFactory:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;public final class PMF {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; private static final PersistenceManagerFactory pmfInstance =&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JDOHelper.getPersistenceManagerFactory("transactions-optional");&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; private PMF() {}&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public static PersistenceManagerFactory get() {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return pmfInstance;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Now, creating a new book and making it persistent is as easy as this:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; @Override&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public Book createBook() {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Book newBook = new Book();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PersistenceManager pm = PMF.get().getPersistenceManager();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pm.makePersistent(newBook);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pm.close();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return newBook;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Access to existing data is done using &lt;a href="http://code.google.com/intl/de-CH/appengine/docs/java/datastore/queriesandindexes.html"&gt;JDOQL&lt;/a&gt; and not much harder:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;public List&lt;book&gt; getBooks() {&lt;br /&gt;&amp;nbsp; PersistenceManager pm = PMF.get().getPersistenceManager();&lt;/book&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; Query query = pm.newQuery(Book.class);&lt;br /&gt;&amp;nbsp; &amp;nbsp; List&lt;book&gt; results = (List&lt;book&gt;) query.execute();&lt;br /&gt;&amp;nbsp; &amp;nbsp; return new ArrayList&lt;book&gt;(results);&lt;/book&gt;&lt;/book&gt;&lt;/book&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; } finally {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pm.close();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This gives a list of all existing books.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;I got into problem when I tried to use iheritence with my JDO data classes. All my data classes inherit from the following class &lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Entity&lt;/span&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@PersistenceCapable&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;public abstract class Entity {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @PrimaryKey&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Long fKey;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected Entity() {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; this(null);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected Entity(Long key) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; fKey = key;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public long getKey() {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return fKey;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int hashCode() {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (fKey == null) return 0;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return fKey.hashCode();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean equals(Object obj) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;// ...&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;}&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The important piece here is &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE).&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; This defines how the objects are stored in the tables. As the default store strategy is not implemented by google it is very important to specify this explicitly!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;If you want to use the data classes as arguments to the service call you need to give them a no-arg constructor&amp;nbsp; (which is allowed to be private) and make sure that they inhert from &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;IsSerializable&lt;/span&gt;:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /**&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; * Creates a new {@link Book} with all fields set to default.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public Book() {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; title = "";&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iSBN = "";&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; price = 0.0;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; description = "";&lt;br /&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-6946351921300601385?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/6946351921300601385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/gwt-and-data-persistence.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6946351921300601385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6946351921300601385'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/gwt-and-data-persistence.html' title='GWT And Data Persistence'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-98469555196067946</id><published>2010-06-11T14:41:00.008+02:00</published><updated>2010-06-12T09:27:31.686+02:00</updated><title type='text'>Implementing Apache Axis Webservices based on POJOs</title><content type='html'>In my last post I came up with the idea of generating a Webservice using dataclass generated from an actifsource model.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Have you ever wrote a wsdl from scratch?&lt;/span&gt; If you are used to the wsdl-schema, it seams to be really easy, even for beginners. Later on when you write the server-side implementation, you will soon find out that you always have to look out for inconsistencies. When you are done and start implementing the client-side, this task become more difficult, it's the third place where to keep consistency.&lt;br /&gt;&lt;br /&gt;This week I started to explore how to generate an &lt;span style="font-style: italic;"&gt;Apache axis&lt;/span&gt; webservice (&lt;a href="http://ws.apache.org/axis/"&gt;http://ws.apache.org/axis/&lt;/a&gt;) with actifsource. First I looked at the eclipse web tool platform project (wtp), for common users point of views, it seems to be really straight forward. If the server-side project and the environment is set up correctly, the service classes are updated on the fly via hot code replacement and there is also the possibility to run the tomcat webserver in debug mode. In debug mode you can use breakpoints the same way in every other jdt project. That's fine.&lt;br /&gt;&lt;br /&gt;One big disadvantage I found, was the way how dependencies are managed. There is an additional entry for the j2ee-dependencies in the preferences. This means you have to be careful where to set the dependencies, because only dependencies defined here, are automatically uploaded to the webserver.&lt;br /&gt;&lt;br /&gt;If your project is also an osgi-bundle, then these dependencies are ignored. This is a thing you have to take care about, but it not really is a problem, since the server-side implementation should be in it's own project anyway. So what was really annoying? The wtp toolkit changed all projects , I added to the j2ee-dependencies. Now, I had dependencies to the eclipse builder of the wst-project in all library-projects I referred to. As that wasn't enough, the classpath was modified, to include the Apache Tomcat 6 Libraries.&lt;br /&gt;&lt;br /&gt;The result is that when we are looking at the dependencies we now have to deliver all the tomcat libraries. Each developer working with these libraries has to install the eclipse wst, otherwise he gets an eclipse problem marker and the project won't compile. The solution I found, was to create a jar-file for each library directly in the webservice project. This means I have to keep them up to date by myself and they are duplicate for each webservice using them.&lt;br /&gt;&lt;br /&gt;The alternative to this is either to find another toolkit, which behaves different or to create an actifsource solution. The actifsource solution should be able to create the dataclasses, the server-side implementation with protected regions and the client implementation directly from the model. Both the server implementation and the client implementation should have the same service interface. To be independent from the underlying webservice framework it should use a generic ServiceException instead, i.e. an AxisFault. The server implementation should be automatically packed in a service archive (.aar/.war) together with the required libraries. At the end it would be fine, if it also offers the possibility for automatic uploading to the webservice.&lt;br /&gt;&lt;br /&gt;For this task I reuse the templates for the genericapp dataclasses and modified the model from service tutorial to fit my needs. I searched for a possibility to auto-generate the wsdl from the server implementation. Reusing the implementations from the wst-plugins was a good option, but failed by lack of information and doesn't seem to be easy and may be impossible.&lt;br /&gt;&lt;br /&gt;Looking at the apache axis website I saw that they already used axis v2 and that there is no need to provide the wsdl in the ".aar" webservice archive. There is no longer the need for a deploy.wsdd and undeploy.wsdd, instead one has to put an "services.xml" to the META-INF directory of the webarchive. This file is really simple, it only needs the service name and some default handlers:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/TBJNQzS7HmI/AAAAAAAAAEM/lc0kRq7SsgI/s1600/services.xml.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 168px;" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/TBJNQzS7HmI/AAAAAAAAAEM/lc0kRq7SsgI/s320/services.xml.png" alt="" id="BLOGGER_PHOTO_ID_5481528647506140770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Since I want to use the actifsource namespace, I also defined the package-namespace mapping and a generated wsdl. One pitfall was generating a custom wsdl; it must be located in the META-INF directory (not in the wsld-directory as in axis 1) and in wsdl2 format, otherwise it will be ignored. Creating the server-side implementation including the templates costs me about four days. But not for writing the templates and the actifsource model. I spent most of the time reading documentation and discovering how the thing work in axis2. Thinking back, how to define the namespace-mapping and why my custom wsdl was ignored, was the hardest thing. Tcpmon was a really good helper. So basically, the main time I spent in learning how axis2 works.&lt;br /&gt;&lt;br /&gt;The client implementation was much easier and compared to axis 1 which generates four classes for the implementation, in axis 2 there is only one implementation class needed and the interface definition can be shared between server and client.&lt;br /&gt;&lt;br /&gt;Now after a week of work, I have a working generic app which has two part. A dataclass project, which defines the metamodel for the dataclasses and the service interfaces. And an axis-service-project to generate the axis-client and server implementation. Here is an example how the project dependencies in a simple setup will look like.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/TBJMllqcj4I/AAAAAAAAAEE/sAZSmCcuLFk/s1600/axis-service-model.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 146px;" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/TBJMllqcj4I/AAAAAAAAAEE/sAZSmCcuLFk/s320/axis-service-model.png" alt="" id="BLOGGER_PHOTO_ID_5481527905112330114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Note that the only actifsource model the user has to create is the dataclass. I think it is a good idea to provide a project generation buildconfig, which allows the creation of the target projects for client, server and dataclasses including an initial setup.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-98469555196067946?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/98469555196067946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/implementing-axis-webservices-based-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/98469555196067946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/98469555196067946'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/implementing-axis-webservices-based-on.html' title='Implementing Apache Axis Webservices based on POJOs'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_NyhaJypG-ZA/TBJNQzS7HmI/AAAAAAAAAEM/lc0kRq7SsgI/s72-c/services.xml.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-3828060248647987284</id><published>2010-06-11T14:35:00.001+02:00</published><updated>2010-06-11T14:36:54.949+02:00</updated><title type='text'>Casting in Java Leads to DRY Violations</title><content type='html'>The &lt;a href="http://c2.com/cgi/wiki?DontRepeatYourself"&gt;&lt;b&gt;D&lt;/b&gt;on't &lt;b&gt;R&lt;/b&gt;epeat &lt;b&gt;Y&lt;/b&gt;ourself&lt;/a&gt; principle states that you should not have any duplication in your code. Code duplication makes the code harder to maintain. In Java, one finds often code like this:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; String extractValue(IType parameter) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (parameter instanceof ILiteralType) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ILiteralType literalType = (ILiteralType)parameter;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return literlType.getValue(); &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;Of course, it is best to avoid casting completely. However, in some cases this is not possible. When casting, the code must first check if an object is an instance of the desired type using the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;instanceof&lt;/span&gt; operator. If the test succeeds, the object can be casted to the type. The problem is that you have to specify the type &lt;b&gt;twice&lt;/b&gt; which is a repetition and therefore violates DRY. Whenever you change the type in the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;instanceof&lt;/span&gt; expression you need to change the cast in sync. Failing to do so will result in an error that occurs &lt;b&gt;only at run time&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;One can circumvent this problem by using a little static helper function (we have put it in a class named &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ObjectUtil&lt;/span&gt;):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public static &lt;t&gt; T castOrNull(Object o, Class&lt;t&gt; clazz) {&lt;/t&gt;&lt;/t&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!clazz.isInstance(o)) return null;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return clazz.cast(o);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With the help of this function the code above becomes:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; String extractValue(IType parameter) { &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ILiteralType literalType =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ObjectUtil.castOrNull(parameter, ILiteralType.class);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (literaType == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return literalType.getValue();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;Now, the type is specified only once as argument to the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;castOrNull&lt;/span&gt; method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;(The attentive reader will object that &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ILiteralType&lt;/span&gt; is still specified twice, once as argument to &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;castOrNull&lt;/span&gt; and once when defining the variable &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;literalType&lt;/span&gt;. So effectively, we have only two occurrences instead of three in the original code. However, an inconsistency of the two remaining occurrences will be detected by the compiler and is therefore far fewer problematic!)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-3828060248647987284?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/3828060248647987284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/casting-in-java-leads-to-dry-violations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3828060248647987284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3828060248647987284'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/casting-in-java-leads-to-dry-violations.html' title='Casting in Java Leads to DRY Violations'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-6719140041830435011</id><published>2010-06-08T18:14:00.003+02:00</published><updated>2010-06-08T18:56:54.662+02:00</updated><title type='text'>Domain-Specific Presentation is Component Visualization</title><content type='html'>Some time ago I was asked if actifsource provides a &lt;span style="font-weight: bold;"&gt;domain-specific presentation&lt;/span&gt; of &lt;span style="font-weight: bold;"&gt;domain-models&lt;/span&gt;. I had to answer this question with &lt;span style="font-style: italic;"&gt;no&lt;/span&gt;. But what's the problem with a domain-specific presentation?&lt;br /&gt;&lt;br /&gt;As I stated in this blog before, components are the building blocks of architecture. A component (derived from latin "componens") is something that is composed of different parts by its very nature.&lt;br /&gt;&lt;br /&gt;Using different UML classes to visualize components is kind of silly, because the single parts of a component are structured hierarchically. This means, that &lt;span style="font-style: italic;"&gt;visualizing component instances of the same type is given by concept&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;But how to specify a &lt;span style="font-weight: bold;"&gt;component visualization concept&lt;/span&gt;? The problem is to cope with the multiplicity of relations between the component parts. Being able to visualize a to-many relation &lt;span style="font-weight: bold;"&gt;r&lt;/span&gt; between to elements &lt;span style="font-weight: bold;"&gt;A&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;B&lt;/span&gt; means that the &lt;span style="font-weight: bold;"&gt;visualization concept&lt;/span&gt; has to cope with any number of &lt;span style="font-weight: bold;"&gt;B&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;instances &lt;/span&gt;aggregated in &lt;span style="font-weight: bold;"&gt;A&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;To implement a &lt;span style="font-style: italic;"&gt;generic&lt;/span&gt; graphical editor where you can design a &lt;span style="font-weight: bold;"&gt;component visualization concept&lt;/span&gt; which handles the presentation of to-many relation is quite a challenge.&lt;br /&gt;&lt;br /&gt;I will try to sketch a possible solution in one of my next blogs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-6719140041830435011?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/6719140041830435011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/domain-specific-presentation-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6719140041830435011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6719140041830435011'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/domain-specific-presentation-is.html' title='Domain-Specific Presentation is Component Visualization'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-7390659782848339159</id><published>2010-06-07T11:28:00.000+02:00</published><updated>2010-06-07T11:28:08.219+02:00</updated><title type='text'>If a bug exists long enough it becomes a feature..</title><content type='html'>Consider the following code which uses a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.TreeSet&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;1 TreeSet set = new TreeSet();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;2 set.add(null);&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;3 set.remove(null);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Does it work? Does it throw a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NullPointerException&lt;/span&gt;? If we look at the javadoc of the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TreeSet.add &lt;/span&gt;method we read:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;* @throws NullPointerException if the specified element is null&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and this set uses natural ordering, or its comparator&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; does not permit null elements&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As we create the TreeSet using the default constructor it uses the natural ordering and we would expect a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NullPointerException&lt;/span&gt; on line 2. However, the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NullPointerException&lt;/span&gt; happens only on line 3. Even though this is a clear bug which got reported already for java 1.3 (&lt;a href="http://bugs.sun.com/view_bug.do?bug_id=5045147"&gt;issue 5045147&lt;/a&gt;) it is still present in Java 6. Sun decided that there is too much code that would break if they fixed the bug that adding &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;null&lt;/span&gt; to an empty TreeSet is allowed. One might ask what quality such code has..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-7390659782848339159?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/7390659782848339159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/if-bug-exists-long-enough-it-becomes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7390659782848339159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7390659782848339159'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/if-bug-exists-long-enough-it-becomes.html' title='If a bug exists long enough it becomes a feature..'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-6064791809771060824</id><published>2010-06-04T16:09:00.016+02:00</published><updated>2010-06-07T09:02:07.901+02:00</updated><title type='text'>Set-Operations</title><content type='html'>When writing templates it's sometime useful to merge the result of two or more selector expressions and iterate of it. In the older versions there was only one possibility to achieve this, writing your own Java template function. With the new version of actifsource we added three keywords to the selector line syntax. Since the selector line doesn't contain any source code, we don't break the rule of avoiding to mixture of source code and template code.&lt;br /&gt;&lt;br /&gt;The three keywords are "union", "intersect", "except". All three are binary operations operating on lists. Additional to the keywords we allow to use round brackets for changing the evaluation order.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;The &lt;strong&gt;union&lt;/strong&gt; keyword&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The &lt;em&gt;union&lt;/em&gt; keywords merges the result of two selector expressions (m1 union m2) by creating a new list containing all elements of m1 and m2. Since we operate on lists this will preserve the order and allows for duplicate elements. As a result we get one big list first containing all element of the result from m1 followed by all element of the result from m2.&lt;br /&gt;&lt;br /&gt;For example [1, 2, 3, 5, 4] union [2, 4, 3] will result in [1, 2, 3, 5, 4, 2, 4, 3].&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;The &lt;strong&gt;intersect&lt;/strong&gt; keyword&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;The &lt;em&gt;intersect&lt;/em&gt; keyword merges the result of two selector (m1 intersect m2) so that all occurrences of an element in m1 that exceed the occurrence of that element in m2 are removed from m1. This keeps the order as in m1 except for the elements removed.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;For example [1, 2, 3, 5, 2] intersect [1, 3, 3, 2] will result in [1, 2, 3].&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;The &lt;strong&gt;except &lt;/strong&gt;keyword&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;The &lt;em&gt;except&lt;/em&gt; keywords merges the result of two selector expressions (m1 except m2) by removing all element of m2 from the result of m1. Since we operate on lists this will preserve the order and elements contained multiple times in the result of m1 will only removed as often they are contained in m2. &lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;For example [1, 2, 3, 5, 2, 4] except [2, 4, 6, 3] will result in [1, 5, 2].&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;For what can it be used?&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;When traversing the hierarchy or collecting referenced objects it's often recommended to exclude the own element. &lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;As an example I built a simple model with persons. All person can have friends. If you want to collect the friends of all friends, except the person itself and the friends that are known directly, you can use the following expression:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/TAkYge1NRwI/AAAAAAAAAD8/C8FeLDEedas/s1600/exceptUnion.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 189px;" id="BLOGGER_PHOTO_ID_5478937367984031490" alt="" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/TAkYge1NRwI/AAAAAAAAAD8/C8FeLDEedas/s320/exceptUnion.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Or you can collect all friends and include person itself:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/TAkXcJeDnPI/AAAAAAAAAD0/gJoDvwjnTF8/s1600/union.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 189px;" id="BLOGGER_PHOTO_ID_5478936194018680050" alt="" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/TAkXcJeDnPI/AAAAAAAAAD0/gJoDvwjnTF8/s320/union.png" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;With the set operation there are much less situations where you have to write template functions, which makes writing templates much faster and easier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-6064791809771060824?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/6064791809771060824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/set-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6064791809771060824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6064791809771060824'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/set-operations.html' title='Set-Operations'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_NyhaJypG-ZA/TAkYge1NRwI/AAAAAAAAAD8/C8FeLDEedas/s72-c/exceptUnion.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-1143645850163545696</id><published>2010-06-03T10:14:00.003+02:00</published><updated>2010-06-03T10:41:17.700+02:00</updated><title type='text'>Software Modernization through Componentization</title><content type='html'>As David L. Parnas in his article Software Aging stated:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Programs, like people, get old. We can't prevent aging, but we can understand its causes, take steps to limit its effects, temporarily reverse some of the damage it has caused, and prepare for the day when the Software is no longer viable.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;But how to cope with a legacy system? Is it even possible to renovate such a legacy system and if so, how?&lt;br /&gt;&lt;br /&gt;Legacy System are hard to maintain because the systems structure tends to degrade over the years. Furthermore, legacy systems support functions as the structuring element. Today, systems are structured along components which contain functions.&lt;br /&gt;&lt;br /&gt;So what's the idea behind &lt;span style="font-style: italic;"&gt;Software Modernization through Componentization&lt;/span&gt;? The idea is to analyze existing functions of your legacy system and group them together to components. This task is called &lt;span style="font-style: italic;"&gt;Componentization&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;After the &lt;span style="font-style: italic;"&gt;Componentization&lt;/span&gt; you need to analyze the worked out components. Are there any similarities in the component structures and the relationship between components? Any findings of this component analysis process will help you to define the &lt;span style="font-style: italic;"&gt;formal component concept&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Once found an adequate &lt;span style="font-style: italic;"&gt;formal component concept&lt;/span&gt; of your legacy system, you are able to manage your components. Doing so allows you to generate &lt;span style="font-style: italic;"&gt;component interfaces&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;These &lt;span style="font-style: italic;"&gt;component interfaces&lt;/span&gt; allow you to define clear relations between components. They also make it easy to setup new functionality as managing components through a web gui (web enbaling) or providing access through services (SOA enabling).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/TAdqFrkqlXI/AAAAAAAAACw/sfybmvH7XcI/s1600/Software_Modernization.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 262px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/TAdqFrkqlXI/AAAAAAAAACw/sfybmvH7XcI/s400/Software_Modernization.png" alt="" id="BLOGGER_PHOTO_ID_5478464117547898226" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-1143645850163545696?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/1143645850163545696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/06/software-modernization-through.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/1143645850163545696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/1143645850163545696'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/06/software-modernization-through.html' title='Software Modernization through Componentization'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_txlKc91hcCk/TAdqFrkqlXI/AAAAAAAAACw/sfybmvH7XcI/s72-c/Software_Modernization.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-685685463788153196</id><published>2010-05-31T16:50:00.015+02:00</published><updated>2010-05-31T18:57:31.299+02:00</updated><title type='text'>The Java Collection Framework and Immutability</title><content type='html'>&lt;span style="font-size: large;"&gt;... or a story of things that can change &lt;/span&gt;&lt;span style="font-size: large;"&gt;unexpectedly&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Have a look at following implementation. Does it what it claims to do?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /**&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; * Selects and returns those entries of the map whose keys are even.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; * @return a set of all entries in the map with even keys &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public static Set&amp;lt;Entry&amp;lt;Integer, String&amp;gt;&amp;gt; extractEvenKeys(Map&amp;lt;Integer, String&amp;gt; map) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Set&amp;lt;Entry&amp;lt;Integer, String&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; result = new Hash&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Set&amp;lt;Entry&amp;lt;Integer, String&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry&amp;lt;Integer, String&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; entry: map.entrySet()) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isEven(entry.getKey())) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result.add(entry);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; private static boolean isEven(int number) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (number &amp;amp; 1) == 0;&lt;br /&gt;&amp;nbsp; } &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The code iterates over all entries of the map and puts the entries into a result set. Does it always work? Let's test it:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;public static void test() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;Integer, String&amp;gt; map = new HashMap&amp;lt;Integer, String&amp;gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int i=0; i&amp;lt;10; ++i) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.put(i, String.valueOf(i));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set&amp;lt;Entry&amp;lt;Integer, String&amp;gt;&amp;gt; even = extractEvenKeys(map);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(even.size());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(Entry&amp;lt;Integer,String&amp;gt; entry: even) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.print("["+entry.getKey()+","+entry.getValue()+"] ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This gives the following output:&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [14,14] [12,12] [8,8] [6,6] [4,4] [2,2] [0,0] [10,10] [18,18] [16,16]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;We get all ten entries with even keys so the output is correct. The entries have no particular ordering but &lt;/span&gt;we did not say anything about this so this is okay. We used a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.HashMap&lt;/span&gt; for the test but this should work with every correct implementation of the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Map&lt;/span&gt; interface, right? So let's try some other maps:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.LinkedHashMap:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [14,14] [12,12] [8,8] [6,6] [4,4] [2,2] [0,0] [10,10] [18,18] [16,16] &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.TreeMap:&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [14,14] [12,12] [8,8] [6,6] [4,4] [2,2] [0,0] [10,10] [18,18] [16,16]&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.concurrent.ConcurrentHashMap:&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [4,4] [14,14] [2,2] [8,8] [0,0] [6,6] [12,12] [10,10] [16,16] [18,18]&amp;nbsp;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;java.util.IdentityHashMap:&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [9,9] [9,9] [9,9] [9,9] [9,9] [9,9] [9,9] [9,9] [9,9] [9,9] &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Oops! Something went terribly wrong with the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;IdentityHashMap&lt;/span&gt;! We got a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Set&lt;/span&gt; that contains ten times the same entry, and it is actually an entry with an odd key! Is the implementation of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.HashSet&lt;/span&gt; wrong? After all, a set should never contain an element more than once! Or do we have do blame something else?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;What went wrong?&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;Well, as it turns out, we trapped into a documentation hole of the Java Collection Framework. If we look at the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry&lt;/span&gt; interface contained in &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Map&lt;/span&gt; we see a comment that these &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry&lt;/span&gt; objects are only valid as long as the map remains unmodified. What is missing, however, is a documentation how the entry objects can change over time:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Are &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry&lt;/span&gt; objects immutable? No, they have a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;setValue&lt;/span&gt; method so they cannot be.&lt;/li&gt;&lt;li&gt;Do &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry&lt;/span&gt; objects remain unchanged as long the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Map&lt;/span&gt; they belong to remains unchanged? We could think so, but unfortunatley not.&lt;/li&gt;&lt;li&gt;Does &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry.getKey()&lt;/span&gt; change while iterating over the entries? Unfortunately, not even this is specified, so an implementation is free to choose!&lt;/li&gt;&lt;/ul&gt;As it turns out, when iterating over the entries of an &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;IdentityHashMap&lt;/span&gt;, the &lt;b&gt;same&lt;/b&gt; entry object is always returned on &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Iterator.next()&lt;/span&gt;, just the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getKey()&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getValue()&lt;/span&gt; returns a different key and value for each iteration. This also means that &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;equals()&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hashCode()&lt;/span&gt; of the entry object change and the disaster is complete when we try to put the entries into a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;HashSet&lt;/span&gt;: We end up with a set that has ten times the same entry object (remember the same object is returned for each iteration) and after iterating, the key and value of the entry are those of the last iteration!&lt;br /&gt;&lt;br /&gt;All this happend because we misleadingly assumed that the entries' keys would not change. There is a &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6312706"&gt;bug report&lt;/a&gt; which complains about the behaviour of the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;IdentityHashMap&lt;/span&gt;'s entry set. Note that there is the same issue with &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.EnumMap&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Let's fix it &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We cannot change the contract of the interface. So, we have to work around in our implementation. To make our code work with all implementations of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.Map&lt;/span&gt;&amp;nbsp; we have to drop the assumption of immutable entry keys and create new &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Entry&lt;/span&gt; objects for the result set:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public static Set&lt;immutableentry style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;integer, string=""&gt;&amp;lt;Entry&amp;lt;Integer,String&amp;gt;&amp;gt; extractEvenKeys(Map&lt;integer, string=""&gt; map) {&lt;/integer,&gt;&lt;/integer,&gt;&lt;/immutableentry&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set&lt;integer, string=""&gt;&amp;lt;Entry&amp;lt;Integer,String&amp;gt;&amp;gt;&lt;/integer,&gt;&lt;immutableentry&gt;&lt;integer, string=""&gt; result&amp;nbsp;&lt;/integer,&gt;&lt;/immutableentry&gt;&lt;br /&gt;&lt;immutableentry&gt;&lt;integer, string=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = new HashSet&lt;immutableentry&gt;&lt;integer,string&gt;&lt;/integer,string&gt;&lt;/immutableentry&gt;&lt;/integer,&gt;&lt;/immutableentry&gt; &lt;integer, string=""&gt;&amp;lt;Entry&amp;lt;Integer,String&amp;gt;&amp;gt;&lt;/integer,&gt;&lt;immutableentry&gt;&lt;integer, string=""&gt;&lt;immutableentry&gt;&lt;integer,string&gt;();&lt;/integer,string&gt;&lt;/immutableentry&gt;&lt;/integer,&gt;&lt;/immutableentry&gt;&lt;br /&gt;&lt;br /&gt;&lt;immutableentry&gt;&lt;integer, string=""&gt;&lt;immutableentry&gt;&lt;integer,string&gt;&lt;/integer,string&gt;&lt;/immutableentry&gt;&lt;/integer,&gt;&lt;/immutableentry&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(Entry&amp;lt;Integer,String&amp;gt;&lt;integer, string=""&gt; entry: map.entrySet()) {&lt;/integer,&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isEven(entry.getKey())) {&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result.add(new ImmutableEntry&amp;lt;Integer,String&amp;gt;&lt;integer, string=""&gt;(&lt;/integer,&gt;&lt;br /&gt;&lt;integer, string=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entry.getKey(), entry.getValue()));&lt;/integer,&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;whereas we need a custom implementation of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Map.Entry&lt;/span&gt; which we now clearly mark as immutable:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; @Immutable&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; public class ImmutableEntry&lt;k,v&gt; implements Map.Entry&lt;k, v=""&gt;&amp;lt;K,V&amp;amp;gt {&lt;/k,&gt;&lt;/k,v&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private final K key;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private final V value;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public ImmutableEntry(K key, V value) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.key = key;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.value = value;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public K getKey() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return key;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public V getValue() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return value;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public V setValue(V value) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new UnsupportedOperationException();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int hashCode() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ((key == null) ? 0 : key.hashCode()) ^&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((value == null) ? 0 : value.hashCode());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean equals(Object obj) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this == obj) return true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!(obj instanceof Map.Entry&amp;lt;?,?&amp;gt;)) return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map.Entry&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;?,?&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; other = (Map.Entry&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;?,?&amp;gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)obj;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (key == null) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (other.getKey() != null) return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (!key.equals(other.getKey())) return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value == null) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (other.getValue() != null) return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (!value.equals(other.getValue())) return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that I took care to fullfill the contract of the equals and hashcode methods as specified in &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Map.Entry&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;A final remark&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hashCode&lt;/span&gt; method of the entry takes the XOR of the key's and value's hashcode (as required by the documentation of the interface). This can have some serious side effect too: If you -- for whatever reason -- put entries into a map with equal key and value, this means that all these entries will have hashcode zero! Putting these entries into a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;HashSet &lt;/span&gt;will kill your performance as the map degrades to a linked list due to the collisions!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-685685463788153196?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/685685463788153196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/java-collection-framework-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/685685463788153196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/685685463788153196'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/java-collection-framework-and.html' title='The Java Collection Framework and Immutability'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-5296998191975122704</id><published>2010-05-28T13:34:00.015+02:00</published><updated>2010-05-30T14:54:38.039+02:00</updated><title type='text'>Generic Applications</title><content type='html'>&lt;div align="left"&gt;This week I started to implement a new actifsource feature. &lt;span style="font-weight: bold;"&gt;A repository for generic actifsource applications.&lt;/span&gt; The idea behind this is to provide an easy way to &lt;span style="font-style: italic;"&gt;distribute models, frameworks and templates solving common tasks&lt;/span&gt;. We decided to provide a special import wizard, which downloads and installs the application. One challenge was to manage the installation of required features and plugins. Our applications may require &lt;a href="http://findbugs.sourceforge.net/"&gt;findbugs&lt;/a&gt; or other third party tools.&lt;br /&gt;&lt;br /&gt;To solve this issue I decided to manage the information about the features and the updateSiteURIs along which some other information in the repository. This way the wizard can check the current feature list, add missing updateSites und the required dependencies. Since svn does a good job in managing source code, I decided to use the&lt;span style="font-style: italic;"&gt; eclipse team project set&lt;/span&gt; to manage the download and import of the projects into the workspace.&lt;br /&gt;&lt;br /&gt;Since we need a way to define and store additional &lt;span style="font-style: italic;"&gt;dependency information&lt;/span&gt;, I defined a small actifsource model. One big advantage over using a textfile are the resource formfieldeditor and the actifsource validation, which shows you where the application definition is incomplete.&lt;br /&gt;&lt;br /&gt;After this I had to think about from where the generic app import will obtain the data. I decided to implement this as a service. If the service is encapsulated properly the importer doesn't have to care about where the information comes from. Both service data classes, the&lt;span style="font-style: italic;"&gt; service interface&lt;/span&gt; and the&lt;span style="font-style: italic;"&gt; service implementation stub&lt;/span&gt; can be generated by actifsource templates. It is also possible to write the &lt;a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language"&gt;wsdl&lt;/a&gt;. I first started using the eclipse j2ee wizards, but very soon I found out that it is not very convenient doing the updates by hand. I'm sure this is a good case for a generic application.&lt;br /&gt;&lt;br /&gt;Providing templates for building simple java beans (value objects) out of the class defined in actifsource, would be easy. I talked about this in my last post. Using a similar model as shown in the &lt;a href="http://www.actifsource.com/tutorials/actifsource_tutorial_simple_service.html"&gt;Simple Service Tutorial&lt;/a&gt; combined with an enhanced version of the DataClass-Templates will do the job:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The actifsource class&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;p align="left"&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/S__HdVLR20I/AAAAAAAAADU/_HG6_JeoZNc/s1600/jax_dataclass_model.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 244px;" id="BLOGGER_PHOTO_ID_5476314978620398402" alt="" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/S__HdVLR20I/AAAAAAAAADU/_HG6_JeoZNc/s320/jax_dataclass_model.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The new template&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S__Hq6m4iNI/AAAAAAAAADc/d3SyZzjzBCk/s1600/jax_dataclass.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 320px; display: block; height: 236px;" id="BLOGGER_PHOTO_ID_5476315212006590674" alt="" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S__Hq6m4iNI/AAAAAAAAADc/d3SyZzjzBCk/s320/jax_dataclass.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The generated java bean for the use for data transfer&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/S__Hyz9lONI/AAAAAAAAADk/5SrsABxgywk/s1600/jax_dataclass_example.png"&gt;&lt;img style="text-align: center; margin: 0px auto 10px; width: 315px; display: block; height: 320px;" id="BLOGGER_PHOTO_ID_5476315347661699282" alt="" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/S__Hyz9lONI/AAAAAAAAADk/5SrsABxgywk/s320/jax_dataclass_example.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see we often need some kind of data classes in a specific format. It's also possible to generate the service calls and everything else including the setup code of the service client and server. I think this would be really a useful application for the actifsource generic application store, generating the transfer classes for your simple model. I say simple model, because if you have a more complex environment, you probably won't have a 1:1 relationship between your &lt;span style="font-style: italic;"&gt;model classes&lt;/span&gt; and the &lt;span style="font-style: italic;"&gt;data classes&lt;/span&gt;. In this case you will most likely write your own templates doing the transformation/mapping between model and code.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-5296998191975122704?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/5296998191975122704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/generic-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5296998191975122704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/5296998191975122704'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/generic-applications.html' title='Generic Applications'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_NyhaJypG-ZA/S__HdVLR20I/AAAAAAAAADU/_HG6_JeoZNc/s72-c/jax_dataclass_model.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-3316745049297965972</id><published>2010-05-27T17:29:00.003+02:00</published><updated>2010-05-27T17:31:57.917+02:00</updated><title type='text'>Grouping Is Domain Specific Too</title><content type='html'>&lt;span style="font-size: large;"&gt;Complex domains have large models...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As an advanced user of domain-driven modeling you may have experienced that you find yourself soon dealing with a huge set of domain-specific elements: A description of a complex domain can need hundreds of elements. Having all these elements as a flat list is no longer convenient. Fortunately, &lt;a href="http://www.actifsource.com/"&gt;actifsource&lt;/a&gt; lets you group your elements -- which are simply called &lt;i&gt;Resources&lt;/i&gt; in actifsource -- into so-called &lt;i&gt;Packages&lt;/i&gt; (similar to Java packages).&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Packages&lt;/i&gt; enable a simple hierarchical structuring and are currently the all-embracing grouping element:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A &lt;i&gt;Package&lt;/i&gt; can contain &lt;i&gt;Resources &lt;/i&gt;&lt;/li&gt;&lt;li&gt;A &lt;i&gt;Package&lt;/i&gt; can contain nested &lt;i&gt;Packages&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;In the domain meta-model we use &lt;i&gt;Packages&lt;/i&gt; to group our &lt;i&gt;Classes&lt;/i&gt;. &lt;i&gt;Packages&lt;/i&gt; do a perfect job there. However, when the task is to group the domain elements themselves, we found that packages have a problem: The are not domain-specific! Instead of &lt;i&gt;Packages&lt;/i&gt;, it would be desirable to have domain-specific grouping elements... &lt;tt&gt;'FunctionalAreas', 'Epics', 'EntitySpaces&lt;/tt&gt;'&amp;nbsp; are possible names. But this name is always specific to the domain so we cannot choose it universally!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&amp;nbsp;... and need to be grouped domain-specifically!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So, after some discussion, we came to the following idea to solve the problems mentioned above: We need to have a way to define grouping elements on the domain meta-level! All the grouping concepts have something in common:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A &lt;i&gt;grouping element&lt;/i&gt; can contain nested grouping elements of some &lt;i&gt;grouping type&lt;/i&gt;s&lt;/li&gt;&lt;li&gt;A &lt;i&gt;grouping element&lt;/i&gt; can define dependencies to other &lt;i&gt;grouping elements&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;Inside Eclipse, the groupings would still be displayed as folders containing elements. But you could fully customise the folders (icons, decorations, ..). Further, the folder would be validated to contain only the correct element types and the dependencies could be used to narrow the scope of references: Resources contained in a grouping are only allowed to have references to other Resources which are in the scope defined by the dependencies on the grouping!&lt;br /&gt;&lt;br /&gt;So, the current concept of &lt;i&gt;Packages&lt;/i&gt; containing &lt;i&gt;Classes&lt;/i&gt; would be only a realization of the more general grouping concept!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-3316745049297965972?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/3316745049297965972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/grouping-is-domain-specific-as-well.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3316745049297965972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3316745049297965972'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/grouping-is-domain-specific-as-well.html' title='Grouping Is Domain Specific Too'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-2696724589932351564</id><published>2010-05-21T09:42:00.014+02:00</published><updated>2010-05-21T17:26:36.445+02:00</updated><title type='text'>Generating for multiple layers</title><content type='html'>You often need the same structures in different places. You have a data-layer where you need data classes to hold the data, you need a network layer for transportation and you also might have a GUI to display your data. Depending on what you do, you may need to decorate the data with additional information or change its representation. One problem with this is that a new feature must be implemented on all layers to fully support it. With actifsource you can make sure that a feature is handled on all layers and no task gets forgotten. Simply create templates for each layer. Today I want to give you a small example how actifsource can help.&lt;br /&gt;&lt;br /&gt;Lets look at the data layer. I generate really simple data classes, they have a getter, setter and field for the value/reference. For this example I don't care about change notification or null checking:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZI-5HVacI/AAAAAAAAACk/ucc1jwyjmCI/s1600/data_template.png"&gt;&lt;img alt="" id="BLOGGER_PHOTO_ID_5473642642436090306" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZI-5HVacI/AAAAAAAAACk/ucc1jwyjmCI/s320/data_template.png" style="cursor: pointer; display: block; height: 258px; margin: 0px auto 10px; text-align: center; width: 320px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As an example I defined a data class Person in actifsource:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZJkJ5co_I/AAAAAAAAACs/7VQ94qxbuWI/s1600/data_class.png"&gt;&lt;img alt="" id="BLOGGER_PHOTO_ID_5473643282596406258" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZJkJ5co_I/AAAAAAAAACs/7VQ94qxbuWI/s320/data_class.png" style="cursor: pointer; display: block; height: 320px; margin: 0px auto 10px; text-align: center; width: 198px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The template that generates the java class using some helper functions "toJavaType" to translate the actifsource types to java:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZKZK48jSI/AAAAAAAAAC0/WnbPewmr9iU/s1600/data_example.png"&gt;&lt;img alt="" id="BLOGGER_PHOTO_ID_5473644193395805474" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZKZK48jSI/AAAAAAAAAC0/WnbPewmr9iU/s320/data_example.png" style="cursor: pointer; display: block; height: 257px; margin: 0px auto 10px; text-align: center; width: 320px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For the second layer I generate a simple viewer for each data structure. There is no need to define additional information in the model, I just use the same data. For simplicity I don't care about the type of the properties and create a text field for each one. In a real world example you might create components instead of frames and create specific controls for each attribute/relation type.&lt;br /&gt;&lt;br /&gt;The following two screenshots show the viewer template and the output for person:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZL0h5q5WI/AAAAAAAAAC8/EnNcsgxRqaM/s1600/viewer_template.png"&gt;&lt;img alt="" id="BLOGGER_PHOTO_ID_5473645762940953954" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZL0h5q5WI/AAAAAAAAAC8/EnNcsgxRqaM/s320/viewer_template.png" style="cursor: pointer; display: block; height: 257px; margin: 0px auto 10px; text-align: center; width: 320px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/S_ZL7N5lI9I/AAAAAAAAADE/zvOrzCWyDs8/s1600/viewer_example.png"&gt;&lt;img alt="" id="BLOGGER_PHOTO_ID_5473645877830951890" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/S_ZL7N5lI9I/AAAAAAAAADE/zvOrzCWyDs8/s320/viewer_example.png" style="cursor: pointer; display: block; height: 280px; margin: 0px auto 10px; text-align: center; width: 320px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the viewer template I also added a main-method and the createExampleValue-method with a protected region to create an example value to display. The running example looks like this:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZMQT8jRtI/AAAAAAAAADM/1XBz-nrtHHc/s1600/viewer_demo.png"&gt;&lt;img alt="" id="BLOGGER_PHOTO_ID_5473646240231278290" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZMQT8jRtI/AAAAAAAAADM/1XBz-nrtHHc/s320/viewer_demo.png" style="cursor: pointer; display: block; height: 200px; margin: 0px auto 10px; text-align: center; width: 314px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now I have two layers that will updated every time when I change the model. It is ensured that there is always both a text field in the view and a data field in the data class. Think about a third layer: a network layer with the serialization code is stored or different output format implementations. You even might have implementations or clients/servers in different programming languages (c++, c#, java). In all cases actifsource takes care about consistency, no more trouble due to missing fields or different order in the serialization/deserialization code between the different implementations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-2696724589932351564?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/2696724589932351564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/generator-for-multiple-layers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/2696724589932351564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/2696724589932351564'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/generator-for-multiple-layers.html' title='Generating for multiple layers'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_NyhaJypG-ZA/S_ZI-5HVacI/AAAAAAAAACk/ucc1jwyjmCI/s72-c/data_template.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-549720234432235902</id><published>2010-05-20T15:44:00.002+02:00</published><updated>2010-05-20T16:49:17.240+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='hashmap'/><category scheme='http://www.blogger.com/atom/ns#' term='memory'/><title type='text'>Generating HashMaps for Primitives</title><content type='html'>Since long, I have wondered whether it would make a big difference in Java if you use a custom hash map implementation for primitives instead of using e.g. &lt;span style="font-family: courier new;"&gt;java.util.HashMap&lt;integer,float&gt;&lt;/integer,float&gt;&lt;/span&gt; with boxed values. However, as there are 7 primitives (&lt;span style="font-family: courier new;"&gt;byte, char, short, int, long, float, double&lt;/span&gt;) this would mean that there are potentially 49 hash map implementations to be written.&lt;br /&gt;&lt;br /&gt;In the process of testing the upcoming release of actifsource, I used actifsource templates to generate the implementations so that I had to write a single generic implementation only (similar to a c++ or c# template). While not being a typical use case for model- or domain-driven engineering (the model is trivial, the domain is pure technical) it was an interesing test. Unlike the &lt;span style="font-family: courier new;"&gt;HashMap&lt;/span&gt; form java.util, my generated versions store directly primitives instead of boxed objects. I was particular curious what impact this had on the memory footprint and the performance.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;The Model&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As I did not want to measure difference in the hashing algorithm I started with the &lt;span style="font-family: courier new;"&gt;HashMap&lt;/span&gt; implementation. This meant copy and pasting the code of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.util.HashMap&lt;/span&gt; into an empty template. But first, I created this simple model:&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_BTMY3_ZR1Fo/S_U1VWMfz_I/AAAAAAAAAAs/Tg4N6Gd4gYM/s1600/Diagram.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5473339562990227442" src="http://4.bp.blogspot.com/_BTMY3_ZR1Fo/S_U1VWMfz_I/AAAAAAAAAAs/Tg4N6Gd4gYM/s400/Diagram.png" style="cursor: pointer; display: block; height: 237px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;A hash map has a key type and a value type which is an enum of the primitive types. For compatibility with the maps from Java i generated an interface which is similar to these maps, just with primitves in the method signature:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_BTMY3_ZR1Fo/S_U2fB-w3kI/AAAAAAAAAA0/J4C97j0lpBo/s1600/interface.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5473340828874235458" src="http://4.bp.blogspot.com/_BTMY3_ZR1Fo/S_U2fB-w3kI/AAAAAAAAAA0/J4C97j0lpBo/s400/interface.png" style="cursor: pointer; display: block; height: 333px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;Next, in the implementation, I replaced all reference to the generic types &lt;span style="font-family: courier new;"&gt;K&lt;/span&gt; and &lt;span style="font-family: courier new;"&gt;V&lt;/span&gt; by the type from the hash map class, i.e. the expression &lt;span style="font-family: courier new;"&gt;HashMap.valuetype.name&lt;/span&gt; and &lt;span style="font-family: courier new;"&gt;HashMap.keytype.name&lt;/span&gt;. The other thing that I had to change was the handling of &lt;span style="font-family: courier new;"&gt;null&lt;/span&gt; keys and values. As primitives cannot be null the code for handling &lt;span style="font-family: courier new;"&gt;null&lt;/span&gt; could be removed. This also means, that the value 0 gets returned instead of &lt;span style="font-family: courier new;"&gt;null&lt;/span&gt; when a get is made for an non-existing key. Compare the implementations from java.util.HashMap with the implementation in the actifsource template:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_BTMY3_ZR1Fo/S_U4a584oBI/AAAAAAAAAA8/XN8L1bKIbr8/s1600/java_get.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5473342957022650386" src="http://3.bp.blogspot.com/_BTMY3_ZR1Fo/S_U4a584oBI/AAAAAAAAAA8/XN8L1bKIbr8/s400/java_get.png" style="cursor: pointer; display: block; height: 161px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_BTMY3_ZR1Fo/S_U4dC5bZgI/AAAAAAAAABE/wjKWV0EOMkk/s1600/as_get.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5473342993783809538" src="http://3.bp.blogspot.com/_BTMY3_ZR1Fo/S_U4dC5bZgI/AAAAAAAAABE/wjKWV0EOMkk/s400/as_get.png" style="cursor: pointer; display: block; height: 162px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;br /&gt;The algorithm itself remained the same. To calculate the hash value I could no longer relay on &lt;span style="font-family: courier new;"&gt;Object.hashCode()&lt;/span&gt; as the primitives are no objects. Instead, I created a utility class &lt;span style="font-family: courier new;"&gt;HashUtil&lt;/span&gt; which contains an overloaded function &lt;span style="font-family: courier new;"&gt;hashCode&lt;/span&gt; for each primitive type.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Performance Results&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To benchmark the implementation, I filled a map int -&amp;gt; float with 1'000'000 random key/value pairs (put), replaced the value for all the keys once (update), asked once for each key (get) and finally removed all keys (remove). This was repeated 15 times with the first 5 repetitions used as warm-up and taking the average timing over the remaining 10 repetitions. All figures are in milliseconds. I also measured the size of the memory retained by the maps.&lt;br /&gt;&lt;br /&gt;Java HashMap&lt;integer, float=""&gt;:&lt;/integer,&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;put 793&lt;br /&gt;update 428&lt;br /&gt;get 409&lt;br /&gt;remove 432&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;retained size: 108MB (113bytes per entry)&lt;/div&gt;&lt;br /&gt;Generated Int2FloatHashMap: &lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;put 352&lt;br /&gt;update 175&lt;br /&gt;get 87&lt;br /&gt;remove 174&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;retained size: 54.1MB (56.7bytes per entry)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As you can see the generated hash map performed notably better with the get being more than 4 times faster in average! Also, only half as much memory is used.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-549720234432235902?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/549720234432235902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/generating-hashmaps-for-primitives.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/549720234432235902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/549720234432235902'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/generating-hashmaps-for-primitives.html' title='Generating HashMaps for Primitives'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_BTMY3_ZR1Fo/S_U1VWMfz_I/AAAAAAAAAAs/Tg4N6Gd4gYM/s72-c/Diagram.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-3887846506736303909</id><published>2010-05-18T16:30:00.007+02:00</published><updated>2010-05-19T08:13:27.026+02:00</updated><title type='text'>Software Architecture and Components</title><content type='html'>Len Bass defines Software Architecture as follows:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Len Bass: Software Architecture in Practice (2003)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Software architecture of a program or computing System is the structure or structures of the System, which comprise Software components, the externally visible properties of those components and the relationships among them.&lt;br /&gt;&lt;/blockquote&gt;Does this help? Maybe... The above definition tells us, that the architecture of a software system comprises &lt;span style="font-weight: bold;"&gt;components&lt;/span&gt;. Obviously the next question is: &lt;span style="font-weight: bold;"&gt;what are components?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The word component itself is derived from the latin word &lt;i&gt;componens&lt;/i&gt; which means something that is composed of several parts. But composed of what parts?&lt;br /&gt;&lt;br /&gt;Using object-oriented technologies it seems obvious that components implement a specific interface. So far so good. But what about building a component? Is there a building plan or a specification to see how to create a new component?&lt;br /&gt;&lt;br /&gt;In our opinion, the structure of a component is something domain specific. Usually, a complex software system consists of several different &lt;span style="font-weight: bold;"&gt;component types&lt;/span&gt;. A Service Oriented Architecture may specify components of type &lt;span style="font-style: italic;"&gt;Service&lt;/span&gt; and components of type &lt;span style="font-style: italic;"&gt;BusinessObject&lt;/span&gt; and the &lt;span style="font-style: italic;"&gt;relationship between these components&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/S_K_EMOAFOI/AAAAAAAAABw/qHk5L6aR8AM/s1600/SystemComponent.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 210px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/S_K_EMOAFOI/AAAAAAAAABw/qHk5L6aR8AM/s400/SystemComponent.png" alt="" id="BLOGGER_PHOTO_ID_5472646575928906978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;No matter how many Services or BusinessObjects our system will be built of, the &lt;span style="font-weight: bold;"&gt;conceptual component architecture&lt;/span&gt; shows us how components are structured and interconnected.&lt;br /&gt;&lt;br /&gt;As you can imagine, building up new components is following specific rules. Since components are spread over several tiers in complex software systems, we do have to implement several aspects per component: GUI, persistency, business logic, etc.&lt;br /&gt;&lt;br /&gt;Imagine a system where you could define your  &lt;span style="font-weight: bold;"&gt;conceptual component architecture.&lt;/span&gt; And imagine a system, where you could specify &lt;span style="font-weight: bold;"&gt;specific components&lt;/span&gt; according the  &lt;span style="font-weight: bold;"&gt;conceptual &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;component architecture&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;actifsource allows you to specify your &lt;span style="font-weight: bold;"&gt;domain-specific conceptual component architecture.&lt;/span&gt; Doing so, specific components may be entered along your concept.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/S_LCbV2MZzI/AAAAAAAAAB4/tNP2Lo7KfSA/s1600/SpecificComponent.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 280px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/S_LCbV2MZzI/AAAAAAAAAB4/tNP2Lo7KfSA/s400/SpecificComponent.png" alt="" id="BLOGGER_PHOTO_ID_5472650272185280306" border="0" /&gt;&lt;/a&gt;Every element is fully type checked at real time. And of source there is a type-sensitive content assist.&lt;br /&gt;&lt;br /&gt;But the most thrilling thing comes now: &lt;span style="font-weight: bold;"&gt;Since we know exactly how a component is structured, we can provide generic code to build up any specific component.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Due to our specification a &lt;span style="font-weight: bold;"&gt;Service&lt;/span&gt; always comprises &lt;span style="font-weight: bold;"&gt;ServiceCalls&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;while a &lt;span style="font-weight: bold;"&gt;ServiceCall&lt;/span&gt; comprises &lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;. Knowing these conceptual facts, we can write a class for every Service, which contains a method for every ServiceCall.&lt;br /&gt;&lt;br /&gt;But instead of writing a method for every ServiceCall manually we let our computer do the tedious work.&lt;br /&gt;&lt;br /&gt;The next picture shows the actifsource template editor. The orange bar on the left hand side indicates the repetition for every specific ServiceCall.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/S_LH0W8q_MI/AAAAAAAAACA/tM2c3DOl5Ys/s1600/TemplateCode.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 175px;" src="http://4.bp.blogspot.com/_txlKc91hcCk/S_LH0W8q_MI/AAAAAAAAACA/tM2c3DOl5Ys/s400/TemplateCode.png" alt="" id="BLOGGER_PHOTO_ID_5472656199535754434" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;A software system consist of components. Defining the conceptual structure of these components and their relationship allows us to enter well defined and specific components. These component might be checked among their concept.&lt;br /&gt;&lt;br /&gt;Since components are well defined, &lt;span style="font-weight: bold;"&gt;generic code might be written only once for every component type&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Limitations&lt;/span&gt;&lt;br /&gt;Note that the above is only true for the structural aspects of a component. Specific algorithms have to be still coded manually. But 3rd GL like Java, C++, etc. are doing a great job for this kind of work.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;In our experience, a complex software system contains up to 70% of structural component code which can be generated.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-3887846506736303909?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/3887846506736303909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/software-architecture-and-components.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3887846506736303909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3887846506736303909'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/software-architecture-and-components.html' title='Software Architecture and Components'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_txlKc91hcCk/S_K_EMOAFOI/AAAAAAAAABw/qHk5L6aR8AM/s72-c/SystemComponent.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-7279894298136582044</id><published>2010-05-11T09:40:00.006+02:00</published><updated>2010-05-11T10:21:39.814+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Model Driven'/><category scheme='http://www.blogger.com/atom/ns#' term='Refactoring'/><category scheme='http://www.blogger.com/atom/ns#' term='MDA'/><category scheme='http://www.blogger.com/atom/ns#' term='MDSD'/><category scheme='http://www.blogger.com/atom/ns#' term='Software Architecture'/><title type='text'>Feature Code, Infrastructure Code and Refactoring</title><content type='html'>Designing a complex software system means beeing prepared for implementing new features over time. For this reason, the software architecture should describe, how to implement new features.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;The conceptual part of a software architecture contains instructions how to setup the infrastructure code needed to embedded feature code into your existing software.&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Facts on infrastructure code:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Built along a concept&lt;/li&gt;&lt;li&gt;Mostly created by copy/paste/modify of similar infrastructure code&lt;/li&gt;&lt;li&gt;70% of a complex software system is infrastructure code&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;Refactoring of a software system means adopting infrastructure code&lt;/li&gt;&lt;/ul&gt;Refactoring of a software means changing the structure of the system without changing it's functional behavior.&lt;br /&gt;&lt;br /&gt;Wikipedia defines refactoring as follows:&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Code refactoring is the process of changing a computer program's source code without modifying its external functional behavior in order to improve some of the nonfunctional attributes of the software. Advantages include improved code readability  and reduced complexity to improve the maintainability of the source code, as well as a more expressive internal architecture or object model to improve extensibility.&lt;br /&gt;&lt;br /&gt;-- http://en.wikipedia.org/wiki/Refactoring&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;A refactoring just improves the structures of your software system.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Because a refactoring does not change the functional behavior, a refactoring does never add business value to a software system.&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;A refactoring affects infrastructure code, as we stated before. &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Generating the infrastructure code makes it possible to automate the refactoring of a complex software system&lt;/span&gt;.&lt;/blockquote&gt;Actifsource allows you to formalize the conceptual parts of your software architecture and generate all infrastructure code. This allows to generate up to 70% of a complex software system. It allows also to refactor the generated infrastructure code of your software system automatically.&lt;br /&gt;&lt;br /&gt;Stop writing infrastructure code - focus on feature code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-7279894298136582044?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/7279894298136582044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/feature-code-infrastructure-code-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7279894298136582044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7279894298136582044'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/feature-code-infrastructure-code-and.html' title='Feature Code, Infrastructure Code and Refactoring'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-6098371143621926985</id><published>2010-05-07T11:07:00.011+02:00</published><updated>2010-05-07T11:42:54.908+02:00</updated><title type='text'>Generating Wizard Classes</title><content type='html'>Today I give you a short insight into the wizard template. I don’t want to show every detail, but you should see what’s possible. For this blog I assume you already tried our tutorials and you know how to create and register a template.&lt;br /&gt;&lt;br /&gt;Let’s build a simple WizardTemplate, to generate the main class for each wizard.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PYigOtoGI/AAAAAAAAABM/sZ1vEjcuyZI/s1600/empty_template.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PYigOtoGI/AAAAAAAAABM/sZ1vEjcuyZI/s320/empty_template.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468452459836711010" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see this empty template has an error at the filename line. This indicates that we have to define a filename otherwise we won’t get any output. &lt;br /&gt;On the filename we put the WizardClass-Instance-Package and the Name. Since packages are separated by a dot, I used the builtin function “package2subdirectory” to replace the dots by slashes.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/S-PYvkdOEVI/AAAAAAAAABU/E4wdpQjJUso/s1600/fileName.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/S-PYvkdOEVI/AAAAAAAAABU/E4wdpQjJUso/s320/fileName.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468452684309598546" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now let’s generate the signature. Each wizard class should derive from a GeneratedWizard class, which contains non generated methods use by all wizards. I also added a wizardInterface–method to get the eclipse Wizard-Interface (INewWizard, IImportWizard, IExportWizard) from the model.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/S-PY5RakBwI/AAAAAAAAABc/J8E1fsoaVyQ/s1600/class_definition.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/S-PY5RakBwI/AAAAAAAAABc/J8E1fsoaVyQ/s320/class_definition.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468452850996872962" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This will generate a class for each wizard having the wizards name, extends the class GeneratedWizard and implements a specific Wizard-Interface. At the moment this won’t compile, since there is implementation of the abstract methods. Let’s add some more code.&lt;br /&gt;Pressing “ALT+Insert” allows me to add a new linecontext. I want to have a field for each wizardpage, I added a selector to iterate overall pages of the current wizard:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PZEk1Vv4I/AAAAAAAAABk/DEB_eJTp7LA/s1600/page_fields.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PZEk1Vv4I/AAAAAAAAABk/DEB_eJTp7LA/s320/page_fields.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468453045188018050" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you ever wrote a wizard, you know pages are registered by the addPages-Method. The generator should create it and add a line for each wizard page. Since there might some setup code to create the pages, I want a creation method for each page:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_NyhaJypG-ZA/S-PZOmRfFRI/AAAAAAAAABs/qkWtMATKdC8/s1600/addPages.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://3.bp.blogspot.com/_NyhaJypG-ZA/S-PZOmRfFRI/AAAAAAAAABs/qkWtMATKdC8/s320/addPages.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468453217373197586" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For the creation method I add a third context iterating over the pages. Using separate contexts I keep all fields and creation methods together. You might choice another way to group the methods based on your companies coding guidelines:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/S-PZc_fxczI/AAAAAAAAAB0/llfuHAZ9HOE/s1600/createPage_ProtectedRegion.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/S-PZc_fxczI/AAAAAAAAAB0/llfuHAZ9HOE/s320/createPage_ProtectedRegion.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468453464662176562" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I added a protected contexts for the constructor call, so it's possible to change the generated code to pass additional parameters later. The code in the resulting protected region won't be touched by future generator runs. Finally I added a add-Method to register the page:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/S-PbTXmJxsI/AAAAAAAAAB8/NLFhd54LcSk/s1600/createPages_complete.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/S-PbTXmJxsI/AAAAAAAAAB8/NLFhd54LcSk/s320/createPages_complete.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468455498355951298" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Look at the reference to the wizard field, it's the same text. To see that the fieldName is ment, I extract a function using the quick assist (Ctrl+1):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-Pb-vbtk6I/AAAAAAAAACE/mZz22ti1aUI/s1600/Extract_FieldName_Function.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 124px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-Pb-vbtk6I/AAAAAAAAACE/mZz22ti1aUI/s320/Extract_FieldName_Function.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468456243488986018" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Via copy paste I replaced all other occurencies:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PcQhcFZhI/AAAAAAAAACM/ILwUB0ZstQ8/s1600/Extracted_FieldName_and_copy_pasted.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PcQhcFZhI/AAAAAAAAACM/ILwUB0ZstQ8/s320/Extracted_FieldName_and_copy_pasted.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468456548970096146" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Using more information from the model, I get some thing like this:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-Pdimnp1PI/AAAAAAAAACU/tn_k-M5Nx_4/s1600/Some_Further_Work.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S-Pdimnp1PI/AAAAAAAAACU/tn_k-M5Nx_4/s320/Some_Further_Work.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468457959110071538" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see the template is still readable and there are nothing special with one exception, our links to the model. No for-each loops and template keywords between the code.&lt;br /&gt;&lt;br /&gt;The same can be done for each wizard page:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/S-PeS6p3_1I/AAAAAAAAACc/Cbv9oPQAyp0/s1600/Some_Further_Work_Page.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/S-PeS6p3_1I/AAAAAAAAACc/Cbv9oPQAyp0/s320/Some_Further_Work_Page.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5468458789121818450" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The fieldeditor are registered automatically, so you don't have to write the fields, initialize them and finally create each fieldeditor. The logic for creating the GUI-Controls is in the GeneratedWizardPage-SuperClass, it just call the createControl-method on each registed fieldeditor when eclipse request the page control creation. &lt;br /&gt;You might have discovered the line calling the "depencencySetterName", this line creates the binding between the fieldeditors. As I mentioned in the last blogs the binding is used for the package-fieldeditor to only show the packages in resourcefolder selected by the resourcefolder-fieldeditor. This is really smart, you cannot forget to set the bindings, since the model forces you to do define them and the generator does the rest.&lt;br /&gt;&lt;br /&gt;I hope this short insight into the templates help you to understand how actifsource can improve your work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-6098371143621926985?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/6098371143621926985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/generating-wizard-classes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6098371143621926985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6098371143621926985'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/generating-wizard-classes.html' title='Generating Wizard Classes'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_NyhaJypG-ZA/S-PYigOtoGI/AAAAAAAAABM/sZ1vEjcuyZI/s72-c/empty_template.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-7482575513971686260</id><published>2010-05-05T11:08:00.007+02:00</published><updated>2010-05-05T11:54:21.669+02:00</updated><title type='text'>Conceptual and Non-Conceptual Parts of Software-Architecture</title><content type='html'>What is Software-Architecture? Do you have a widely accepted definition? Aksing 10 different people for a definition, you might get 12 different answers.&lt;br /&gt;&lt;br /&gt;In my opinion, Software Architecture can be described as followed:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The software architecture is a directive for the effective and efficient building, understanding and expanding of a software system.&lt;br /&gt;&lt;br /&gt;-- Reto Carrara&lt;br /&gt;&lt;/blockquote&gt;Ok, that's nothing new so far. So let's talk on the nature of an architecture. A software architecture is a directive or kind of a building plan for a software system. There will be decisions on the choosen n-tier model or the third party libs we plan to use. All this information can be implemented 1:1 in code &lt;span style="font-weight: bold;"&gt;and is therefore non-conceptual!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But a software architecture describes also, how features of a domain shall be implemented. &lt;span style="font-weight: bold;"&gt;This kind of information is conceptual!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Defining a &lt;span style="font-style: italic;"&gt;Service Oriented Architecture&lt;/span&gt; for example, you can be sure, there is a &lt;span style="font-weight: bold;"&gt;concept&lt;/span&gt; in your architecture, how to define new &lt;span style="font-style: italic;"&gt;Services&lt;/span&gt;. Specifying a Architecture for &lt;span style="font-style: italic;"&gt;Complex Event Processing&lt;/span&gt; there will be &lt;span style="font-style: italic;"&gt;EventHandlers&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;Events&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;EventSources&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;This conceptual information is one of the most important of our architecture. It tells the developers how to embed new features in the existing structure of the software system.&lt;br /&gt;&lt;br /&gt;The concept how to embed new features in your software helps also, to understand the structure of a complex software systems in the maintenance phase.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Having a concept how to build new features for a complex software system is most important. Only a system that is built on a clear concept can be understood and maintained over time.&lt;br /&gt;&lt;/blockquote&gt; So, what's the problem?&lt;br /&gt;&lt;br /&gt;If one thing is certain in our job: things change - always! Even your basic requirements are subject to change, if your market asks for it.&lt;br /&gt;&lt;br /&gt;One of the &lt;span style="font-style: italic;"&gt;most basic and most important requirements&lt;/span&gt; is therefore:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Software Requirement 1:&lt;br /&gt;Design for Requirements Change!&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;As we have seen: implementing concepts is most important to read and understand our code later on.&lt;br /&gt;&lt;br /&gt;But there is a crux:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Concepts that are implemented many times by their very nature. But concepts that are implemented many times are very hard to change, because every implementation has to be adapted.&lt;br /&gt;&lt;/blockquote&gt;So, we need to have concepts to understand the structure of our software system. But implementing concepts prevent us from changing them. Seems to be an unsolvable problem!&lt;br /&gt;&lt;br /&gt;Not so, if we implement all concepts automatically by generating the code needed.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;actifsource allows you to formalize the &lt;span style="font-style: italic;"&gt;conceptual parts of your software architecture&lt;/span&gt; to generate the &lt;span style="font-style: italic;"&gt;structural feature code&lt;/span&gt;. Doing so, concept changes can be done easily just by regenerating existing implementations.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;In our experience, structural feature code is about 60-70% of the code of a complex software system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Imagine to focus on features, not structural code. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-7482575513971686260?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/7482575513971686260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/05/conceptual-and-non-conceptual-parts-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7482575513971686260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7482575513971686260'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/05/conceptual-and-non-conceptual-parts-of.html' title='Conceptual and Non-Conceptual Parts of Software-Architecture'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-9118770206786142325</id><published>2010-04-30T08:05:00.031+02:00</published><updated>2010-04-30T15:41:49.916+02:00</updated><title type='text'>New Wizards needed more details - The model</title><content type='html'>Last week I talked a little bit about generating wizards with actifsource. I further talked about the model and what things the actifsource code generator will do for you. This week I want to go in some more details and tell you how I started using a Code Generator for implementing the wizards.&lt;br /&gt;&lt;br /&gt;The idea of generating the wizards came up, when Micha had to create new wizards and looked into the other implementations to see how the wizard pages where built there. Since all the wizards where completely handwritten, there was nothing but the coding conventions that restricted us in implementing them. As a result, each wizard does its job a little bit different.&lt;br /&gt;&lt;br /&gt;How is this possible? If you think about your own code you will find out quickly, that if you have to implement the same stuff a half year later or give it to a colleague, it will result in slightly different code. A reason for that is, that writing code always  depends on the experience of the developer, which grows over the years. It comes the time where code style and coding conventions will be changed, but no one will go through the old code to update.&lt;br /&gt;&lt;br /&gt;What can we do against this? One thing is discipline in following company guidelines. But who really remembers all the rules? Some rules are not even written down in a document. Here is where actifsource templates can help. A template defines the structure and limits needed to ensure that things look the same way and ensure that changes will be made in all implementation at the same time.&lt;br /&gt;&lt;br /&gt;Okay, let's start. We have the code mess, we want to get rid of. First, you have to find a meta-model, that is common for all wizards, but still different when writing the wizard classes. All wizards have a title, a description and pages. The title and description is always set in the constructor. Each page must be accessible by the finish-method, thus we need to declare a field of the concrete type for each wizard page. These are things normally done by hand. The information will be stored in the model and the translation of the code structure in the templates.&lt;br /&gt;&lt;br /&gt;After collecting the information, I started creating a new &lt;span style="font-style: italic;"&gt;actifsource resource folder&lt;/span&gt; in the existing wizard project and creates an actifsource class named "Wizard":&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S9qD3HnIHkI/AAAAAAAAAA8/xAVDvJX9DTE/s1600/WizardClass.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 254px; height: 320px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S9qD3HnIHkI/AAAAAAAAAA8/xAVDvJX9DTE/s320/WizardClass.png" alt="" id="BLOGGER_PHOTO_ID_5465826080726720066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The second class I needed was the "WizardPage":&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_NyhaJypG-ZA/S9qDszU8_gI/AAAAAAAAAA0/vD3pFFbaoSA/s1600/WizardPage.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 254px; height: 320px;" src="http://4.bp.blogspot.com/_NyhaJypG-ZA/S9qDszU8_gI/AAAAAAAAAA0/vD3pFFbaoSA/s320/WizardPage.png" alt="" id="BLOGGER_PHOTO_ID_5465825903483092482" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The wizard page, again has a title, a description and an inputfield. The inputfield are the different control to be filled out by the user. There are some more classes but I think you can see where this goes. I don't define the field and methods to be generated in the model, I created a simple description of a wizard.&lt;br /&gt;&lt;br /&gt;The data for each wizard is also stored in the model, for this I created a model instance of the wizard class:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S9qFcb8DdJI/AAAAAAAAABE/gj8sgzW4Gb0/s1600/WizardInstance.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 184px;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S9qFcb8DdJI/AAAAAAAAABE/gj8sgzW4Gb0/s320/WizardInstance.png" alt="" id="BLOGGER_PHOTO_ID_5465827821349991570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see this is a really minimalistic model. &lt;b&gt;That is one of the benefits of using actifsource, the model can change over the time as needed. Actifsource supports iterative and incremential development.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;By the way setting of the dependency between the resourcefolder and packagename is forced by a decorating property. If you are interested how they work, checkout our &lt;a href="http://www.actifsource.com/tutorials/actifsource_tutorial_statemachine.html"&gt;State Machine Tutorial&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The next time I will tell you about how the GUI code is generated by using actifsource templates.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-9118770206786142325?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/9118770206786142325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/new-wizards-needed-more-details-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/9118770206786142325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/9118770206786142325'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/new-wizards-needed-more-details-model.html' title='New Wizards needed more details - The model'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_NyhaJypG-ZA/S9qD3HnIHkI/AAAAAAAAAA8/xAVDvJX9DTE/s72-c/WizardClass.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-9001145822867526018</id><published>2010-04-29T14:53:00.004+02:00</published><updated>2010-04-29T18:34:29.378+02:00</updated><title type='text'>Mapping from Ecore to the Actifsource Core - Part 2</title><content type='html'>&lt;div style="text-align: justify;"&gt;Last week, I wrote about &lt;a href="http://actifsource.blogspot.com/2010/04/mapping-from-ecore-to-actifsource-core.html"&gt;the similarities of ecore and the actifsource core&lt;/a&gt;. This time, I want to tell you about the differences and why they exist.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Elements Missing in Actifsource&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some things that are present in ecore do not have a correspondence in the actifsource core:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Operations&lt;/li&gt;&lt;li&gt;Information which is used only for the serialization of data: volatile, transient, id, resolveProxies, instanceClassName&lt;/li&gt;&lt;li&gt;Factories&lt;/li&gt;&lt;li&gt;Annotations&lt;/li&gt;&lt;li&gt;Derived References and Attributes&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;Why were these things left out in the actifsource core? You will understand this when we look at the purposes of the two meta-models. Quoting from the EMF homepage:&lt;br /&gt;&lt;blockquote&gt;"EMF provides tools and runtime support to &lt;span style="font-weight: bold;"&gt;produce a set of Java classes for the model&lt;/span&gt;, a set of adapter classes that enable viewing and command-based editing of the model, and a basic editor."&lt;/blockquote&gt;So, an ecore model must hold all information to generate a set of java classes which allow reading and writing the model including notifications and serialization. In actifsource however, you model your domain using domain classes. These &lt;a href="http://actifsource.blogspot.com/2010/04/common-classes-vs-domain-specific.html"&gt;domain classes&lt;/a&gt; do &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; directly map to Java classes for editing and serializing the model! Instead, instantiation and editing of your model is done in actifsource itself using the &lt;a href="http://www.actifsource.com/how_it_works/step_2_define_your_domain_model/"&gt;Resource Editor&lt;/a&gt;. Therefore, we do not want any information for mapping to a Java representation in the core itself!&lt;br /&gt;&lt;br /&gt;If you want to map your domain classes to Java (or C, C++, Ruby, Scala..) you make use of &lt;a href="http://www.actifsource.com/how_it_works/step_3_write_your_template_code/index.html"&gt;Generic Code Templates&lt;/a&gt;. Like that, you have full control about every single character of the generated code! This explains why there is no need to have Operations, Factories and mapping information in the actifsource core model.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Annotations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Annotations are a way to attach additional information to any ecore element. There is currently no such thing in actifsource. However, it is possible to create an extension of the actifsource core model and define so-called &lt;span style="font-style: italic;"&gt;Decorators&lt;/span&gt; which add additional information to the elements (actually, any model, not just the core can be extended in this way!). This has the advantage that the for additional information a meta-model can be defined such that they are fully typed as well. Ecore annotations on the other hand are just maps with key-value pairs of strings.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Derived Attibutes and References&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Derived features do not add more information to the model but calculate something based on the ordinary attributes and references. For example, the &lt;span style="font-style: italic;"&gt;eAllAtributes&lt;/span&gt; Reference collects all attributes on a class inculding those defined on its super-classes. Such funtionallity does not really describe the structure of the model but are just helpers. Actifsource has a similar concept: Functions. However, these functions are only used when writing code templates. They allow you to define and use what would be a derived feature in ecore for the purpose of code generation. Each function is associated to a function space which is usually the template. Like that, these functions do not clutter the domain model.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Additional Elements in Actifsource&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some elment of actifsource cannot be mapped to anything in ecore:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Aspects&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some elements of actifsource can implement a so-called &lt;span style="font-style: italic;"&gt;Aspect&lt;/span&gt;. Each aspect has an interface which defines its purpose. Aspects allow to associate elements with functionality (usually implemented as Java class) which is needed for displaying, validating or editing models. For example, there are aspects which further restrict the range of a Relation, validate additinal contraints or add entries to the content-assist in the resource editor.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Sub-Relations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sub-relations restrict a relation which is defined in a base class. Instances of the sub-class can then only realise the restricted association. Surprisingly, you can find such a constellation in the ecore model:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;ETypedElement&lt;/span&gt; has the relation &lt;span style="font-style: italic;"&gt;eType&lt;/span&gt; with target &lt;span style="font-style: italic;"&gt;EClassifier&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;EAttribute&lt;/span&gt; inherits the &lt;span style="font-style: italic;"&gt;eType&lt;/span&gt; relation&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;EAttribute&lt;/span&gt; has the (derived) relation &lt;span style="font-style: italic;"&gt;eAttributeType&lt;/span&gt; with target &lt;span style="font-style: italic;"&gt;EDataType&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;Now, the &lt;span style="font-style: italic;"&gt;eType&lt;/span&gt; of an &lt;span style="font-style: italic;"&gt;EAttribute&lt;/span&gt; should &lt;span style="font-weight: bold;"&gt;never&lt;/span&gt; map to something that is not an &lt;span style="font-style: italic;"&gt;EDataType&lt;/span&gt;! This means that the &lt;span style="font-style: italic;"&gt;eAttributeType&lt;/span&gt; relation is actually a sub-relation of &lt;span style="font-style: italic;"&gt;eType&lt;/span&gt;! Sadly, this information is missing in ecore!&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Decocrating Relations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Deocrating relations can be used to define &lt;a href="http://en.wikipedia.org/wiki/Homomorphism"&gt;Homomorphisms&lt;/a&gt; in your model. I might write about this another time. If you do not want to wait, check out the &lt;a href="http://www.actifsource.com/tutorials/actifsource_tutorial_statemachine.html"&gt;Statemachine Tutorial&lt;/a&gt; where you can find an example of a decorating relation.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-9001145822867526018?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/9001145822867526018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/mapping-from-ecore-to-actifsource-core_29.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/9001145822867526018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/9001145822867526018'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/mapping-from-ecore-to-actifsource-core_29.html' title='Mapping from Ecore to the Actifsource Core - Part 2'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-7198922895199449096</id><published>2010-04-27T09:15:00.011+02:00</published><updated>2010-04-27T15:35:26.463+02:00</updated><title type='text'>On Symbolic Integration</title><content type='html'>Writing Code in a GPL (&lt;a href="http://en.wikipedia.org/wiki/General-purpose_programming_language"&gt;General Purpose Language&lt;/a&gt;), elements are &lt;span style="font-style: italic;"&gt;referenced by name&lt;/span&gt;. Say we do have a Class UserService. If I'd like to instantiate an Object of type UserService, I have to write something like:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;UserService userService = new UserService();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Renaming the Class UserService enforces me to rename:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;All references in the code&lt;/li&gt;&lt;li&gt;All comment where UserService occurs&lt;/li&gt;&lt;li&gt;UML Diagrams&lt;/li&gt;&lt;li&gt;User Documentation&lt;/li&gt;&lt;li&gt;SW Architecture&lt;/li&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;As Martin Fowler states in his groundbreaking Article &lt;a href="http://martinfowler.com/articles/languageWorkbench.html"&gt;Language Workbenches: The Killer-App for Domain Specific Languages?&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;"The second big plus of a language workbench is that you get symbolic integration. The ability to take an excel-like formula language, and just plug it into your own specialized language is pretty nifty. &lt;span style="font-weight: bold;"&gt;As is the ability to change symbols in one language and have those changes ripple through the whole system, which is a plausible thing to consider with a language workbench&lt;/span&gt; (I'm not sure if any of them can do that yet.)"&lt;br /&gt;&lt;br /&gt;-- &lt;a href="http://martinfowler.com/articles/languageWorkbench.html"&gt;Martin Fowler&lt;/a&gt;&lt;br /&gt;&lt;/blockquote&gt;Starting &lt;span style="font-weight: bold;"&gt;actifsource&lt;/span&gt; 5 years ago, we agreed that names can be changed anytime. This tasks becomes even more complex if you want to change names on a conceptual level. Imagine to build up a &lt;span style="font-style: italic;"&gt;Service Infrastructure&lt;/span&gt;. It seems obvious that our &lt;span style="font-style: italic;"&gt;Software Architecture&lt;/span&gt; describes how to implement &lt;span style="font-style: italic;"&gt;Services&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;As it almost ever happens, requirements may change due to market demands. Let's say that the &lt;span style="font-style: italic;"&gt;Service Concept&lt;/span&gt; shall be broaden to a general &lt;span style="font-style: italic;"&gt;Component Concept&lt;/span&gt; and therefore &lt;span style="font-style: italic;"&gt;Services&lt;/span&gt; shall be renamed to &lt;span style="font-style: italic;"&gt;Component&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;If you have done this before in a Larger Scale Software Project, you will agree that renaming conceptual elements is a very hard task. This is because a conceptual name is used widely by its very nature.&lt;br /&gt;&lt;br /&gt;For this reason, we decided that we will never reference any element by its name but by a GUID:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;"A &lt;b&gt;globally unique identifier&lt;/b&gt; or &lt;b&gt;GUID&lt;/b&gt; (pronounced /ˈɡuːɪd/ or &lt;span title="Representation in the International Phonetic Alphabet (IPA)" class="IPA"&gt;/ˈɡwɪd/&lt;/span&gt;) is a special type of identifier used in software applications to provide a unique  reference number. The value is represented as a 32 character hexadecimal  character string, such as {21EC2020-3AEA-1069-A2DD-08002B30309D} and  usually stored as a 128 bit integer."&lt;br /&gt;&lt;br /&gt;-- &lt;a href="http://en.wikipedia.org/wiki/GUID"&gt;wikipedia&lt;/a&gt;&lt;br /&gt;&lt;/blockquote&gt;Using GUIDs instead of names will do the trick: Using &lt;span style="font-weight: bold;"&gt;actifsource&lt;/span&gt;, you are able to rename any element easily. No matter if it has a conceptual or a specific nature.&lt;br /&gt;&lt;br /&gt;Technically, a name is just an attribute, which is identified by its GUID. Renaming an &lt;span style="font-weight: bold;"&gt;actifsource Resource&lt;/span&gt; just means to notify all &lt;a href="http://en.wikipedia.org/wiki/Observer_pattern"&gt;listeners&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;To change names easily, make sure that you always reference you &lt;span style="font-style: italic;"&gt;Domain Model&lt;/span&gt; using the &lt;span style="font-weight: bold;"&gt;actifsource Content Assist&lt;/span&gt; to insert a Model Reference (blue underlined). Even when writing comments.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_txlKc91hcCk/S9ahqZXFh2I/AAAAAAAAABE/kQfGqltKtPQ/s1600/actifsource_writing_comments.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 243px;" src="http://3.bp.blogspot.com/_txlKc91hcCk/S9ahqZXFh2I/AAAAAAAAABE/kQfGqltKtPQ/s400/actifsource_writing_comments.png" alt="" id="BLOGGER_PHOTO_ID_5464732947594970978" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-7198922895199449096?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/7198922895199449096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/on-symbolic-integration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7198922895199449096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/7198922895199449096'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/on-symbolic-integration.html' title='On Symbolic Integration'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_txlKc91hcCk/S9ahqZXFh2I/AAAAAAAAABE/kQfGqltKtPQ/s72-c/actifsource_writing_comments.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-4143689807421882077</id><published>2010-04-23T14:18:00.008+02:00</published><updated>2010-04-29T14:10:28.373+02:00</updated><title type='text'>Designing Large Scale Software Systems for Change</title><content type='html'>Today's software systems are of a complexity we can hardly manage. Even harder than just maintaining a system is adopting the system to new market needs. Changing an existing system is nearly impossible. Let's explore why.&lt;br /&gt;&lt;br /&gt;One of the most important thing for designing a large scale software system is an up-to-date overview of all &lt;span style="font-weight: bold;"&gt;Business Objects&lt;/span&gt; an their relations. For an even deeper understanding, &lt;span style="font-weight: bold;"&gt;Business Objects&lt;/span&gt; need to be categorized by &lt;span style="font-weight: bold;"&gt;Business Classes&lt;/span&gt;. Designing a &lt;span style="font-style: italic;"&gt;Service Oriented Architecture, &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Business Classes &lt;/span&gt;and their relationship might be as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/S9GSbaKxFKI/AAAAAAAAAA0/BQsrOC-x1s8/s1600/00.01+Overview.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 391px; height: 199px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/S9GSbaKxFKI/AAAAAAAAAA0/BQsrOC-x1s8/s400/00.01+Overview.png" alt="" id="BLOGGER_PHOTO_ID_5463308822555727010" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Using conventional programming technique, we have to implement the Business Object using classes. Say we do have 10 different services, we do need at least 10 different classes representing these services.&lt;br /&gt;&lt;br /&gt;Anytime a new service is implemented as a class, the Service Concept gets cemented a little more. Having implemented dozens of services, nobody can even think of touching the underlying concept.&lt;br /&gt;&lt;br /&gt;The problem seems to be easy to understand:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Every concept is a directive how to build some things&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Changing the concept enforces the change of every built thing&lt;/li&gt;&lt;/ul&gt;Having built lots of things already, changing the concept will get more and more expensive.&lt;br /&gt;The basic idea of actifsource is very simple:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Implement every concept only once&lt;/li&gt;&lt;/ul&gt;At a first glance, this sounds impossible. But we can achieve this by providing &lt;span style="font-weight: bold;"&gt;one&lt;/span&gt; generic implementation. The tedious work of implementing the concept over and over again can be let to your computer. That's what machine can do best!&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Every implementation of a concept has to be done only once as a generic implementation&lt;/li&gt;&lt;li&gt;Specific implementations can now be generated &lt;/li&gt;&lt;li&gt;Changing the concepts only leads to the change of one single implementation&lt;/li&gt;&lt;li&gt;Therefore changing concepts becomes cheap&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-4143689807421882077?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/4143689807421882077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/designing-large-scale-software-systems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4143689807421882077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/4143689807421882077'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/designing-large-scale-software-systems.html' title='Designing Large Scale Software Systems for Change'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_txlKc91hcCk/S9GSbaKxFKI/AAAAAAAAAA0/BQsrOC-x1s8/s72-c/00.01+Overview.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-6389187882711367629</id><published>2010-04-23T09:22:00.006+02:00</published><updated>2010-04-23T09:30:39.023+02:00</updated><title type='text'>New wizards needed</title><content type='html'>This week I created two new wizards for importing and exporting the ecore model. If you ever created an eclipse jface wizard you know there are a lot of things to do.&lt;br /&gt;&lt;br /&gt;- Create the wizard class&lt;br /&gt;- Create the wizard page and add them to the wizard&lt;br /&gt;- Initialize the values of the wizard and it’s pages depending on selection&lt;br /&gt;- Implement the code to update status message&lt;br /&gt;- Defining when a page is complete&lt;br /&gt;- Place the wizard page control&lt;br /&gt;- Connect the page controls that depends on each other&lt;br /&gt;- Remembering and Storing the settings from last wizard usages&lt;br /&gt;- Setting the initial focus control&lt;br /&gt;- Defining the perform finish code&lt;br /&gt;&lt;br /&gt;Since these tasks are always the same for all wizards we decided to use our actifsource templates to generate the wizard classes. You may notice that some of the tasks above may be done by super classes. For example we can setup the layout manager, define the page complete state and collect the status messages from the page control interfaces. We also may set the focus to the control containing first undefined value.  But all these tasks don’t require the concrete types of the values. When we come to the initialization, finish and settings management code, we have to start writing a concrete subclass for this wizard and these are the classes we generate. The templates automatically create the fields for accessing the concrete wizard pages, allowing access to the specific getters and setters not on the page interfaces. I also defined the dependencies of page controls in the model. This way the code for connecting the controls with each other is created by the generator. Code that has to be handwritten is placed in protected regions. It’s the code for initializing, storing the settings, updating the status message and performing the finish action, but this time I don’t have to create the things like field for accessing the wizard page and the initialization method for each page.  I’m more or less forced to put the code in the right places.  The structure of each wizard implementation is kept clean.  &lt;br /&gt;&lt;br /&gt;Now all we have to do is to create a wizard instance in the model and define the pages with their control and connect them. Afterwards the generator creates the whole skeleton and we simply have to fill out the gaps. If we decide to rename a wizard all class-, field- and method names coming from the model are changed by the generator. &lt;br /&gt;&lt;br /&gt;Look at the model: &lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_NyhaJypG-ZA/S9FLA3gLF9I/AAAAAAAAAAM/553aqxqE-A4/s1600/WizardModel.png"&gt;&lt;img style="margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_NyhaJypG-ZA/S9FLA3gLF9I/AAAAAAAAAAM/553aqxqE-A4/s320/WizardModel.png" border="0" alt="Wizard Model"id="BLOGGER_PHOTO_ID_5463230301248100306" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I defined a Wizard-Class which contains WizardPages containing inputfields (package-selection, filename-selection, etc.). Each inputfield has a name and uses a fieldeditor (page controls) that may define other fieldeditor as dependency. When the fieldeditor has a dependency you must define a dependency from that to an inputfield to another inputfield using the required fieldeditor. For example I can create a package-field which is restricted based on the selected a resource folder. After defining some name, titles and page descriptions I’m ready to go. Further work that may be done is writing templates for the fieldeditors.&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_NyhaJypG-ZA/S9FLVt3T5bI/AAAAAAAAAAU/1-NPPvRi-fk/s1600/Wizard.png"&gt;&lt;img style="margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_NyhaJypG-ZA/S9FLVt3T5bI/AAAAAAAAAAU/1-NPPvRi-fk/s320/Wizard.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5463230659438044594" /&gt;&lt;/a&gt;&lt;br /&gt;Finally this is one of the generated wizards, each row label, textField and button is a fieldeditor (page control).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-6389187882711367629?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/6389187882711367629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/new-wizards-needed.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6389187882711367629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/6389187882711367629'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/new-wizards-needed.html' title='New wizards needed'/><author><name>Heiko Böttger</name><uri>http://www.blogger.com/profile/16800445213978498191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_NyhaJypG-ZA/S9FLA3gLF9I/AAAAAAAAAAM/553aqxqE-A4/s72-c/WizardModel.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-1055956108861599692</id><published>2010-04-22T14:31:00.001+02:00</published><updated>2010-04-23T11:48:07.203+02:00</updated><title type='text'>Mapping from Ecore to the Actifsource Core (and back)</title><content type='html'>&lt;div style="text-align: justify;"&gt;As I am currently implementing the import of models created with the &lt;a href="http://www.eclipse.org/modeling/emf/?project=emf"&gt;Eclipse Modeling Framework (EMF)&lt;/a&gt; into &lt;a href="http://www.actifsource.com/"&gt;actifsource&lt;/a&gt; I had to think about the mapping from &lt;a style="font-style: italic;" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.5.0/org/eclipse/emf/ecore/package-summary.html#details"&gt;ecore&lt;/a&gt; to the &lt;span style="font-style: italic;"&gt;actifsource core&lt;/span&gt; (the mapping needs to be bidirectional such that actifsource models can be exported to ecore as well) . If you are already acquainted with modeling using EMF this blog posting should help you getting started modeling with actifsource very quickly.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;As both ecore and actifsource core are&lt;span style="font-style: italic;"&gt; self-describing meta-meta models&lt;/span&gt; it is not surprising that in their heart they are very similar. But the naming is a bit different:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;table style="width: 330px; height: 236px;" border="1" cellpadding="0" cellspacing="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th style="text-align: left;"&gt;ecore name&lt;/th&gt;&lt;th style="text-align: left;"&gt;actifsource name&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EPackage&lt;/td&gt;&lt;td&gt;Package&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EObject&lt;/td&gt;&lt;td&gt;Resource&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ENamedElement&lt;/td&gt;&lt;td&gt;NamedResource&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EClass&lt;/td&gt;&lt;td&gt;Class&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EStructuralFeature&lt;/td&gt;&lt;td&gt;Property&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EAttribute&lt;/td&gt;&lt;td&gt;Attribute&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EReference&lt;/td&gt;&lt;td&gt;Relation&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EDataType&lt;/td&gt;&lt;td&gt;Literal&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EEnum&lt;/td&gt;&lt;td&gt;Enum&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;EEnumLiteral&lt;/td&gt;&lt;td&gt;EnumValue&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Visually compared:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_BTMY3_ZR1Fo/S9A--1zLIQI/AAAAAAAAAAk/qd--ALXl-q4/s1600/ecore.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 240px;" src="http://1.bp.blogspot.com/_BTMY3_ZR1Fo/S9A--1zLIQI/AAAAAAAAAAk/qd--ALXl-q4/s400/ecore.png" alt="" id="BLOGGER_PHOTO_ID_5462935597314941186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_BTMY3_ZR1Fo/S9A-38R5t-I/AAAAAAAAAAc/zHKf-Wg8N3M/s1600/acore.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 297px;" src="http://3.bp.blogspot.com/_BTMY3_ZR1Fo/S9A-38R5t-I/AAAAAAAAAAc/zHKf-Wg8N3M/s400/acore.png" alt="" id="BLOGGER_PHOTO_ID_5462935478795352034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;As a first difference you can see that the actifsource diagram contains dotted relations between elements which correspond to an instance relation. Have you ever tried to change the type of an elment in the ecore model editor after you created it? It is not possible because the fact that one elment is a type of another comes implicitly into the ecore model.&lt;br /&gt;&lt;br /&gt;In actifsource however, the fact that one Resource is an &lt;span style="font-style: italic;"&gt;instance&lt;/span&gt; of some other is modeled by the typeOf Relation. Therefore, types of Resources can be changed as easily as any other property of the model. (The typeOf Relation is part of the Class Resource and therefore every Resource has it. That's where the self-describing plays an important role -- which can be rather confusing at first but you do not have to fully understand this to successfully model with actifsource!)&lt;br /&gt;&lt;br /&gt;You might wonder why we did not just use ecore instead of the actifsource core when they look so similar. In the next blog posting I will analyze the differences of ecore and the actifsource core which will show you that the origin of the cores are fundamentally different.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-1055956108861599692?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/1055956108861599692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/mapping-from-ecore-to-actifsource-core.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/1055956108861599692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/1055956108861599692'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/mapping-from-ecore-to-actifsource-core.html' title='Mapping from Ecore to the Actifsource Core (and back)'/><author><name>Micha Riser</name><uri>http://www.blogger.com/profile/05154197551733318608</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_BTMY3_ZR1Fo/S9A--1zLIQI/AAAAAAAAAAk/qd--ALXl-q4/s72-c/ecore.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-718239174094029455</id><published>2010-04-22T13:34:00.013+02:00</published><updated>2010-04-22T20:22:09.774+02:00</updated><title type='text'>Common Classes vs. Domain Specific Classes</title><content type='html'>&lt;span style="font-size:100%;"&gt;Right now, I have had an interesting phone call with a potential customer. Quite important to mention - my conversational  partner has lots of experience using code generators.&lt;br /&gt;&lt;br /&gt;After a 10 minute talk, it came to my mind, that we are talking about different things. My conversational  partner has the idea, that generators are transforming &lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Common Classes&lt;/span&gt;&lt;span style="font-size:100%;"&gt; from a graphical &lt;/span&gt;&lt;span style="font-size:100%;"&gt;representation &lt;/span&gt;&lt;span style="font-size:100%;"&gt;to a textual code representation.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Common Classes&lt;/span&gt;&lt;span style="font-size:100%;"&gt; mean classes as we now them from object-oriented languages or UML. In a nutshell, such classes do have a &lt;span style="font-style: italic;"&gt;class name&lt;/span&gt;, a &lt;span style="font-style: italic;"&gt;base class&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;members variables&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;member functions&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;If we have to represent a &lt;span style="font-weight: bold;"&gt;Domain-Object&lt;/span&gt;, let's say a &lt;span style="font-style: italic;"&gt;Service-Object&lt;/span&gt;, all the properties of this &lt;span style="font-style: italic;"&gt;Service&lt;/span&gt; have to be expressed by &lt;span style="font-style: italic;"&gt;member variables&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;member functions&lt;/span&gt;. When working with &lt;span style="font-weight: bold;"&gt;Common Classes&lt;/span&gt;, it makes no difference whether we implement some &lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;service calls&lt;/span&gt;&lt;span style="font-size:100%;"&gt; or functions to set up the &lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;service environment&lt;/span&gt;&lt;span style="font-size:100%;"&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;class MyUserService implements IService&lt;/span&gt; &lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;{&lt;/span&gt;  &lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;  // Service Calls&lt;/span&gt; &lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;public boolean registerUser(int id, String name) {...}&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;  public boolean deregisterUser(int id) {...}&lt;/span&gt; &lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;public User getUser(int id) {...}&lt;/span&gt;  &lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;br /&gt;// Service Environment&lt;/span&gt; &lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;public boolean setUserRegistry(UserRegistry userRegistry);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; public boolean resetUserRegistry();&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;  &lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;}&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;Using &lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Domain Specific Classes&lt;/span&gt;&lt;span style="font-size:100%;"&gt; on the other hand side, we can distinguish between functions concerning &lt;span style="font-style: italic;"&gt;Service Call&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;Service Environment&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Since we are not working with &lt;span style="font-weight: bold;"&gt;Common Classes&lt;/span&gt;, we first have to design our &lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Domain Specific Classes&lt;/span&gt;&lt;span style="font-size:100%;"&gt;. Means, we have to specify the Attributes (i.e. class name) and the relation between these classes. In actifsource, we do this task in a diagram editor using an UML-like syntax.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_txlKc91hcCk/S9A6TdggWSI/AAAAAAAAAAU/clnXqevYUas/s1600/00.01+Overview.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 163px;" src="http://4.bp.blogspot.com/_txlKc91hcCk/S9A6TdggWSI/AAAAAAAAAAU/clnXqevYUas/s320/00.01+Overview.png" alt="" id="BLOGGER_PHOTO_ID_5462930454013303074" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;Since we do have an exact &lt;span style="font-weight: bold;"&gt;Specification&lt;/span&gt; of our &lt;span style="font-weight: bold;"&gt;Domain Specific Classes&lt;/span&gt;, the &lt;span style="font-weight: bold;"&gt;Domain Objects &lt;/span&gt;are no longer of type Class, but type of the domain-specific class &lt;span style="font-style: italic;"&gt;Service&lt;/span&gt;.&lt;br /&gt;&lt;img src="file:///C:/Projects/actifsource_doc/tutorials/docs/SimpleService/ActifsourceTutorial-SimpleService-Screenshots/00.01%20Overview.png" alt="" /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/S9A6buCM1NI/AAAAAAAAAAc/TWqdq9vYato/s1600/00.02+Overview.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 224px;" src="http://1.bp.blogspot.com/_txlKc91hcCk/S9A6buCM1NI/AAAAAAAAAAc/TWqdq9vYato/s320/00.02+Overview.png" alt="" id="BLOGGER_PHOTO_ID_5462930595888551122" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;As shown above, we can now create dozens of specific services of type Service. As you know from your experience, every specific service has a similar implementation.&lt;br /&gt;&lt;br /&gt;By example, we write a class for every service. Furthermore, we write a function for every service call. Subsequent, we do have do write a typed parameter for every service call argument.&lt;br /&gt;&lt;br /&gt;Today, this tedious and error prone work is done for every service over and over again. But how would it be, if we could state our intension just by writing template code? Template code which doesn't depend on &lt;span style="font-weight: bold;"&gt;Common Classes&lt;/span&gt; - but which refers to &lt;span style="font-weight: bold;"&gt;Domain Specific Classes&lt;/span&gt;!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_txlKc91hcCk/S9A6jD9eIYI/AAAAAAAAAAk/3j0_GT6exYo/s1600/00.03+Overview.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_txlKc91hcCk/S9A6x60MIvI/AAAAAAAAAAs/-8YZrpXsg_E/s1600/00.03+Overview.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 175px;" src="http://2.bp.blogspot.com/_txlKc91hcCk/S9A6x60MIvI/AAAAAAAAAAs/-8YZrpXsg_E/s400/00.03+Overview.png" alt="" id="BLOGGER_PHOTO_ID_5462930977276568306" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;The idea behind actifsource is writing templates, bases on &lt;span style="font-weight: bold;"&gt;Domain Specific Classes&lt;/span&gt;, rather than Common Classes!&lt;span style="font-weight: bold;"&gt; Doing so gives you the possibility to write templates as easy as you write code.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Working with &lt;span style="font-weight: bold;"&gt;Domain Specific Classes&lt;/span&gt; allows you to access all the attributes of your domain in the templates which is rather easier than coping with &lt;span style="font-weight: bold;"&gt;Common Classes&lt;/span&gt;!&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-718239174094029455?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/718239174094029455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/common-classes-vs-domain-specific.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/718239174094029455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/718239174094029455'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/common-classes-vs-domain-specific.html' title='Common Classes vs. Domain Specific Classes'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_txlKc91hcCk/S9A6TdggWSI/AAAAAAAAAAU/clnXqevYUas/s72-c/00.01+Overview.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2550930328775670949.post-3022869461232217269</id><published>2010-04-21T14:25:00.002+02:00</published><updated>2010-04-21T15:07:50.016+02:00</updated><title type='text'>New actifsource Blog</title><content type='html'>actifsource is a state-of-the-art code-generator-workbench that tightly integrates into the popular Eclipse IDE.&lt;br /&gt;&lt;br /&gt;In this blog we write about our everyday life as developers. Follow us to see actifsource grow daily and let us know about new features you need. Get involved: share your thoughts and discuss the merits of model driven software development.&lt;br /&gt;&lt;br /&gt;Check &lt;a href="http://www.actifsource.com"&gt;http://www.actifsource.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2550930328775670949-3022869461232217269?l=actifsource.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://actifsource.blogspot.com/feeds/3022869461232217269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://actifsource.blogspot.com/2010/04/new-actifsource-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3022869461232217269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2550930328775670949/posts/default/3022869461232217269'/><link rel='alternate' type='text/html' href='http://actifsource.blogspot.com/2010/04/new-actifsource-blog.html' title='New actifsource Blog'/><author><name>Reto Carrara</name><uri>http://www.blogger.com/profile/13498751439262288481</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_txlKc91hcCk/S9f9fpngSrI/AAAAAAAAABQ/JCWNOJpKDsk/S220/RetoCarrara.jpg'/></author><thr:total>0</thr:total></entry></feed>
