<?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:blogger='http://schemas.google.com/blogger/2008' 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-8466358959168318018</id><updated>2024-10-03T00:21:12.053+02:00</updated><category term="Java"/><category term="Java 101"/><category term="Java for beginners"/><category term="JavaScript for beginners"/><category term="book"/><category term="clean coder"/><category term="cx"/><category term="dropbox"/><category term="robert c. martin"/><category term="software development"/><category term="storage"/><category term="uncle bob"/><title type='text'>Tom&#39;s Life and Professional Software Development</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-632640686130576183</id><published>2012-06-30T19:32:00.000+02:00</published><updated>2012-06-30T19:32:29.066+02:00</updated><title type='text'></title><content type='html'>Links of the week&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.noop.nl/2012/06/managers-should-not-be-coaching-developers.html&quot;&gt;http://www.noop.nl/2012/06/managers-should-not-be-coaching-developers.html&lt;/a&gt;&lt;br /&gt;
Good hint about what managers should actually manage and what they shouldn&#39;t.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.forbes.com/sites/frederickallen/2012/06/27/inside-the-new-deskless-office/&quot;&gt;http://www.forbes.com/sites/frederickallen/2012/06/27/inside-the-new-deskless-office/&lt;/a&gt;&lt;br /&gt;
Old, but great idea for better office rooms.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.javacodegeeks.com/2012/06/demeter-law.html&quot;&gt;http://www.javacodegeeks.com/2012/06/demeter-law.html&lt;/a&gt;&lt;br /&gt;
A simple, but powerful law. Hopefully well known and widely used :-)&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://css.dzone.com/articles/no-browser-left-behind-html5-0&quot;&gt;http://css.dzone.com/articles/no-browser-left-behind-html5-0&lt;/a&gt;&lt;br /&gt;
Really good article about a cautious switch to HTML 5.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/&quot;&gt;http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/&lt;/a&gt;&lt;br /&gt;
An older article, but I needed it for a different topic, and this article is still excellent, so give it a try, please.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://css.dzone.com/articles/top-10-css3-forms-tutorials&quot;&gt;http://css.dzone.com/articles/top-10-css3-forms-tutorials&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://css.dzone.com/articles/mastering-css3-7-cool-text&quot;&gt;http://css.dzone.com/articles/mastering-css3-7-cool-text&lt;/a&gt;&lt;br /&gt;
Some CSS 3 tutorials and samples.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/632640686130576183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/06/links-of-week-httpwww.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/632640686130576183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/632640686130576183'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/06/links-of-week-httpwww.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-4826740111854856724</id><published>2012-02-04T19:37:00.001+01:00</published><updated>2012-06-30T13:22:30.606+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Java 101"/><category scheme="http://www.blogger.com/atom/ns#" term="Java for beginners"/><title type='text'>Real Story: One of my favorite pieces of code (including advanced tutorial)</title><content type='html'>&amp;lt;sarcasm&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a real piece of code I found some time ago and I a still think, it has some great internal greatness, so I decided to publish some kind of a special tutorial about it:&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:c85e7501-4847-46cf-baf1-f0ee00305fc7&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 194px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt; 1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; falseBoolean( &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; trueValue ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; returnValue &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ( trueValue &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 4&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    returnValue &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 5&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 6&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 7&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    returnValue &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 8&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 9&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; returnValue;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;10&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
One can easily see the advanced mind of the programmer who wrote that exceptional piece of code. &lt;br /&gt;
So why we don&#39;t take the code and analyze the &lt;strong&gt;important Java idioms and rules&lt;/strong&gt; one can find there, and maybe we can also improve it a little bit.&lt;br /&gt;
&lt;br /&gt;
First it is a good idea to &lt;strong&gt;change names&lt;/strong&gt; accordingly: the name of the method variable &#39;trueValue&#39; is probably not so good, because one might think that this variable always contains a true value, or if there are some &#39;wrong variable&#39; somewhere, so I will change this to &#39;value&#39; which is quite neutral.&lt;br /&gt;
&lt;br /&gt;
Also &#39;returnValue&#39; is a little bit long and it might confuse to have all variable names containing &#39;value&#39;, so I change this to the shorter name &#39;result&#39;.&lt;br /&gt;
&lt;br /&gt;
Then there is the idea that variables should be final, what actually means that they are not real variable, but fixed, but let us ignore this tiny point now. &lt;br /&gt;
&lt;br /&gt;
If we change the local variable to final, we are not allowed to assign anything to it in line 2, because otherwise we would not be able to assign a new value to it in lines 4 and 6.&lt;br /&gt;
&lt;br /&gt;
So here is the slightly improved code:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:e7b0fa2f-78a7-4623-a27f-692c93947177&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 194px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt; 1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; falseBoolean( &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; value ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; result;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ( value &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 4&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    result &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 5&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 6&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 7&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    result &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 8&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt; 9&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; result;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;10&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
You see the code confirms to an old rule: &quot;Not more than 1 return statement in a method&quot;. Well, to be quite direct, let me say that I don&#39;t like that rule. It does not make sense for me, because there&amp;nbsp; might be of course some situations where it is OK, to return from a method in the middle of the method. I really think that it depends on the context or on the coding conventions you have to use at your office.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s assume that I can do what I want..., so I will use two return statements here, so that the method is quite shorter. In order to do so, we will remove the local variable.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:a7cdff93-ad5b-447a-bcba-205755a66d1d&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 155px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; falseBoolean( &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; value ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ( value &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;4&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;5&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;6&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;7&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;8&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Another small issue is that I do not like comparisons of the kind &#39;a == true&#39;, where a is a boolean variable. So I change this, too.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:31e17870-3752-4f7a-bbd4-dc493384246e&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 160px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; falseBoolean( &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; value ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ( value ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;4&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;5&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;6&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;7&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;8&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
As I like to use what Java offers, I also like the ternary (conditional) operator. Some people do not like it, because the code might be more difficult to read then, but I think one can use it for short statements, as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:0aec07f0-0c42-4065-bff8-794f29dc406c&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 65px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; falseBoolean( &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; value ) {&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; value &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
I hope, everybody got that last change...&lt;br /&gt;
&lt;br /&gt;
Now we should check how this method is actually called, maybe somehow like as follows (ignoring that it is a static method and should perhaps have the class name before the method name):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:c695b1d1-4a9a-4e69-a856-bdea78fbfeed&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 68px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; dump &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ...;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; garb &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; falseBoolean( dump );&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here &lt;em&gt;dump&lt;/em&gt; gets a boolean value somehow and later the new value is assigned to &lt;em&gt;garb&lt;/em&gt; by calling our optimized method.&lt;br /&gt;
&lt;br /&gt;
As the method is quite short, one might consider inlining the contents of the method. Then one would have:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9D7513F9-C04C-4721-824A-2B34F0212519:1856a0e3-d297-42f5-af79-42a0bf389aad&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;pre style=&quot;background-color: #f3f3f3; height: 68px; overflow: auto; width: 502px;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: teal;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; dump &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ...;&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; garb &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; dump &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Yes, this is it...&lt;br /&gt;
&lt;br /&gt;
This is my final version for all the programmers who have never heard of the &lt;strong&gt;!&lt;/strong&gt; operator.&lt;br /&gt;I thank you for your attention.&lt;br /&gt;
&lt;br /&gt;
In my next post I will show you how to convert a &lt;em&gt;long&lt;/em&gt; value to an &lt;em&gt;int&lt;/em&gt; value. Stay tuned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/sarcasm&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/4826740111854856724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/02/real-story-one-of-my-favorite-pieces-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/4826740111854856724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/4826740111854856724'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/02/real-story-one-of-my-favorite-pieces-of.html' title='Real Story: One of my favorite pieces of code (including advanced tutorial)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-3111455784205891429</id><published>2012-02-01T19:27:00.002+01:00</published><updated>2012-02-01T19:27:55.742+01:00</updated><title type='text'></title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;I don&#39;t like NullPointerExceptions&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Actually I don&#39;t like the message of NullPointer Exceptions, i. e. &quot;&lt;i&gt;null&lt;/i&gt;&quot;. Such a message is usually not very helpful.&lt;br /&gt;
&lt;br /&gt;
I created a few rules for myself how to avoid certain exceptions and actually define pre- and post-conditions for methods. Let me please give you a few examples.&lt;br /&gt;
&lt;br /&gt;
In the beginning of a non-private method I usually check all method arguments.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;public void foo( String x, int a, Person p ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ( x == null ) throw new IllegalArgumentException( &quot;Argument &#39;x&#39; must not be null.&quot; );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ( a &amp;lt; 0 ) throw new IllegalArgumentException( &quot;Argument &#39;a&#39; must not be less than 0.&quot; );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ( p == null ) throw new IllegalArgumentException( &quot;Argument &#39;p&#39; must not be null.&quot; );&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
A few hints:&lt;br /&gt;
&lt;br /&gt;
There are of course libraries which do such checks, i. e. they can check if a String is not null and not empty, and if it contains only &amp;nbsp;white spaces and so on.&lt;br /&gt;
I would recommend to choose one of those libraries and use them intensively.&lt;br /&gt;
Otherwise some checks like in the example might be helpful.&lt;br /&gt;
&lt;br /&gt;
There are also libraries which offer annotations for methods or method arguments to check if the method arguments are valid. Those libraries are great in my opinion, but often companies do not allow the use of some libraries for whatever reasons.&lt;br /&gt;
&lt;br /&gt;
You can create your own Exception type or use an existing one. I have seen very often that developers use IllegalArgumentException, IllegalStateException, or NullPointerException. In the later case with a good error message...&lt;br /&gt;
&lt;br /&gt;
These checks should not only be done in methods, but also in constructors, and whereever it makes sense for you.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
For private methods I use assert statements. Remember assertion checking can be enabled and disabled by the command line options -ea and -da.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;private void gee( Person p ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; assert p != null;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
I usually do not add messages (too much work) to assertions. As we usually compile everything with the debug flag it is easy to find the line where the assertion error happened.&lt;br /&gt;
&lt;br /&gt;
In the if statements from above or in such assert statements I always check only one thing.&lt;br /&gt;
That means that the following code is not OK for me:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;assert p != null &amp;amp;&amp;amp; p.getName() != null &amp;amp;&amp;amp; !list.contains( p );&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I prefer:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;assert p != null;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;assert p.getName();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;assert !list.contains( p );&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before I return a value in a method, I check the value (post-condition) like in:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;public String concat( String a, String b ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;final String result = a + b;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;assert result != null;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return result;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You can also add assert statements to various places within a method like:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;public void addPerson( Person p ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; final int previousSize = list.size();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; list.add( p );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; assert list.size() == previousSize + 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; assert list.contains( p );&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Remember that this code is not included in the class files, if you use the -da option, so there is no performance problem in production software, but those assertions can be great during development to find problems.&lt;br /&gt;
And they are a very good way to document assumptions. That is actually the most important point for me: I like executable documentation...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition I always check a reference before I call a method of if:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;y = x.getName().toUpperCase();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
will become:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;if ( x != null and x.getName() != null ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; y = ...&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
Or one can also use assertions here, that depends on the context.&lt;br /&gt;
&lt;br /&gt;
For me it is not so important which technology is used for all those checks, &lt;b&gt;but that those checks are done at all.&lt;/b&gt;&lt;br /&gt;
I think it is a very important and actually very simple step toward increasing quality of software.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/3111455784205891429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/02/i-dont-like-nullpointerexceptions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/3111455784205891429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/3111455784205891429'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/02/i-dont-like-nullpointerexceptions.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-2289599602737041630</id><published>2012-01-31T10:14:00.000+01:00</published><updated>2012-01-31T10:18:03.749+01:00</updated><title type='text'></title><content type='html'>&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Subversion - We don&#39;t need no stinking trunk!&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Most software developers seem to use a directory called &#39;&lt;i&gt;trunk&lt;/i&gt;&#39; in Subversion. I always wondered what &lt;i&gt;trunk&lt;/i&gt; is good for.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In real life software development in a team of, let&#39;s say, about 20-30 developers some coordination is needed when making a release version.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Often this happens as follows (and I am quite simplifying):&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;All developers commit their stuff to the &lt;i&gt;trunk&lt;/i&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;The trunk is copied to a release branch, e. g. RB-2.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;The new release (with 3) starts on the trunk.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Every developer has to check out the version he needs for further programming, either the trunk for the new release, or the release branch.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Now when a typical developer who is not interested too much in organisational things wants to add an incredibly important, last second change to the release version, he often asks the following question - and I have heard it so often that I decided to write this post:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;i&gt;&quot;Where can I commit my stuff for the current release? On the trunk or...?&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;Usually another developer answers slightly irritated: &lt;i&gt;&quot;On the relase branch, of course, we created it yesterday.&quot; &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;- &lt;i&gt;&quot;Ah, sorry, I missed that somehow.&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;There is a very small idea to improve such a situation (without kicking someone somewhere):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Don&#39;t use the word &#39;trunk&#39; for the &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i&gt;trunk&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;, but give it the name of the release branch.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;So we might have a few SVN directories like RB-1, RB-2, RB-3.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;And everybody knows what stuff goes to which branch.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;I admit, for a good developer this idea might sound strange or ridiculuous, but in real life, you know, not everybody is perfect or takes care of all those coordination issues.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Another good idea would be to jump to a more modern system like GIT:-)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;But that&#39;s a different story.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/2289599602737041630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/01/we-dont-need-no-stinking-trunk-most.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2289599602737041630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2289599602737041630'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2012/01/we-dont-need-no-stinking-trunk-most.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-2967429148250522212</id><published>2011-12-30T20:20:00.000+01:00</published><updated>2011-12-30T20:20:20.090+01:00</updated><title type='text'></title><content type='html'>&lt;b&gt;Java 7 does not work on some older Linux platforms:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
A good hint is&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6538311&quot;&gt;http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6538311&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Just search for the part with&amp;nbsp;&lt;b&gt;system-config-securitylevel&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/2967429148250522212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/12/java-7-does-not-work-on-some-older.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2967429148250522212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2967429148250522212'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/12/java-7-does-not-work-on-some-older.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-507665085467239544</id><published>2011-12-30T17:36:00.003+01:00</published><updated>2011-12-30T17:36:41.476+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cx"/><category scheme="http://www.blogger.com/atom/ns#" term="dropbox"/><category scheme="http://www.blogger.com/atom/ns#" term="storage"/><title type='text'></title><content type='html'>I started to use &lt;a href=&quot;https://www.cx.com/&quot; target=&quot;_blank&quot;&gt;CX.COM&lt;/a&gt;, which is a new online storage like Dropbox.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.cx.com/wp-content/themes/cx/img/cx-logo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://www.cx.com/wp-content/themes/cx/img/cx-logo.png&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;https://www.dropbox.com/static/20995/images/logo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://www.dropbox.com/static/20995/images/logo.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
You can have a FREE account which gives you &lt;b&gt;&lt;span style=&quot;background-color: #ffe599; font-size: large;&quot;&gt;10 GB of FREE storage&lt;/span&gt;&lt;/b&gt; which is twice as much as on Dropbox. The disadvantage: the background synchronization seems to be slower than Dropbox, but I can life with that. I don&#39;t care if it takes 2 or 2.5 days...&lt;br /&gt;
&lt;br /&gt;
I use such free online services (there are many more than mentioned here) for transferring my files between several computers, and for backup of certain, incredibly important files.&lt;br /&gt;
&lt;br /&gt;
I can recommend both :-)&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/507665085467239544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/12/i-started-to-use-cx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/507665085467239544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/507665085467239544'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/12/i-started-to-use-cx.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-241622267326628075</id><published>2011-12-30T16:00:00.000+01:00</published><updated>2011-12-30T16:53:46.101+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="book"/><category scheme="http://www.blogger.com/atom/ns#" term="clean coder"/><category scheme="http://www.blogger.com/atom/ns#" term="robert c. martin"/><category scheme="http://www.blogger.com/atom/ns#" term="software development"/><category scheme="http://www.blogger.com/atom/ns#" term="uncle bob"/><title type='text'>My opinion about &#39;The Clean Coder&#39;</title><content type='html'>There are already several reviews of Robert C. Martin&#39;s book&amp;nbsp;&#39;&lt;b&gt;The Clean Coder&lt;/b&gt;&#39;&amp;nbsp;out there, but I couldn&#39;t resist to write my own comments / thoughts about that book.&lt;br /&gt;
&lt;br /&gt;
It is a &lt;b&gt;very important book&lt;/b&gt; for software developers, even if it does not contain any new ideas at all.&lt;br /&gt;
&lt;br /&gt;
The important point is that Mr. Martin&amp;nbsp;emphasizes &quot;professional&quot; software development, and he wants us to behave and sell ourselves as professionals. That&#39;s quite OK for me, I like that, but I don&#39;t need to read a complete book for figuring this out:-)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mr. Martin touches several topics about so-called professional&amp;nbsp;software development like testing, estimating, collaborating, and so on.&lt;br /&gt;
&lt;br /&gt;
A typical chapter consists of some stories of Mr. Martin&#39;s own experience as a programmer. Those stories usually show what went wrong, so that one can learn from them. After having read so many bad stories I started to wonder, if Mr. Martin ever had a&amp;nbsp;successful&amp;nbsp;software project, but let&#39;s assume so...&lt;br /&gt;
&lt;br /&gt;
Then there are some instructions for developers what to do and what not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you are a &lt;b&gt;not so much experienced&lt;/b&gt; software developer:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Read it, learn it, try it, code it, quote it.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
If you are an &lt;b&gt;experienced&lt;i&gt; &lt;/i&gt;&lt;/b&gt;software developer:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;This book&amp;nbsp;
probably&amp;nbsp;does not help you, it does not contain anything new, just old stuff, extended by unnecessary personal stories by Mr. Martin.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
A ridiculously poor (aka uninformative) appendix mentions some &#39;tools&#39; like&amp;nbsp;continuous&amp;nbsp;integration software.</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/241622267326628075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/06/my-opinion-about-clean-coder.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/241622267326628075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/241622267326628075'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/06/my-opinion-about-clean-coder.html' title='My opinion about &#39;The Clean Coder&#39;'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-6505569783154332614</id><published>2011-12-30T12:49:00.000+01:00</published><updated>2011-12-30T17:02:19.099+01:00</updated><title type='text'>Some hints for calculations with floating point numbers</title><content type='html'>&lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;This is an old posting from 2009 which I am publishing again.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Here are some (slightly simplifying) hints or rules for the usage of BigDecimal.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Use &lt;code&gt;BigDecimal.valueOf(double)&lt;/code&gt; or &lt;code&gt;new BigDecimal(String)&lt;/code&gt; to create BigDecimal objects.&lt;br /&gt;
Never use &lt;code&gt;new BigDecimal(double)&lt;/code&gt;, unless you know what you are doing. Be aware that 0.1 is an infinite decimal number, 0.5 is not, so &lt;code&gt;new BigDecimal(0.5)&lt;/code&gt; is fine, but not &lt;code&gt;new BigDecimal(0.1)&lt;/code&gt;. And if you do not want to think about the difference every time, do not use &lt;code&gt;new BigDecimal(...)&lt;/code&gt; at all.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;If you want to compare BigDecimal objects, be aware: equals() compares the value and the scale, that means 1.001 is not equal to 1.00100. Use signum() and compareTo().&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Use setScale to round the BigDecimal value.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Use a Context for rounding.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Be aware that setScale or a division may throw an ArithmeticException, so always use a RoundingMode or a RoundingContext.&lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;package testdrive;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.math.BigDecimal;

import org.junit.Test;



public class DoubleCalcTest
{

    @Test
    public void addDouble()
    {
        /**
         * This is actually a very old example which shows that calculations with double values can lead to unexpected
         * results.
         */
        double a = 0.1;
        double sum = 0;
        for ( int i = 0; i &amp;lt; 10; i++ )
        {
            sum += a;
        }
        // sum should be 1, but it isn&#39;t
        assertTrue( sum != 1 );
        /**
         * There is no exact binary representation for 0.1, so repeated calculations with 0.1 will probably have wrong
         * results.
         */
    }



    @Test
    public void createBigDecimalCorrectly()
    {
        /**
         * This shows the usage of the static valueOf method. In such a way, a BigDecimal object can be created from a
         * double value. Another possibility is the constructor with the String which is shown here just for fun. I would
         * recommend to always use the static valueOf method.
         */
        BigDecimal a = BigDecimal.valueOf( 0.1 );
        BigDecimal sum = new BigDecimal( &quot;0&quot; ); // Just to show this possibility.
        // OR: BigDecimal sum = BigDecimal.ZERO;

        for ( int i = 0; i &amp;lt; 10; i++ )
        {
            sum = sum.add( a );
        }
        BigDecimal expected = BigDecimal.valueOf( 1.0 );

        /**
         * If the two BigDecimal objects may have different scale, then use signum() and compareTo().
         */
        assertTrue( expected.signum() == sum.signum() );
        assertTrue( expected.compareTo( sum ) == 0 ); // == 0 means, they are equal.
    }



    @Test
    public void createBigDecimalInAWrongWay()
    {
        /**
         * Never use the constructor with double values, unless the binary representation of the double values is what you
         * want. So actually it is better to use the constructor with a String or the static value of method.

         * This example shows the problem with the constructor which has a double as parameter.
         */
        BigDecimal a = new BigDecimal( 0.1 );
        BigDecimal sum = new BigDecimal( 0.0 );
        for ( int i = 0; i &amp;lt; 10; i++ )
        {
            sum = sum.add( a );
        }
        BigDecimal expected = new BigDecimal( 1.0 );

        /**
         * The value of the expected variable (i.e. 1.0) is not the same as the value of the sum variable. The reason is
         * that there is no exact representation of 0.1 in the binary system, so the BigDecimal does not represent 0.1 but
         * something similar.
         */
        assertFalse( expected.equals( sum ) );

        /**
         * If the two BigDecimal objects may have different scale, then use signum() and compareTo().
         */
        assertTrue( expected.signum() == sum.signum() );
        assertTrue( expected.compareTo( sum ) != 0 ); // != 0 means, they are different.

        /**
         * A hint to JUnit:

         * 

         * If you use JUnit, then be aware that assertEquals does use the Number.longValue() method to compare BigDecimal
         * objects, so the result is often wrong. So please use the assertTrue or assertFalse methods.
         */
        assertEquals( expected, sum );
    }

}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: monospace;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/6505569783154332614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/12/some-hints-for-calculations-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/6505569783154332614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/6505569783154332614'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/12/some-hints-for-calculations-with.html' title='Some hints for calculations with floating point numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-2703790301291775357</id><published>2011-07-01T06:36:00.000+02:00</published><updated>2011-07-01T06:36:20.324+02:00</updated><title type='text'></title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWBVC-d01MoOSaGYdP40ApiEZqWccGJ4rvwCDL3gavBhj857SPnuy4B2QORrQZmyWKDtQDZfN-LzkpQxj39Dma9S-w1vTDWC1FBFSYMnWQjL_jQUyQYv8dIY-mntTZtEDtixEHj7a-t_8D/s1600/110704_cartoon_049_a15852_p465.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;287&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWBVC-d01MoOSaGYdP40ApiEZqWccGJ4rvwCDL3gavBhj857SPnuy4B2QORrQZmyWKDtQDZfN-LzkpQxj39Dma9S-w1vTDWC1FBFSYMnWQjL_jQUyQYv8dIY-mntTZtEDtixEHj7a-t_8D/s320/110704_cartoon_049_a15852_p465.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.newyorker.com/humor/issuecartoons/2011/07/04/cartoons_20110627#slide=9&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: xx-small;&quot;&gt;The New Yorker&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/2703790301291775357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/07/new-yorker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2703790301291775357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2703790301291775357'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/07/new-yorker.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWBVC-d01MoOSaGYdP40ApiEZqWccGJ4rvwCDL3gavBhj857SPnuy4B2QORrQZmyWKDtQDZfN-LzkpQxj39Dma9S-w1vTDWC1FBFSYMnWQjL_jQUyQYv8dIY-mntTZtEDtixEHj7a-t_8D/s72-c/110704_cartoon_049_a15852_p465.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-3238636841046837326</id><published>2011-06-29T19:11:00.000+02:00</published><updated>2011-06-29T19:11:24.400+02:00</updated><title type='text'>The Cutter Blog » Blog Archive » The Truth About Technology Management</title><content type='html'>&lt;div&gt;Interesting read: &quot;IT doesn’t work if you’re surrounded by bad people and stupid processes immersed in a deranged corporate culture.&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href=&quot;http://blog.cutter.com/2011/04/05/the-truth-about-technology-management/&quot;&gt;The Cutter Blog » Blog Archive » The Truth About Technology Management&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/3238636841046837326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/06/cutter-blog-blog-archive-truth-about.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/3238636841046837326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/3238636841046837326'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/06/cutter-blog-blog-archive-truth-about.html' title='The Cutter Blog » Blog Archive » The Truth About Technology Management'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-7432226654163773686</id><published>2011-05-13T23:19:00.000+02:00</published><updated>2011-05-13T23:19:00.221+02:00</updated><title type='text'>I became digitally distinct</title><content type='html'>I checked my online visibility on&amp;nbsp;&lt;a href=&quot;http://www.onlineidcalculator.com/&quot;&gt;www.onlineidcalculator.com&lt;/a&gt;, here is the result:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.onlineidcalculator.com/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img src=&quot;http://www.onlineidcalculator.com/img/digitally-distinct_badge120px.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Try it, it&#39;s nice :-)&lt;br /&gt;
&lt;br /&gt;
.</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/7432226654163773686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/05/i-became-digitally-distinct.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/7432226654163773686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/7432226654163773686'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/05/i-became-digitally-distinct.html' title='I became digitally distinct'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-2189466899732116154</id><published>2011-04-13T18:24:00.001+02:00</published><updated>2011-04-13T18:38:11.609+02:00</updated><title type='text'>JSR-346 for new CDI 1.1</title><content type='html'>There is a new Java Specification Request (JSR) with number 346: Contexts and Dependency Injection for JavaTM EE 1.1.&lt;br /&gt;
It contains improvements for CDI&amp;nbsp; 1.0, and is lead by Red Hat.&lt;br /&gt;
&lt;br /&gt;
CDI might be the most helpful new piece  of technology in Java EE 6. If you haven&#39;t heard of it or didn&#39;t use it before, then try &lt;a href=&quot;http://www.oracle.com/technetwork/articles/java/cdi-javaee-bien-225152.html&quot;&gt;Adam Bien&#39;s articles&lt;/a&gt; or the &lt;a href=&quot;http://docs.jboss.org/weld/reference/1.0.0/en-US/html/&quot;&gt;documentation of CDI&#39;s reference implementation&lt;/a&gt;, called Weld, which is actuaaly quite easy to read.&lt;br /&gt;
&lt;br /&gt;
So what are the suggestions for CDI 1.1? Let&#39;s look what the JSR says:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&quot;Global ordering of interceptors and decorators, as well as global enablement of alternatives [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-48&quot;&gt;CDI-48&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;An API for managing built in contexts, allowing the built in implementation of the conversation context to be used outside of JSF [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-30&quot;&gt;CDI-30&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;An embedded mode allowing startup outside of a Java EE container [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-26&quot;&gt;CDI-26&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Declarative control over which packages/classes are scanned in a bean archive [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-87&quot;&gt;CDI-87&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Bean declaration at constructor level [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-55&quot;&gt;CDI-55&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Static injection [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-51&quot;&gt;CDI-51&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Inclusion of @Unwraps from Seam Solder [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-89&quot;&gt;CDI-89&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Align with current version of @Inject [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-51&quot;&gt;CDI-51&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Numerous minor enhancements to the Portable Extensions SPI&lt;/li&gt;
&lt;li&gt;Client controlled contexts allowing for SaaS style multi-tennancy [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-103&quot;&gt;CDI-103&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Better support for CDI in libraries when used in the Java EE platform [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-84&quot;&gt;CDI-84&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Send CDI events for Servlet events [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-38&quot;&gt;CDI-38&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Application lifecycle events [&lt;a href=&quot;https://issues.jboss.org/browse/CDI-86&quot;&gt;CDI-86&lt;/a&gt;]&quot;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The final release of CDI 1.1 is currently scheduled for Q3 2012.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2189466899732116154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2189466899732116154'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/04/jsr-346-for-new-cdi-11.html' title='JSR-346 for new CDI 1.1'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-4312596590451633243</id><published>2011-04-07T08:51:00.003+02:00</published><updated>2011-05-06T20:08:58.302+02:00</updated><title type='text'>NMO</title><content type='html'>Today 6 months ago - on 2010-10-07 - I got a bad disease called &lt;i&gt;neuromyelitis optica&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
It nearly killed me within the first hours, but some good people in the hospital saved my life. I was lucky, because I was in a hospital at that time (for some other reasons).&lt;br /&gt;
&lt;br /&gt;
I spent a month in the intensive care unit of the hospial, sleeping a lot, dreaming bad dreams, and fighting for my life.&lt;br /&gt;
&lt;br /&gt;
Then I spent two long months in the monitoring station, struggeling with my blood circuit and other things. After another month in a regular station, I finally moved to the rehabilation center called Weisser Hof.&lt;br /&gt;
&lt;br /&gt;
I cannot feel and move my legs anymore, so I am learning to use a wheel chair.&lt;br /&gt;
&lt;br /&gt;
My body becomes stronger now, and I feel more energy, so I try to come back to a regular life.&lt;br /&gt;
&lt;br /&gt;
.</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/4312596590451633243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/04/nmo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/4312596590451633243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/4312596590451633243'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2011/04/nmo.html' title='NMO'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-7587005223599653425</id><published>2010-01-17T12:02:00.002+01:00</published><updated>2010-01-17T12:06:10.168+01:00</updated><title type='text'>How to change the Maven directory structure for compatibility with MyEclipse web projects</title><content type='html'>In order to change the default Maven directory structure to the typical structure of MyEclipse web projects change the Maven configuration file (pom.xml) like follows:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;lt;build&gt;&lt;br /&gt;
&lt;blockquote&gt;&amp;lt;sourcedirectory&gt;${basedir}/src&amp;lt;/sourcedirectory&gt;&lt;br /&gt;
&amp;lt;outputdirectory&gt;${basedir}/WebRoot/WEB-INF/classes&amp;lt;/outputdirectory&gt;&lt;br /&gt;
&lt;/blockquote&gt;&amp;lt;resources&gt;&lt;br /&gt;
&lt;blockquote&gt;&amp;lt;resource&gt;&lt;br /&gt;
&lt;blockquote&gt;&amp;lt;directory&gt;${basedir}/src&amp;lt;/directory&gt;&lt;br /&gt;
&amp;lt;excludes&gt;&lt;br /&gt;
&amp;lt;exclude&gt;**/*.java&amp;lt;/exclude&gt;&lt;br /&gt;
&amp;lt;/excludes&gt;&lt;br /&gt;
&lt;/blockquote&gt;&amp;lt;/resource&gt;&lt;br /&gt;
&lt;/blockquote&gt;&amp;lt;/resources&gt;&lt;br /&gt;
&amp;lt;plugins&gt;&lt;br /&gt;
&lt;blockquote&gt;&amp;lt;plugin&gt;&lt;br /&gt;
&lt;blockquote&gt;&amp;lt;artifactid&gt;maven-war-plugin&amp;lt;/artifactid&gt;&lt;br /&gt;
&amp;lt;configuration&gt;&lt;br /&gt;
&amp;lt;webappdirectory&gt;${basedir}/WebRoot&amp;lt;/webappdirectory&gt;&lt;br /&gt;
&amp;lt;warsourcedirectory&gt;${basedir}/WebRoot&amp;lt;/warsourcedirectory&gt;&lt;br /&gt;
&amp;lt;/configuration&gt;&lt;br /&gt;
&lt;/blockquote&gt;&amp;lt;/plugin&gt;&lt;br /&gt;
&lt;/blockquote&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This does not take into account special resources directories, but they can easily be added by the resources element.</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/7587005223599653425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2010/01/maven-configuration-of-web-projects-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/7587005223599653425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/7587005223599653425'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2010/01/maven-configuration-of-web-projects-for.html' title='How to change the Maven directory structure for compatibility with MyEclipse web projects'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-6410482308266040022</id><published>2009-08-23T17:36:00.004+02:00</published><updated>2009-08-23T18:46:05.959+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript for beginners"/><title type='text'>JavaScript: Introduction to closures</title><content type='html'>&lt;p&gt;&lt;em&gt;This is an introduction to closures in JavaScript. It is intended for JavaScript beginners and belongs to a small series of (future) blogs for JavaScript beginners.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Closures are an important concept in modern programming languages, and one should be able to understand and use them well.&lt;/p&gt;&lt;p&gt;Closures are functions which reference (i.e. use) variables that are defined outside of those functions. This is not an exact definition, but it will help for the following examples.&lt;/p&gt;&lt;p&gt;In JavaScript, closures are usually realized as functions which are defined of other functions.&lt;/p&gt;&lt;p&gt;Have a look at the following code:&lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 422px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 214px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:   &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; gee() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; 1;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; gee();
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo() );&lt;/pre&gt;&lt;/pre&gt;&lt;p&gt;The function foo contains an inner function gee. The ability of a function to have inner functions is an interesting point. In other languages like in Java that is not possible. gee is our first closure here.&lt;/p&gt;&lt;p&gt;The function – or the closure - gee returns the number 1, and the method foo returns the value, that gee returns, i.e. 1. So far nothing special…&lt;/p&gt;&lt;p&gt;By the way, the print method at the bottom of the code, is a method of the Aptana JavaScript library. &lt;a href=&quot;http://www.aptana.com/studio&quot; target=&quot;_blank&quot;&gt;You can download the Aptana Studio here.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The output of the code above is&lt;/p&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;1&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Now check this code: &lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 423px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 261px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:   &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; a = 2;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5:   &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; gee() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 87.35%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; height: 20px; background-color: #ffffff&quot;&gt;6:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; a;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; gee();
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;11: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;12: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo() );&lt;/pre&gt;&lt;/pre&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;2&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;This time the method gee uses a variable which has been defined outside of gee, but inside of foo. This is an important feature. The variable a is not a global variable, because it has been defined by using the keyword “var”, but the scope of visibility of this variable contains everything inside of the foo method, and sowith the function gee.&lt;/p&gt;&lt;p&gt;Please keep in mind that from within an function which is defined inside of another function, all variables which are defined in the outer function can be used.&lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 425px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 303px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:   &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; a = 2;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5:   &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; gee() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; a;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9:   a = 10;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;11:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; gee();
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;12: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;13: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;14: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo() );&lt;/pre&gt;&lt;/pre&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;10&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;This time the variable a is defined, then gee, then the value of a is changed. What happens here, is that gee gets a reference to the variable a, so the value 2 is not copied somehow within the function definition of gee (then 2 would be printed), but gee gets a reference to the variable a, so 10 is printed.&lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 433px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 463px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:   &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; a = 2;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5:   &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; gee() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6:     
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7:     &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; b = 3;  
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8:     
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9:     &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; hii() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10:       &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; a * b;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;11:     }    
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;12:     
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;13:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; hii();
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;14:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;15:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;16:   a = 10;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;17:   
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;18:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; gee();
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;19: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;20: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;21: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo() );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;22: &lt;/pre&gt;&lt;/pre&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;30&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Now we have three functions which are somehow combined. The same principles as above work now, so the function foo and therefore hii return 3 times 10.&lt;/p&gt;&lt;iframe src=&quot;http://rcm-de.amazon.de/e/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFE81A&amp;fc1=000000&amp;lc1=0000FF&amp;t=javaforum-21&amp;o=3&amp;p=8&amp;l=as1&amp;m=amazon&amp;f=ifr&amp;asins=193398869X&quot; style=&quot;width:120px;height:240px;&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;p&gt;The following example shows that an inner function can also access the parameters of the outer function.&lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 432px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 172px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo( a ) {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;() {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; a * 2;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo(1) );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo(1)() );&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;And one can see that foo(1) returns what comes after the return statement, i.e. the anonymous, inner function. As it is common in JavaScript, the toString method of a function returns the source code of that function. And as foo(1) is a function, we can call this function by adding (), so that we have foo(1)(), which generates the output “2”.&lt;/p&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;        &lt;p&gt;function () { &lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; return a * 2;           &lt;br /&gt;
}           &lt;br /&gt;
2&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Now we have two inner functions (or closures), so that we can call the inner-most function with three parentheses: foo(1)()(). That means, 1 is given to a, then the first inner function is called which has a local variable b, and finally the inner-most function is called which returns the result 6. &lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 423px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 277px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo( a ) {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(){
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:     &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; b = 3;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(){
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5:       &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; a * 2 * b;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6:     };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo(1)()() );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;11: &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; f = foo(1);
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;12: &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; g = f();
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;13: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( g() );&lt;/pre&gt;&lt;/pre&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;6         &lt;br /&gt;
6&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;One can also see that one can assign a function to a variable, like f, then call the function by f(), and assign this to a variable, like g, which then can be called by g() - nothing very complicated, just a little bit unusual for people who come from other languages like Java.&lt;/p&gt;&lt;p&gt;The following code example shows a function foo which returns a closure. That closure is again returned to a variable with a more meaningful name as in the examples above. &lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 427px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 275px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; foo( a ) {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;( b ) {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; a * b;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:   };
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( foo(2)(5) );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9: &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; doubleIt = foo(2);
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;11: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( doubleIt( 1 ) );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;12: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( doubleIt( 2 ) );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;13: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( doubleIt( 3 ) );&lt;/pre&gt;&lt;/pre&gt;&lt;p&gt;This example returns the following numbers, i.e. twice the value of the input.&lt;/p&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;2&amp;#160; &lt;br /&gt;
4         &lt;br /&gt;
6&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;The interesting point is that one can give the closure foo(2) a new and more meaningful name, so that doubleIt seems to be like a new function which can used in the program later.&lt;/p&gt;&lt;p&gt;It is like converting a given API to something more specific and more useful in the current application or the current context.&lt;/p&gt;&lt;p&gt;The following example shows this again with a function that simply calculates the sum of two numbers, but implemented by a closure. &lt;/p&gt;&lt;pre style=&quot;border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 428px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 272px; background-color: #fbfbfb&quot;&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;1: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; add( summand1 ) {  
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;2:   &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;( summand2 ) {
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;3:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; summand1 + summand2;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;4:   }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;5: }
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;6: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;7: &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; threeAnd = add( 3 );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;8: &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; fourAnd  = add( 4 );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;9: &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; fiveAnd  = add( 5 );
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;10: 
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;11: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( threeAnd( 2 ) ); &lt;span style=&quot;color: #008000&quot;&gt;// 5&lt;/span&gt;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;12: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( fourAnd(  2 ) ); &lt;span style=&quot;color: #008000&quot;&gt;// 6&lt;/span&gt;
&lt;/pre&gt;&lt;pre style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb&quot;&gt;13: &lt;span style=&quot;color: #0000ff&quot;&gt;print&lt;/span&gt;( fiveAnd(  2 ) ); &lt;span style=&quot;color: #008000&quot;&gt;// 7&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;p&gt;The output is of course: &lt;/p&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; bgcolor=&quot;#ffffcc&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;5         &lt;br /&gt;
6         &lt;br /&gt;
7&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;The three closures have meaningful names which say what the closure is going to do. In such a way you can easily create new &quot;functions&quot; based on already existing functions or closures.&lt;/p&gt;&lt;iframe src=&quot;http://rcm-de.amazon.de/e/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=F3FD00&amp;fc1=000000&amp;lc1=0000FF&amp;t=javaforum-21&amp;o=3&amp;p=8&amp;l=as1&amp;m=amazon&amp;f=ifr&amp;asins=3836213974&quot; style=&quot;width:120px;height:240px;&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:d7bf807d-7bb0-458a-811f-90c51817d5c2:be5fac34-8ec2-4bf1-98a4-7cf933b02ad3&quot; style=&quot;padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px&quot;&gt;&lt;p&gt;&lt;span class=&quot;TagSite&quot;&gt;Technorati:&lt;/span&gt; &lt;a href=&quot;http://technorati.com/tag/javascript&quot; rel=&quot;tag&quot; class=&quot;tag&quot;&gt;javascript&lt;/a&gt;, &lt;a href=&quot;http://technorati.com/tag/closure&quot; rel=&quot;tag&quot; class=&quot;tag&quot;&gt;closure&lt;/a&gt;, &lt;a href=&quot;http://technorati.com/tag/closures&quot; rel=&quot;tag&quot; class=&quot;tag&quot;&gt;closures&lt;/a&gt;&lt;br /&gt;
&lt;!-- StartInsertedTags: javascript,closure,closures :EndInsertedTags --&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/6410482308266040022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/08/javascript-introduction-to-closures.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/6410482308266040022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/6410482308266040022'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/08/javascript-introduction-to-closures.html' title='JavaScript: Introduction to closures'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-5166483819341552228</id><published>2009-08-13T18:58:00.008+02:00</published><updated>2009-08-15T20:18:26.589+02:00</updated><title type='text'>Java: char to int</title><content type='html'>&lt;p&gt;Today I found some code (in a current project of a company), where they convert a Java char to an int like this: &lt;/p&gt; &lt;span style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; x = Integer.parseInt( String.valueOf( c ) ); &lt;/span&gt;  &lt;br /&gt;  &lt;br /&gt;where c is a char like &#39;0&#39;, &#39;1&#39;, ... (i.e. a digit as a char).  &lt;br /&gt;  &lt;br /&gt;I would suggest to make a conversion like:  &lt;br /&gt;  &lt;br /&gt;&lt;span style=&quot;font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; x = c - &#39;0&#39;;&lt;/span&gt;  &lt;br /&gt;  &lt;br /&gt;That&#39;s easier and probably faster...    </content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/5166483819341552228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/08/java-char-to-int.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/5166483819341552228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/5166483819341552228'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/08/java-char-to-int.html' title='Java: char to int'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-5381715807575952889</id><published>2009-06-30T06:29:00.003+02:00</published><updated>2009-06-30T06:33:41.033+02:00</updated><title type='text'>Top 200 blogs for developers</title><content type='html'>&lt;strong&gt;&lt;/strong&gt;Jurgen Appelo published on this blog a list of the top 200 blogs for software developers.&lt;br /&gt;This is a good and helpful list, I&#39;m going through it, making bookmarks, checking what would be helpful for me.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.noop.nl/2009/06/top-200-blogs-for-developers-q2-2009.html&quot; target=&quot;_blank&quot;&gt;http://www.noop.nl/2009/06/top-200-blogs-for-developers-q2-2009.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/5381715807575952889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/06/jurgen-appelo-published-on-this-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/5381715807575952889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/5381715807575952889'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/06/jurgen-appelo-published-on-this-blog.html' title='Top 200 blogs for developers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-2197870159308628040</id><published>2009-06-30T06:15:00.008+02:00</published><updated>2009-06-30T22:10:38.003+02:00</updated><title type='text'>My love from Iran</title><content type='html'>In a few hours I&#39;m going to pick up the parents of my girl-friend from the airport.&lt;br /&gt;My girl-friend is originally from Iran. She came to Austria when she was 18 years old. She came here alone, learnt German for one year, and then studied Information Technologies. I think that was a very hard and brave action. And it must have been some kind of a culture shock.&lt;br /&gt;&lt;br /&gt;Today, after so many years, it is the first time that her parents come to Austria.&lt;br /&gt;It was not so easy to invite them. I did not know about it, but it is quite difficult here in Austria to invite people from certain other countries, so that they are allowed to see Austria for a while. Actually the austrian embassy in Iran has to give the allowance to visitors, but they said no to the parents for my girl-friend. As I heard, the current people in the embassy suck a lot, so we thought we would have no chance, but my girl-friend called the Austrian ministry of foreign affairs and started to make a complaint. Suddenly, on the next day, the embassy called my girl-friend&#39;s parents and told them that they may go to Austria. So much about making complaints, sometimes they help.&lt;br /&gt;&lt;br /&gt;For me my life changed very much because of my girl-friend. She is from another culture, and she sees many things in a different way than I do. And I learnt a lot about Iran.&lt;br /&gt;&lt;br /&gt;Some time ago, I had thought that most people in Iran were muslims and convinced of their religion and some kind of fanatic. Then I was invited by so many iranian people living here in Austria, so that I had the chance to learn more.&lt;br /&gt;First of all there seem to be two worlds in Iran: the official one of the government and the islam, and then the private one. One can see it on the photos. When women are walking on the streets, they have headscarfs, when they are in the house, maybe on a party, they have no headscarfs, but miniskirts. It&#39;s the opposite, very closed in the public, very open in the private area, somehow. In the beginning it confused me.&lt;br /&gt;&lt;br /&gt;People from Iran are very hospitable, and they love their country, they are proud of it. I have the feeling, that it is sometimes difficult to find things where they can be proud of. They often talk about history, and how powerful Persia once was. But now it is not anymore.&lt;br /&gt;And they seem not to like Turkish or Arabian people...&lt;br /&gt;&lt;br /&gt;Iran nowadays is a lost country. It has a regime which surpresses the intelligent people of the country, so that more and more of them leave the country. And most of the people are very poor, and I read, that 70% of the people are younger than 30 years old.&lt;br /&gt;This last fact gives me some hope. The young people like the Internet, they like Twitter, and so on. They are open-minded and curious to learn new things. Maybe there is a chance that they will change their regime some day.&lt;br /&gt;&lt;br /&gt;We have to hope for this, because the Iran could be a wonderful country to live with a lot of great people.</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/2197870159308628040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/06/in-few-hours-im-going-to-pick-up.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2197870159308628040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2197870159308628040'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/06/in-few-hours-im-going-to-pick-up.html' title='My love from Iran'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8466358959168318018.post-2444347978296797392</id><published>2009-06-29T21:00:00.001+02:00</published><updated>2009-06-30T06:57:52.764+02:00</updated><title type='text'>Twitter</title><content type='html'>A few weeks ago I started to use Twitter.&lt;br /&gt;
I&#39;m not a fan of spending too much time on the computer, even though I SPEND a lot of time sitting in front of this strange device. Nevertheless I was curious what Twitter really is and registered myself there.&lt;br /&gt;
&lt;br /&gt;
Well, mot of the talks are not interesting for me, but when I search for java, javascript, jquery, or similiar topics I get a huge number of interesting articles. &lt;br /&gt;
This actually changed my life.&lt;br /&gt;
I got more links to exciting and interesting home pages than ever before, and I&#39;m reading and learning new things now all the time. I&#39;m quite thankful for this possibility.&lt;br /&gt;
&lt;br /&gt;
I use the Xmarks plugin for Firefox where one can share one&#39;s bookmarks between the PCs at the office and at home. I made a new structure of my bookmarks, so that I can easily find things again, and I add the most helpful links I found on Twitter to my bookmarks quite often.&lt;br /&gt;
&lt;br /&gt;
I am also impressed about the tweets about the election in Iran (#iranelection), there were so many people who were shocked by the behaviour of the iranish government, it was good to hear or read them. My Twitter icon is still green as a sign against the current actions of the government of Iran.</content><link rel='replies' type='application/atom+xml' href='http://thomas-eichberger.blogspot.com/feeds/2444347978296797392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/06/twitter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2444347978296797392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8466358959168318018/posts/default/2444347978296797392'/><link rel='alternate' type='text/html' href='http://thomas-eichberger.blogspot.com/2009/06/twitter.html' title='Twitter'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10759225001394215378</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>