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

<channel>
	<title>Greg's ramblings</title>
	<atom:link href="http://dev.magnolia-cms.com/~gjoseph/feed" rel="self" type="application/rss+xml" />
	<link>http://dev.magnolia-cms.com/~gjoseph</link>
	<description>about Magnolia and other stuff</description>
	<pubDate>Tue, 02 Jun 2009 21:45:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Build updates</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/build-updates</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/build-updates#comments</comments>
		<pubDate>Tue, 02 Jun 2009 21:45:36 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dev.magnolia-cms.com/~gjoseph/?p=64</guid>
		<description><![CDATA[A recent release of our parent poms, v9, introduces the following changes and improvements:
* Maven 2.0.10 : we now require Maven 2.0.10 to build Magnolia, through the enforcer plugin. Eclipse and IDEA users, rejoice, however, because we&#8217;ve made the configuration laxer: regular Maven invocations will require Maven 2.0.10 or a more recent version (which includes [...]]]></description>
			<content:encoded><![CDATA[<p>A recent release of our parent poms, v9, introduces the following changes and improvements:</p>
<p>* Maven 2.0.10 : we now require Maven 2.0.10 to build Magnolia, through the enforcer plugin. Eclipse and IDEA users, rejoice, however, because we&#8217;ve made the configuration laxer: regular Maven invocations will require Maven 2.0.10 or a more recent version (which includes Maven 2.1 which Eclipse and IDEA use internally); only when performing a release will the enforcer plugin strictly require Maven 2.0.10.</p>
<p>* If you&#8217;ve had Clover license issues recently while attempting to build/release Magnolia, a module or project, rejoice. You now have two options:<br />
1) live with the evaluation license that&#8217;s bundled in the Clover Maven plugin itself - this should work for a little while now, as I&#8217;ve just updated the pom to use the latest version of Clover.</p>
<p>2) use your own license: the parent pom configures the plugin so that it uses a cloverLicenseLocation property. You can, for instance, define it in your ~/.m2/settings.xml file, using a profile, such as :<br />
 &lt;profiles&gt;<br />
   &lt;profile&gt;<br />
     &lt;id&gt;my-default-profile&lt;/id&gt;<br />
     &lt;activation&gt;<br />
       &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;<br />
     &lt;/activation&gt;<br />
     &lt;properties&gt;<br />
       &lt;cloverLicenseLocation&gt;${user.home}/.m2/clover.license&lt;/cloverLicenseLocation&gt;<br />
     &lt;/properties&gt;<br />
[...]<br />
Provided that your license key is indeed in ~/.m2/clover.license</p>
<p>If the property isn&#8217;t defined in your settings.xml file, the plugin will fall back to the evaluation license. On the other hand, you&#8217;ll get an explicit error message if you define the property but make it point to an non-existent or invalid file.</p>
<p>Next step will be to provide a valid license for our open-source projects.</p>
<p>* We now keep track of the parent pom changes in Jira: see http://jira.magnolia-cms.com/browse/BUILD</p>
<p>* Magnolia 4.1 will require Java 1.5, but some modules might still be happy with 1.4, or might want to go ahead and use 1.6: we&#8217;ve introduced a ${javaVersion} property. If you want to build your project/module against 1.5, simply add a &lt;javaVersion&gt;1.5&lt;/javaVersion&gt; property. The default is still 1.4, so that all modules can update to the new version of the parent pom without breaking compatibility. The main Magnolia project and some modules have this set to 1.5 now. Ideally, we won&#8217;t update this property to 1.5 for modules that don&#8217;t depend on Magnolia 4.1 yet.</p>
<p>* Projects and modules using the info.magnolia:magnolia-parent-pom-enterprise parent pom will now be deployed to <a href="http://repo.magnolia-cms.com/enterprise/">http://repo.magnolia-cms.com/enterprise/</a>. The transition is insured as all relevant other parent poms (-internal and -project) now have both the new /enterprise repo and the old /restricted repo (which shouldn&#8217;t be used anymore - contact me if doubts about this)</p>
<p>One final remark: there are still people out there who extend info.magnolia:magnolia-project in their own project. Don&#8217;t ! There is no good reason to do so. Likewise, if your project or module is not meant to be hosted here, there&#8217;s probably no good reason to use our parent poms (although if you do, please contact me or send a mail to the users list, I&#8217;d like to hear about it). What you want to do is probably build a project that *depends* on Magnolia. If you&#8217;re building a webapp with Maven (&lt;packaging&gt;war&lt;/packaging&gt;), here&#8217;s an (outdated) example of how to do it: <a href="http://svn.magnolia-cms.com/view/community/modules/magnolia-webapp-documentation/trunk/pom.xml?revision=19481&amp;view=markup">http://svn.magnolia-cms.com/view/community/modules/magnolia-webapp-documentation/trunk/pom.xml?revision=19481&amp;view=markup</a> If you are buliding a module, just have a look at any of the up-to-date modules under <a href="http://svn.magnolia-cms.com/view/community/modules">http://svn.magnolia-cms.com/view/community/modules</a></p>
<p> </p>
<p>Until next time,</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/build-updates/feed</wfw:commentRss>
		</item>
		<item>
		<title>Winstoned !</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/winstoned</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/winstoned#comments</comments>
		<pubDate>Tue, 23 Dec 2008 01:41:40 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[build]]></category>

		<guid isPermaLink="false">http://dev.magnolia-cms.com/~gjoseph/?p=60</guid>
		<description><![CDATA[I&#8217;m happy to report that Magnolia seemingly works in Winstone !
With this simple command, it just worked (using the webapps of our latest 4.0 Milestone 2, as deployed in our current standard Tomcat-based bundle)
java -jar winstone-0.9.10.jar --useJasper --webappsDir=/Applications/MagnoliaEnterpriseEdition/apache-tomcat-5.5.27/webapps/
All that was needed is to have the following in a lib folder:
./lib
./lib/commons-logging-api-1.1.1.jar
./lib/jasper-compiler-jdt.jar
./lib/jasper-compiler.jar
./lib/jasper-runtime.jar
./lib/jsp-api.jar

(which sadly adds 1.9mb to Winstone&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to report that Magnolia seemingly works in <a href="http://winstone.sourceforge.net/">Winstone</a> !</p>
<p>With this simple command, it just worked (using the webapps of our latest 4.0 Milestone 2, as deployed in our current standard Tomcat-based bundle)</p>
<p><code>java -jar winstone-0.9.10.jar --useJasper --webappsDir=/Applications/MagnoliaEnterpriseEdition/apache-tomcat-5.5.27/webapps/</code></p>
<p>All that was needed is to have the following in a lib folder:<br />
<code>./lib<br />
./lib/commons-logging-api-1.1.1.jar<br />
./lib/jasper-compiler-jdt.jar<br />
./lib/jasper-compiler.jar<br />
./lib/jasper-runtime.jar<br />
./lib/jsp-api.jar<br />
</code><br />
(which sadly adds 1.9mb to Winstone&#8217;s meager 300k)</p>
<p>A warning about tools.jar not being found can be safely ignored on OSX, at least if you have the developer tools installed.</p>
<p>Two worries left: 1) the JAAS configuration. I&#8217;m not sure if it&#8217;s handled properly. Magnolia itself needs improvement in this area anyway. 2) Performance. The performance in AdminCentral seems okayish, but browsing the demo site is utterly slow. It seems as slow as when Tomcat compiles JSPs&#8230; however there are no JSPs in these pages! Taglibs are used in FreeMarker templates, but we got rid of performance issues in that area ages ago, at least with Tomcat&#8230;</p>
<p>What&#8217;s next ? I&#8217;d love to see a clickable embedded version of Magnolia. With, say, a minimal Swing GUI or a CLI which would ask me what port I want to start it on, if I want to run an author or public instance, and if applicable, where the associated public instance is.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/winstoned/feed</wfw:commentRss>
		</item>
		<item>
		<title>Growing and shrinking</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/growing-and-shrinking</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/growing-and-shrinking#comments</comments>
		<pubDate>Wed, 10 Dec 2008 14:36:40 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[modules]]></category>

		<category><![CDATA[templating]]></category>

		<guid isPermaLink="false">http://dev.magnolia-cms.com/~gjoseph/?p=53</guid>
		<description><![CDATA[Two exciting things happening at once !
One, we&#8217;re finally getting rid of a bunch of old &#8220;stuff&#8221; in Magnolia&#8217;s main codebase. A very welcome diet, as some of that code has been lying around unused or deprecated for two years or more. It&#8217;s also a relief to see that this will incidentally increase our code coverage and/or [...]]]></description>
			<content:encoded><![CDATA[<p>Two exciting things happening at once !</p>
<p>One, we&#8217;re finally getting rid of a bunch of old &#8220;stuff&#8221; in Magnolia&#8217;s main codebase. A very welcome diet, as some of that code has been lying around unused or deprecated for two years or more. It&#8217;s also a relief to see that this will incidentally increase our code coverage and/or help making some classes a little more testable. There&#8217;s still a long way to go in that area though !</p>
<p>Second, we&#8217;re moving a bunch of modules, which have been nurtured internally, to the community space. Watch out for</p>
<ul>
<li>In place templating - yes! You&#8217;ll be able to edit (Freemarker) templates directly from inside Magnolia ! Support for JSP isn&#8217;t impossible, but involved some much hassle (JSPs have to be on the file system) that we decided to leave that as an exercise for the reader. I&#8217;m pretty convinced everyone will love the Freemarker support we&#8217;ve introduced though. It takes a bit getting used to, but once you get the hang of it, it&#8217;s so much cleaner than JSP&#8230; &lt;insert bad-taste pun about never coming back&gt;.</li>
<li>Resources - a simple module that allows one to handle web resources in a separate workspace and within Magnolia. CSS is currently supported, we&#8217;re hoping to add support for Javascript and images soonish, making this a one-stop shop for all your layout/design resources.</li>
<li>Form - build simple forms within Magnolia, and process them. Elegant css-based layout for your forms, a simple API for processing the results.</li>
<li>Webdav support - still experimental, but we&#8217;re hoping to get this to work for DMS, templates, and so on.</li>
</ul>
<div>Care to help out ?</div>
<div></div>
<div>Some more info:</div>
<div>
<div>  http://wiki.magnolia-cms.com/display/DEV/Roadmap+4.0</div>
<div>  http://wiki.magnolia-cms.com/display/DEV/Concepts</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/growing-and-shrinking/feed</wfw:commentRss>
		</item>
		<item>
		<title>IE6 on OSX</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/ie6-on-osx</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/ie6-on-osx#comments</comments>
		<pubDate>Wed, 22 Oct 2008 17:45:54 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://dev.magnolia-cms.com/~gjoseph/?p=50</guid>
		<description><![CDATA[Yes, some people still have to go through the pain of using Internet Explorer &#8230; 6. Tonight, that&#8217;s me. After loosing (too much) time getting a virtual machine or a remote desktop to a windows machine, and then on said machine getting an IE6 to actually work (Multiple_IE never really worked for me, and Microsoft&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, some people still have to go through the pain of using Internet Explorer &#8230; 6. Tonight, that&#8217;s me. After loosing (too much) time getting a virtual machine or a remote desktop to a windows machine, and then on said machine getting an IE6 to actually work (Multiple_IE never really worked for me, and Microsoft&#8217;s 400mb of disk image for doing the same with a single version of IE is still downloading&#8230;), I stumbled accross Darwine (Wine for OSX) and &#8230; yes, IEs4osx.</p>
<p>So, without further ado, if you have to suffer, but are no masochist, it&#8217;s a simple as that: <a href="http://www.kronenberg.org/ies4osx/">http://www.kronenberg.org/ies4osx/</a> !</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/ie6-on-osx/feed</wfw:commentRss>
		</item>
		<item>
		<title>Codepress for Magnolia ?</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/codepress-for-magnolia</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/codepress-for-magnolia#comments</comments>
		<pubDate>Tue, 07 Oct 2008 19:09:46 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[templating]]></category>

		<guid isPermaLink="false">http://dev.magnolia.info/~gjoseph/?p=41</guid>
		<description><![CDATA[I was looking for a simple way to get line numbers in html textareas - amongst other things to edit css, javascript and templates from within Magnolia, making my whole layout activatable/versionable ! - and I just stumbled upon Codepress ! Man, that thing is sweet ! (if you use Firefox, that is)
Unfortunately, their main [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple way to get line numbers in html textareas - amongst other things to edit css, javascript and templates from within Magnolia, making my whole layout activatable/versionable ! - and I just stumbled upon <a href="http://maemo.org/midcom-static/midcom.helper.datamanager2/codepress/">Codepress</a> ! Man, that thing is sweet ! (if you use Firefox, that is)</p>
<p>Unfortunately, their main site (<a href="http://codepress.org">codepress.org</a>) seems down at the moment, and the<a href="http://209.85.135.104/search?q=cache:q8WXrNp8JYAJ:codepress.org/changelog.php+site:codepress.org+to-do&amp;hl=en&amp;ct=clnk&amp;cd=3&amp;client=safari"> Google-cached changelog page</a> seems to tell me there&#8217;s been no release since a year. Does anybody what the real status is and/or is there&#8217;s any alternative ?</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/codepress-for-magnolia/feed</wfw:commentRss>
		</item>
		<item>
		<title>News from Bob !</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/news-from-bob</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/news-from-bob#comments</comments>
		<pubDate>Thu, 04 Sep 2008 15:33:25 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[build]]></category>

		<guid isPermaLink="false">http://dev.magnolia.info/~gjoseph/?p=20</guid>
		<description><![CDATA[There has been some definitive construction work undergoing at Magnolia in the last few days, and this is what this post is all about: changes and improvements in our builds ! (Bob the Builder, geddit?)
It all started with a long standing need to restructure our Subversion repository, along with a desire to improve our Maven [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-45" title="bob-the-builder" src="http://dev.magnolia-cms.com/~gjoseph/wp-content/uploads/2008/10/bob-the-builder.jpg" alt="" width="115" height="150" />There has been some definitive construction work undergoing at Magnolia in the last few days, and this is what this post is all about: changes and improvements in our builds ! (Bob the Builder, geddit?)</p>
<p>It all started with a long standing need to restructure our Subversion repository, along with a desire to improve our Maven pom files. Both tasks were a bit daunting at first, but at some point, after long egg and chicken debates, it just became too itchy and I got started.<span id="more-20"></span></p>
<ul>
<li>The Subversion repository structure has been completely overhauled. It&#8217;s now much easier to navigate AND to maintain. It is even <a href="http://wiki.magnolia.info/display/DEV/Svn+structure">documented</a> !</li>
<li>Checkout helper scripts have been unified and overhauled. Check &#8216;em ! Documentation above.</li>
<li><a href="http://dev.magnolia-cms.com/~gjoseph/wp-content/uploads/2008/10/poms.png"><img class="alignnone size-thumbnail wp-image-46" title="poms" src="http://dev.magnolia-cms.com/~gjoseph/wp-content/uploads/2008/10/poms.png" alt="" width="150" height="67" /></a>Pom files have been overhauled too. Here&#8217;s a quick diagram of their structure.<a href="http://dev.magnolia.info/~gjoseph/wp-content/uploads/2008/09/poms.png"></a></li>
<li>All poms inherit from a common parent which define a bunch of generic properties, plugins, and dependencies. Everything can be overridden, but it provides a stable basis.</li>
<li>The lower level of parent poms (<tt>magnolia-parent-pom-community-module</tt> and so on) share a common site descriptor and skin (provided by <tt> magnolia-parent-pom-abstract</tt>) and provide the specific repositories and deployment locations.</li>
<li>Thanks to the above, projects extending these poms now deploy their artifacts and sites in different locations without any hassle.</li>
<li>Javadoc is now generated in <strong>both</strong> aggregated and non-aggregated forms ! This means that on the <a href="http://dev.magnolia.info/ref/3.6.2-SNAPSHOT/">main Maven generated website</a>, you can find <a href="http://dev.magnolia.info/ref/3.6.2-SNAPSHOT/apidocs/">aggregated</a> Javadoc (includes Javadoc for all sub-modules) and <a href="http://dev.magnolia.info/ref/3.6.2-SNAPSHOT/magnolia-core/apidocs/">non-aggregated</a> Javadoc (Javadoc for a single module)</li>
<li>All our projects now include a Clover report. (Which hopefully will become greener!)</li>
<li>Archetypes for easily generating skeletons for Magnolia-based projects and modules are being <a href="http://confluence.magnolia.info/display/DEV/Create+a+New+Module#CreateaNewModule-Aprimeronthenewarchetype">overhauled</a> as well !</li>
<li>Our Maven repository should soon be synchronized with the central Maven repository. Follow <a href="http://jira.codehaus.org/browse/MAVENUPLOAD-2194">MAVENUPLOAD-2194</a> and <a href="ttp://jira.magnolia.info/browse/SYS-19">SYS-19</a> to be updated on this ! For starters, we might only have our parent poms synchronized, but that should be enough to be able to build any Magnolia module without struggling with pom inheritance.</li>
</ul>
<div>It all seems to work nicely so far. I will release all the parent poms and updated Maven plugins and build tools soon. The first release of Magnolia based on these changes will most likely be 3.6.2. Fingers crossed !</div>
<div><em>edit: well, almost. It had to be 3.6.3, nothing&#8217;s ever without surprises.</em></div>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/news-from-bob/feed</wfw:commentRss>
		</item>
		<item>
		<title>On code readability</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/on-code-readability</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/on-code-readability#comments</comments>
		<pubDate>Mon, 23 Jun 2008 12:08:55 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[opinions]]></category>

		<guid isPermaLink="false">http://dev.magnolia.info/~gjoseph/?p=3</guid>
		<description><![CDATA[It&#8217;s always been a subject for long and sterile debates. And yet, every now and then, I feel the itch and need to scratch it a little: coding style. Coding conventions. Javadoc usage. And whenever this comes up, it mostly ends up in &#8220;let&#8217;s update the eclipse/idea configuration files&#8221; or just &#8220;hum, yeah, we should [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s always been a subject for long and sterile debates. And yet, every now and then, I feel the itch and need to scratch it a little: coding style. Coding conventions. Javadoc usage. And whenever this comes up, it mostly ends up in &#8220;let&#8217;s update the eclipse/idea configuration files&#8221; or just &#8220;hum, yeah, we should look into this at some point&#8221; sort of reactions.</p>
<p>Setting up code conventions is all about code readability. Readability being all but subjective, these can hardly be completely enforced by software. I&#8217;d rather rely on common sense, but too many factors (like the food you had for lunch) have an effect on your common sense. The few points I&#8217;m about to mention can probably not be enforced reliably by any kind of tool, other than yourself. <span id="more-3"></span>In general, <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun&#8217;s coding conventions</a> work for me, except for their &#8220;indentation&#8221; notes. Well, the note about indentation is absolutely correct is the one I&#8217;m actually the most anal about (indent on 4 spaces, a tab character is to be represented by <strong>8</strong> spaces, thank you eclipse, and please don&#8217;t use the tab character in the first place anyway), but their notes about line length and line wrapping, are just plain out of scope. Generally long lines will be harder to read, yes, but wrapping them won&#8217;t help. Wrapped statements are just impossible to read. We&#8217;re not in the 70s anymore, and nobody ever has to actually work in an 80 columns terminal. So don&#8217;t enforce line length, but factor your code instead ! I&#8217;d <strong>almost</strong> be in favor of enforcing a rule that would say that <strong>1 statement == 1 line</strong>.</p>
<p>Related to the above, try avoiding complex statements. <strong>Introduce variables</strong>, even if they&#8217;re to be used only once in a <tt>if</tt> statement. Give them a meaningful name, and all of sudden your code almost becomes like natural language.</p>
<p>Consider the following statement:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parent <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp;&amp;amp; parent.<span style="color: #006633;">getLevel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt; level <span style="color: #339933;">&amp;</span>amp;&amp;amp; parent.<span style="color: #006633;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #666666; font-style: italic;">//..blah).size()==0) {</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// .. do something</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>No, it is not *that* complex to read. Now consider the following:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">boolean</span> hasChildren <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>parent <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp;&amp;amp; parent.<span style="color: #006633;">getLevel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt; level <span style="color: #339933;">&amp;</span>amp;&amp;amp;  parent.<span style="color: #006633;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #666666; font-style: italic;">//..blah).size()==0);</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>hasChildren<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// .. do something</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It was not simpler to write, but way simpler to read. Why, you ask? Most probably because you didn&#8217;t even read what was assigned to the hasChildren variable. Because it has a meaningful name, you don&#8217;t need to know how the value is assigned - unless there&#8217;s a bug, which your unit tests surely have covered.</p>
<p>If your code is readable, why clutter it with <strong>log statements</strong>? I am not about to run a war against logging here, because I see how it can sometimes be useful, but if a 10 lines methods is cluttered with 4 lines of logging, I am going to ask questions. I don&#8217;t have very specific examples or guidelines for this, but avoiding splitting log statements in multiple lines, or wrapping them in if statements would already be a good start. Always question their need before adding them. Well tested code is likely to require less logging, because the tests will give you the confidence that your code works the way you expect it to work; the debug log statements would only be there as a reassurance for when your less tested code will eventually fail.</p>
<p>One last point that has buggered me for a while: why clutter your code with <strong>javadoc</strong> comments that had absolutely no value and just duplicates what your code already says ? A few examples to illustrate my point:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Logger.
 */</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Logger log <span style="color: #339933;">=</span> LoggerFactory.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>SomeRandomClass.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>The variable name and its type said it all. Why waste 3 lines of my precious attention ? (remember most computer people suffer from ADD)</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Gets the foo value.
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getFoo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>The method name told me that.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Does something valuable for your business.
 * @throws SomeException when something is wrong with the business.
 * @throws SomeOtherException
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> SomeException, SomeOtherException <span style="color: #009900;">&#123;</span></pre></div></div>

<p>Succinct method description: check. First @throws tag tells me in what condition the exception is thrown: this is useful; check. Second @throws tag: useless. Of course, in reality, this will rarely happen, and I&#8217;ll be more often that not baffled by some eclipse-generated javadoc like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 
 * @throws SomeException
 * @throws SomeOtherException
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> SomeException, SomeOtherException <span style="color: #009900;">&#123;</span></pre></div></div>

<p>&#8230; which is utterly useless. (In case you weren&#8217;t sure, yes, the generated javadoc will still document these exceptions if you omit the @throws tags.)</p>
<p>In short: javadoc <strong>is</strong> useful when you <strong>make it</strong> useful. In other cases, in just essentially makes the code unreadable. Class level javadoc often seems the most useful and less likely to get out of synch or irrelevant after 3 weeks. </p>
<p>Well, this being now written for posterity, I feel much better. Hopefully this will help my point made whenever I bitch about code style and javadoc, and, woohoo, maybe, help improve the general quality and readability of our code.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/on-code-readability/feed</wfw:commentRss>
		</item>
		<item>
		<title>Updating to Maven 2.0.9</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/updating-to-maven-209</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/updating-to-maven-209#comments</comments>
		<pubDate>Fri, 20 Jun 2008 13:15:18 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[build]]></category>

		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://dev.magnolia.info/~gjoseph/?p=10</guid>
		<description><![CDATA[There are a couple of cool improvements in there (most notably the fixed version of most plugins in the superpom - the end of our release plugin nightmares?), and now&#8217;s probably the best time to do this. (would admittedly have been even better prior to 3.6 M1, but hey)  I&#8217;ll update the configuration of [...]]]></description>
			<content:encoded><![CDATA[<p>There are a couple of cool improvements in there (most notably the fixed version of most plugins in the superpom - the end of our release plugin nightmares?), and now&#8217;s probably the best time to do this. (would admittedly have been even better prior to 3.6 M1, but hey)  I&#8217;ll update the configuration of the <tt>maven-enforcer-plugin</tt>, so if you haven&#8217;t done so yet, and want to build Magnolia&#8217;s latest trunk, you&#8217;ll <strong>have to </strong>update your Maven installation too.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/updating-to-maven-209/feed</wfw:commentRss>
		</item>
		<item>
		<title>Startup tasks, voters and irony</title>
		<link>http://dev.magnolia-cms.com/~gjoseph/startup-tasks-voters-and-irony</link>
		<comments>http://dev.magnolia-cms.com/~gjoseph/startup-tasks-voters-and-irony#comments</comments>
		<pubDate>Wed, 14 May 2008 13:21:22 +0000</pubDate>
		<dc:creator>greg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[caching]]></category>

		<category><![CDATA[opinions]]></category>

		<guid isPermaLink="false">http://dev.magnolia.info/~gjoseph/?p=13</guid>
		<description><![CDATA[A recent spike a rewriting the cache module ironically has me looking at startup tasks again; a feature I&#8217;ve never been too fond of, even though I clearly see the need. (My take on this is that these tasks should be executed through the ModuleLifecycle instead of this patchy wooden leg, but that would require [...]]]></description>
			<content:encoded><![CDATA[<p>A recent spike a rewriting the cache module ironically has me looking at <a href="http://www.nabble.com/update-mechanism%3A-tasks-to-be-executed-always-to12243569.html">startup tasks</a> again; a feature I&#8217;ve never been too <a href="http://www.nabble.com/Re%3A-update-mechanism%3A-tasks-to-be-executed-always-td13780743.html">fond of</a>, even though I clearly see the need. (My take on this is that these tasks should be executed through the ModuleLifecycle instead of this patchy wooden leg, but that would require some more work which we&#8217;re not ready to do right now.)</p>
<p>So the only current usage of startup tasks in Magnolia itself is <a href="http://svn.magnolia.info/svn/magnolia/tags/magnolia-3.5.4/magnolia-module-cache/src/main/java/info/magnolia/cms/cache/setup/CacheModuleVersionHandler.java">in the cache module</a>. There are some projects out there who use the feature as well, most likely for sanity checks and recovery.<span id="more-13"></span>These startup tasks were applying a sanity check, making sure the necessary minimal set of &#8220;voters&#8221; were in place for the cache. As the comment says, these could be disabled by setting their enabled flag to false. But there is no way to get rid of them. Every Magnolia restart would recreate them. Fair enough, especially since their configuration is <a href="http://dev.magnolia-cms.com/~gjoseph/wp-content/uploads/2008/10/voters_config.png">not trivial</a>.</p>
<p>Now, the cache module was rewritten. The decision of caching a page - or not - is done by the <a href="http://dev.magnolia.info/ref/3.6-SNAPSHOT/apidocs/index.html?info/magnolia/module/cache/CachePolicy.html">CachePolicy</a>. The <a href="http://dev.magnolia.info/ref/3.6-SNAPSHOT/apidocs/index.html?info/magnolia/module/cache/DefaultCachePolicy.html">DefaultCachePolicy</a> supports voters, just like the original <a href="http://dev.magnolia.info/ref/3.6-SNAPSHOT/apidocs/index.html?info/magnolia/cms/cache/DefaultCacheManager.html">DefaultCacheManager</a>, hopefully in a less obscure manner: the voters list is populated using &#8220;content2bean&#8221;. But you could swap that policy for another. One which does not support voters. One which uses voters, but for a totally different purpose.</p>
<p>Given this, does it still make sense to force the existence of those voters in a specific location? (i.e. a specific node in the configuration workspace, which might or might not match the properties of the chosen CachePolicy implementation) Should the startup tasks check if the CachePolicy is the default one before possibly recreating the voters? I don&#8217;t think it should. If you mess up your configuration, 1) you can <a href="http://wiki.magnolia.info/display/WIKI/Recreating+the+anonymous+user">recreate it</a>, 2) it can&#8217;t cause that much damage.</p>
<p>The only situation where this might get tricky is if you accidently remove the bypass on /.magnolia, since you won&#8217;t even be able to browse the configuration tree anymore. This <a href="http://wiki.magnolia.info/display/WIKI/Executing+fix+scripts">can be overcome</a> but is admittedly a bit tedious. Maybe Philipp&#8217;s recent spike at <a href="http://svn.magnolia.info/svn/community/modules/magnolia-module-shell/trunk/">scripting</a> could also help.</p>
<p>I&#8217;d vote (ha ha) for less magic(don&#8217;t fix stuff silently), more power to the user(let them do what they want), and better tools to fix user mistakes <img src='http://dev.magnolia-cms.com/~gjoseph/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.magnolia-cms.com/~gjoseph/startup-tasks-voters-and-irony/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
