<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Improved software testing</title>
	
	<link>http://blog.kalistick.com</link>
	<description>Innovation for Agile QA</description>
	<lastBuildDate>Wed, 28 Mar 2012 13:38:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/kalistick_blog_en" /><feedburner:info uri="kalistick_blog_en" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Harden your testing pyramid</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/K3eT8THryMk/</link>
		<comments>http://blog.kalistick.com/Agile/harden-testing-pyramid/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 11:24:10 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1923</guid>
		<description><![CDATA[You might know the famous testing pyramid established by Mike Cohn, one of the founders of the Scrum Alliance. This pyramid has been used and modified a bunch of times. Now is my turn to fill up the pyramid! The testing pyramid For those who aren’t familiar with the testing pyramid (or who don’t remember), [...]]]></description>
			<content:encoded><![CDATA[<p>You might know the famous testing pyramid established by <a href="http://www.mountaingoatsoftware.com/" target="_blank">Mike Cohn</a>, one of the founders of the <a href="http://www.scrumalliance.org/" target="_blank">Scrum Alliance</a>. This pyramid has been used and modified a bunch of times. Now is my turn to fill up the pyramid!</p>
<h2>The testing pyramid</h2>
<p>For those who aren’t familiar with the testing pyramid (or who don’t remember), the principle is as follows:</p>
<div id="attachment_1936" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.kalistick.com/Agile/harden-testing-pyramid/attachment/pyramid/" rel="attachment wp-att-1936"><img class="size-medium wp-image-1936" title="Testing pyramid" src="http://blog.kalistick.com/wp-content/uploads/2012/02/pyramid-300x272.png" alt="Testing pyramid" width="300" height="272" /></a>
<p class="wp-caption-text">Mike Cohn</p>
</div>
<p>The bottom tier has to be automated the most: it gives the best ROI as unit tests can be easily written by developers and gives them an immediate feedback. The more automated unit tests, the stronger will be the foundation.</p>
<p>The middle tier is more difficult to automate than the foundation and tests at this level will be focused on business-facing tests. These functional tests will give an answer to the question “are we building the right thing”. It will ensure functionalities match the requirements.</p>
<p>The top tier will the least automated tests because this level is usually composed of UI tests that are expensive to write or maintain and that often require human control (over visual aspects for instance).</p>
<h2>What the pyramid misses</h2>
<p>I think the pyramid is very useful and test teams can gain efficiency if they follow its principle. However, something is missing…</p>
<p>Tests in this multi-layer system are being executed by different people, and all these tests are of different nature. This introduces one more difficulty: there is no aggregated vision of all these different tests. For instance, it is hard to get a  complete picture of acceptance and GUI tests.</p>
<p>As a result, teams can leave “testing holes” within their application: <a href="http://www.kalistick.com/testing-agility/test-coverage" target="_blank">software areas that are not covered by any tests</a> and it is more likely that bugs will slip through the net of your testing in these areas!</p>
<div id="attachment_1980" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.kalistick.com/Agile/harden-testing-pyramid/attachment/unknown_risk_coverage/" rel="attachment wp-att-1980"><img class="size-medium wp-image-1980" title="Unknown risk coverage" src="http://blog.kalistick.com/wp-content/uploads/2012/02/unknown_risk_coverage-300x221.png" alt="Unknown risk coverage" width="300" height="221" /></a>
<p class="wp-caption-text">Unknown risk coverage</p>
</div>
<p>However it is almost impossible to reach 100% test coverage of the software. So how to assess risks related to these “testing holes” in order to decide which tests should be added?</p>
<p>We suggest 2 ways of doing this assessment in order to have the right focus for additional tests.</p>
<p style="padding-left: 30px;"><strong>1. Focus on regression risk</strong></p>
<p>The point is to compare the current version of the software you have to test with the previous one. This comparison will allow you to identify changes where regression risks are higher.</p>
<p>Mixing this information with test coverage clearly identifies regression risks that have not been covered by any test.</p>
<p>As a picture is worth a thousand words, let me show you that new principle:</p>
<div id="attachment_1981" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.kalistick.com/Agile/harden-testing-pyramid/attachment/assessed_risk_coverage/" rel="attachment wp-att-1981"><img class="size-medium wp-image-1981" title="Known risk coverage" src="http://blog.kalistick.com/wp-content/uploads/2012/02/assessed_risk_coverage-300x234.png" alt="Known risk coverage" width="300" height="234" /></a>
<p class="wp-caption-text">Known risk coverage</p>
</div>
<p style="padding-left: 30px;"><strong>2. Add business perspectives</strong></p>
<p>Even with a focus on untested changes this could still be too large when you haven’t yet got a high proportion of automated test. So in addition, we recommend adding a business perspective: drill-down to untested changes by features or  software functional areas. So you can focus your additional testing activities where bugs should be avoided in order of priority.</p>
<div id="attachment_1969" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.kalistick.com/Agile/harden-testing-pyramid/attachment/testing_blind/" rel="attachment wp-att-1969"><img class="size-medium wp-image-1969" title="Functional view" src="http://blog.kalistick.com/wp-content/uploads/2012/02/testing_blind-300x158.png" alt="Functional view" width="300" height="158" /></a>
<p class="wp-caption-text">Functional view</p>
</div>
<h2>Ok, but what do we do when we don’t have a high number of automated tests?</h2>
<p>Let’s jump to the top of the pyramid, this is where you will need to have more manual tests if your coverage by automated tests is weak. In such a situation you won’t have enough time to execute all the manual tests<br />
every time. You will have to select relevant tests and execute them depending on their priorities and on what has not been tested at lower levels.</p>
<p>Combining changes, coverage and business perspectives, not only will you optimize the time you spend on testing by balancing automated and manual tests, but you will also focus on relevant tests (and thus avoid losing time with useless  tests) and ensure you covered the risks in the application.</p>
<h2>Adding test footprints</h2>
<p>During testing, Kalistick’s agent can record all the execution paths through your application. This is not about record/replay but <a href="http://www.kalistick.com/testing-agility" target="_blank">linking test cases and code</a> so that when changes are made in a release, relevant test  cases to cover the corresponding regressions risks can be identified.</p>
<p>As you can imagine, the technology is self-learning. The more tests you execute, the better the software is going to know yours and be able to help you to build more <a href="http://www.kalistick.com/testing-agility/optimize-test-strategy" target="_blank">efficient regression test strategy</a>.</p>
<p>The goal of this technology is double:</p>
<ol>
<li>Optimizing test efficiency by selecting relevant tests for a test campaign and avoid losing time with useless tests which aren’t testing changed modules</li>
<li>Ensuring that all risks are covered, even indirect risks dues to indirect impacts of certain changes (mainly regressions thus)</li>
</ol>
<h3>Conclusion</h3>
<p>On your way to reach the right balance of automated and manual tests at each level of the pyramid this technology will help you improve your software testing efficiency.</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/K3eT8THryMk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Agile/harden-testing-pyramid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Agile/harden-testing-pyramid/</feedburner:origLink></item>
		<item>
		<title>Kalistick expands its integrations</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/vo3bDI8Cjmg/</link>
		<comments>http://blog.kalistick.com/Kalistick/kalistick-new-integrations/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 10:44:07 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Kalistick]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1829</guid>
		<description><![CDATA[We are proud to announce our new integrations! Thanks to our great R&#38;D team, Kalistick integrates with even more very famous tools that most testers are using. SoapUI : using this integration with SoapUI by SmartBear, you get your real tests coverage within the application and you detect untested code changes that leave the door [...]]]></description>
			<content:encoded><![CDATA[<p>We are proud to announce our new integrations! Thanks to our great R&amp;D team, Kalistick integrates with even more very famous tools that most testers are using.</p>
<p><strong><a href="http://blog.kalistick.com/Kalistick/kalistick-new-integrations/attachment/soapui/" rel="attachment wp-att-1841"><img class="alignleft" title="soapui" src="http://blog.kalistick.com/wp-content/uploads/2011/11/soapui.png" alt="" width="150" height="63" /></a>SoapUI</strong> : using this integration with <a href="http://www.soapui.org/" target="_blank">SoapUI</a> by SmartBear, you get your real tests coverage within the application and you detect untested code changes that leave the door open to undetected regression.</p>
<p>&nbsp;</p>
<p><strong><a href="http://blog.kalistick.com/Kalistick/kalistick-new-integrations/attachment/selenium/" rel="attachment wp-att-1849"><img class="alignleft" title="selenium" src="http://blog.kalistick.com/wp-content/uploads/2011/11/selenium.png" alt="" width="150" height="136" /></a>Selenium</strong> : largely used by our Agile customers they have asked us to to integrate our technology to <a href="http://seleniumhq.org/" target="_blank">Selenium</a>. Now you are able register all your test coverage and  to detect holes in your tests through the code and changes coverage analysis.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><a href="http://blog.kalistick.com/Kalistick/kalistick-new-integrations/attachment/hp-qtp-logo/" rel="attachment wp-att-1854"><img class="alignleft" title="HP QTP Logo" src="http://blog.kalistick.com/wp-content/uploads/2011/11/HP-QTP-Logo.png" alt="" width="132" height="113" /></a>QTP</strong> : in the field of automation tools, we had to integrate Kalistick to HP QTP. With Kalistick, you record all your automated tests coverage and you identify untested areas that could need additional testing activities. It helps you find the best balance between automation and manual testing.</p>
<p>&nbsp;</p>
<p><strong><br />
</strong></p>
<p><strong><a href="http://blog.kalistick.com/Kalistick/kalistick-new-integrations/attachment/hp/" rel="attachment wp-att-1848"><img class="alignleft" title="hp" src="http://blog.kalistick.com/wp-content/uploads/2011/11/hp.png" alt="" width="150" height="95" /></a>HP ALM (QC 11)</strong>: Kalistick was already integrated with Quality Center 10. With QC11 ALM, the integration is going further by allowing you to optimize your regression <a href="http://www.kalistick.com/how-to-increase-software-test-efficiency.html" target="_blank">test strategy</a> and to follow your functional test coverage.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://blog.kalistick.com/Kalistick/kalistick-new-integrations/attachment/xqual/" rel="attachment wp-att-1889"><img class="alignleft size-full wp-image-1889" title="xqual" src="http://blog.kalistick.com/wp-content/uploads/2011/12/xqual.png" alt="" width="155" height="78" /></a></p>
<p><strong>XStudio:</strong><a href="http://www.xqual.com/"> XQual</a> delivers XStudio, a free test management application that handles the complete life-cycle of your QA/testing projects. With Kalistick plugin, it&#8217;s easy to re-run only the tests that are necessary after code change.</p>
<p>&nbsp;</p>
<p>All these integration are built with our public API that open our technology to any Test Management Solution or Automated Test tools.</p>
<p>In order to give an always higher quality level, we continuously work on new integrations with the essential test tools. Our platform already integrates with over than 35 tools dedicated to software testing and development.</p>
<p>If you think about a particular tool we should integrate with, please tell us in the comments!</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/vo3bDI8Cjmg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Kalistick/kalistick-new-integrations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Kalistick/kalistick-new-integrations/</feedburner:origLink></item>
		<item>
		<title>Non-Regression Testing: an alternative to automation</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/Y1QO2ueQw9s/</link>
		<comments>http://blog.kalistick.com/Tests/non-regression-test-alternative-automation/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 09:04:36 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1801</guid>
		<description><![CDATA[Test automation : the holy grail quest An idyllic vision of test automation Automated testing is undoubtedly an ideal solution for having the capacity of replaying test for each version of an application, and thus avoiding regressions. First steps with automation tools are generally awesome, but… A reality not so bright It appears that this “ideal” [...]]]></description>
			<content:encoded><![CDATA[<h2>Test automation : the holy grail quest</h2>
<h3>An idyllic vision of test automation</h3>
<p>Automated testing is undoubtedly an ideal solution for having the capacity of replaying test for each version of an application, and thus avoiding regressions. First steps with automation tools are generally awesome, but…</p>
<h3>A reality not so bright</h3>
<p>It appears that this “ideal” is not always fulfilled. Depending on projects and contexts:</p>
<ul class="style-none list_arrow2">
<li>Application’s functionalities and UI are not stable enough. They change with each version and thus require manual intervention on automation scripts. Maintenance costs of test scripts become too important.</li>
<li>Data are not stable on a long term basis and it is hard to control results. Analyzing every result requires as much time as executing the test.</li>
<li>Visibility on real test coverage is poor. We’ve got automated tests, but knowing if they are relevant regarding to regression risks related to the evolutions is very different. Basically, you play the tests, but it doesn’t avoid regressions.</li>
</ul>
<p>So, here is the reality as seen with our clients: there sometimes are automated test. When there are, it’s no more than 20% to 40% of tests overall!</p>
<p>For manual tests remaining, an efficient test strategy is essential. Available resources and time are impeding testers from executing all the tests.</p>
<h2>How to define a non-regression strategy</h2>
<h3>Identification of regression risks</h3>
<p>It is essential to have a clear vision of risks in order to define an efficient test strategy. Otherwise, selecting relevant tests is extremely hard.</p>
<p>However, this clear vision is not easy to obtain.</p>
<p>As explained in a previous article about <a href="http://blog.kalistick.com/Tests/developers-come-from-mars-and-testers-from-venus/">misunderstanding between developers and testers</a>, developers are failing to provide test teams trustable information. Thus, no way to surely identify impacted functionalities nor risks.</p>
<p>Our technology is taking <a href="http://www.kalistick.com/how-does-kalistick-works.html">a picture of each version of the application</a>. It then compares each picture to precisely identify changes and their functional impacts. Thanks to that, we you can get a clear picture of risks to cover for each version, whether major of minor.</p>
<h3>Identifying the right test cases</h3>
<p>Beyond risks identification, it’s necessary to select test cases that effectively cover those risks. And selecting them becomes more complex with an increasing number of tests.</p>
<p><a name="video"></a></p>
<p>Our technology is unique. For each test execution, its real footprint on the application is recorded. We accurately identify what’s tested in the application (executed code) by one test. We called it “<a href="http://www.kalistick.com/improving-software-test-strategy-demos-videos.html">Test Learning System</a>”, and it’s automated.</p>
<p style="text-align: center;"><iframe width="560" height="315" src="http://www.youtube.com/embed/jJNjIVJHBcU?rel=0&amp;autohide=1" frameborder="0" allowfullscreen></iframe></p>
<p>By correlating this footprint with version analysis, our platform can identify which scenarios are relevant for covering the regression risks.</p>
<h3>Prioritizing tests regarding business issues</h3>
<p>Identifying tests is a good point, but it can also be necessary to prioritize them.</p>
<p>When time runs out and you can’t play all of the tests, better to be sure you started with the good ones. This is <a href="http://www.kalistick.com/a-unique-test-strategy-improvement-platform.html">Risk Based Testing</a>.</p>
<p>By identifying each functional module of the software, Kalistick’s platform allows to associate a business criticality level. It is then crossed with footprints and modifications in order to select and prioritize test scenarios.</p>
<p>An integrated wizard also allows polishing the strategy until the number of scenarios can be played in the allocated time with the available testers.</p>
<h3>Trustworthy test coverage indicators</h3>
<p>During the test stage, Kalistick’s platform brings a detailed vision of the risk coverage progress by identifying tested and untested elements. Thus, it becomes possible to identify the eventual falls through the net and to stitch them up before going live to production.</p>
<p>This vision of coverage highlights complementarity between automated and manual tests. After an automated test campaign, it allows to identify remaining parts to be tested as well as the most relevant manual tests.</p>
<p>In conclusion, it becomes possible with Kalistick to define more efficient regression test strategies that are balancing time, costs and risk coverage, and to adapt them to every business context, project or version.</p>
<div class="green-box"><strong> Going further</strong><br><br />
For more information about this brand new and unique technology, we invite you to take part in a webinar. <a href="http://www.kalistick.com/webinars-assist-to-a-live-presentation.html?utm_source=Blog&amp;utm_medium=Article&amp;utm_campaign=TNR">Register now for free</a> !
</div>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/Y1QO2ueQw9s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Tests/non-regression-test-alternative-automation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Tests/non-regression-test-alternative-automation/</feedburner:origLink></item>
		<item>
		<title>Testers: How to maximize test efficiency with test coverage?</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/QcACDf-n33g/</link>
		<comments>http://blog.kalistick.com/Tests/testers-maximize-test-efficiency-test-coverage/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 11:44:53 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1790</guid>
		<description><![CDATA[How to use test coverage? The basic use of test coverage… Most of the time, for functional test teams, test coverage is a control matrix that links risks, requirements and test scenarios. As soon as scenarios match the requirements, the known risks and that they are successfully run, the coverage is validated and theoretically covers [...]]]></description>
			<content:encoded><![CDATA[<h2>How to use test coverage?</h2>
<h3>The basic use of test coverage…</h3>
<p>Most of the time, for functional test teams, test coverage is a control matrix that links risks, requirements and test scenarios.</p>
<p>As soon as scenarios match the requirements, the known risks and that they are successfully run, the coverage is validated and theoretically covers the risks…</p>
<h3>Or strategic use</h3>
<p>However, it is possible to approach test coverage from a new way. This way will give richer information that will be really useful for test improvement. It will allow testers to improve test efficiency.</p>
<h2>Decrypting test coverage</h2>
<h3>What is that?</h3>
<p><a href="http://www.kalistick.com/test-coverage-insights.html">Test coverage</a> is seeing the real coverage of tests in the application. Shortly, it’s analyzing what has been executed in the code by tests. We call it the “footprint” of tests in the software.</p>
<h3>Global coverage</h3>
<p>Globally on an application, it becomes possible to see accurately:</p>
<ul class="style-none list_arrow2">
<li>What has been tested</li>
<li><strong>What hasn’t been tested</strong></li>
</ul>
<p>It will allow testers to make sure every single part of code is covered by a test scenario at least. But as testing all of the application is rarely possible regarding the short period of time allocated, we need more data…</p>
<h3>Enrich the information</h3>
<p>In order to exploit even better the test coverage knowledge, it is ideal to double check that tests are covering the changes that has been made in the software while validation stage. This will permit testers to better anticipate regression risks.</p>
<p>For doing this, unexpected changes must be identified first, and then the code has to be checked to reveal if weather or not it is covered by a scenario.</p>
<p>If some parts of the added code are seen as not covered, test teams can react very quickly and focus on these specific highly risked areas.</p>
<p>Of course, the closer is the deadline; the most important is the information. During the last test stages, it is absolutely impossible to re test all over again. It becomes a must to only select a few test cases and to make sure nothing has been missed.</p>
<p>And it’s the same scenario for minor versions or patches: allocated time and test load are making it impossible to re test all over. Identifying test scenarios impacted by changes allows focusing on relevant tests. This increases the team’s reactivity.</p>
<h3>Case by case even more efficient</h3>
<p>Individually looking the footprints gives an even finest details level.</p>
<p>With traditional test tools, test coverage is seen global: test execution paths in the application are not considered. Even test are not differentiated.</p>
<p>By capturing every scenario footprint individually, Kalistick brings a high value data to test teams.</p>
<p>When executing a test scenario, each and every executed action on the software is recorded. Thus, when a new version is received during a validation stage, if certain tests have already been executed, the system will detect which results can be compromised by the new version (when the footprint has changed).</p>
<p>If a choice has to be made between scenarios, or if you work with <a href="http://www.kalistick.com/a-unique-test-strategy-improvement-platform.html">Risk Based Testing</a>, Kalistick brings an ideal additional information. Based on each scenario’s footprint on code and on the application’s functional risks, the system shows which scenarios are to be run for each functional subset.</p>
<h2>The “Test Learning System”</h2>
<p>It is the name of the software that will help you improve your tests!</p>
<p>Here is how it works:</p>
<ul class="style-none list_arrow2">
<li>When a test is played, it is recorded</li>
<li>Every action executed on the application during the test is linked to the part(s) of used code</li>
<li>The link between the test and the code is defined</li>
<li>A new footprint is created</li>
</ul>
<p>Thanks’ to its integration to HP Quality Center; the operation is very simple and automated. For each test execution, the process is automatically run and a new footprint is created. And in case the test has already been executed, the new footprint will be compared to the previous one; if changes happened, they are immediately identified.</p>
<h3>Secured Go-live decision</h3>
<p>Thanks to the Test Learning System, the Go decision is safe. Indeed, the real risks coverage is 100% known. If all tests are validated, then no unknown risk can impede the production.</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/QcACDf-n33g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Tests/testers-maximize-test-efficiency-test-coverage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Tests/testers-maximize-test-efficiency-test-coverage/</feedburner:origLink></item>
		<item>
		<title>Developers come from Mars, and testers from Venus!</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/auXGSZzU74s/</link>
		<comments>http://blog.kalistick.com/Tests/developers-come-from-mars-and-testers-from-venus/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 07:41:16 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1775</guid>
		<description><![CDATA[The code has changed&#8230; huh? Developers and testers don’t speak the same language. This strongly reduces test teams efficiency! Developers talk about files, class or code; testers talk about test case, business needs and functional scenarios. In other words, communication isn’t working. The consequence of this misunderstanding, just like we talked about in the post [...]]]></description>
			<content:encoded><![CDATA[<h2>The code has changed&#8230; huh?</h2>
<p>Developers and testers don’t speak the same language. This strongly reduces test teams efficiency!</p>
<p>Developers talk about files, class or code; testers talk about test case, business needs and functional scenarios. In other words, communication isn’t working.</p>
<p>The consequence of this misunderstanding, just like we talked about in the post concerning <a href="http://www.kalistick.com/how-does-kalistick-works.html">test efficiency improvement</a>, is the blindness of test teams.</p>
<p>The content of received versions is a mystery, just like changes and impacts. No way to direct the test strategy toward risks. Or with extremely low confidence.</p>
<p>This communication problem is perfectly pictured by the trials of developers to make changes clearer: testers don’t get a thing! Why?</p>
<p>Release notes are aiming to point out the modifications. But in fact, the content is too technical for testers, sometimes too general or even declarative. The usefulness of these notes is then more than questionable…</p>
<p>The question is: what are the impacts of these misunderstandings?</p>
<ul class="list_arrow3">
<li>Hardly assessed regression risks</li>
<li>Difficulty to select the appropriate test scenarios</li>
<li>Impossibility to make sure the regression risks are well covered</li>
</ul>
<p>&nbsp;</p>
<p>In short, misunderstanding between developers and testers is a major source of test process inefficiency. And this generates regressions that only surface when in production.</p>
<h2>What’s up, doc?</h2>
<h3>Information with every delivery is a good start…</h3>
<p>During validation stage of a version, regression risk is increased with every new delivery (estimated to 8% of bugs found in production).</p>
<p>Executing 100% of test cases at each delivery rapidly appears as unrealizable. The shortest is the given time; the narrowest is the scenarios selection, and the more are missed regressions.</p>
<p>In order to avoid this infernal cycle, testers must get a clear vision of changes and their impacts for every delivery.</p>
<h3>Trustable information is much better !</h3>
<p>For test teams to be able to rely on this information, they must be trustable. The discussion we have with our clients shows that when the information is given on a written support by development teams, trust is lowered.</p>
<p>It seems a specific tool is needed to compare the received version to the previous one on the overall of its features (code, setup, third party libraries, etc). This would allow testers to reach the high trust level they are looking for.</p>
<h3>I have a dream… to get relevant information!</h3>
<p>Having information is essential, but this information must be usable by test teams!</p>
<p>Dealt functional requirements, dealt User Stories… These data can’t be missing for functional validation. But they are hardly usable by the test manager for defining the regression test strategy.</p>
<p>Moreover, it’s rarely comprehensive! New changes would have been done. With no record on functional requirements or anomalies most of the time.</p>
<p>Exploratory tests will try to catch related risks, but often with a very low efficiency.</p>
<p>For improving this matter, our clients helped us define 2 levels of useful information:</p>
<ul class="list_arrow3">
<li><strong>Business view</strong>, for knowing changes and their impacts. Returning information through impacted sub-sets of the software will allow targeting test efforts toward highest regression risks.</li>
<li><strong>Impact on scenarios</strong>, to identify scenarios to replay. Identifying the footprint (executed code during a test case) of every test on the software’s code will point out test cases impacted by a change.</li>
</ul>
<p>&nbsp;</p>
<h3>What if you could “Test right”?</h3>
<p>If this difficulty to communicate between dev and test teams could fade away, what could become of tests?</p>
<p>This is what we call “Right testing” (see our concept “<a href="http://www.kalistick.com/how-to-increase-software-test-efficiency.html">Smarter Testing Strategies</a>”). An open door to a new strategy which tend to solve this equation:</p>
<h2>To more efficient tests and beyond !</h2>
<p>This series on test efficiency improvement will go on in two coming articles:</p>
<ul class="list_arrow3">
<li>How to exploit test coverage to master and anticipate risks?</li>
<li>How to define a more efficient non-regression test strategy?</li>
</ul>
<p>&nbsp;</p>
<p>We will also talk in a soon article about reverse communication issue: when developers don’t receive the right level of information from testers.</p>
<p>Thus, how to analyze, diagnose and correct an anomaly? A classic problem that feed bug trackers of “un reproduced” bugs. It is also the reason why the number of deliveries needed to correct an issue is increasing.</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/auXGSZzU74s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Tests/developers-come-from-mars-and-testers-from-venus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Tests/developers-come-from-mars-and-testers-from-venus/</feedburner:origLink></item>
		<item>
		<title>Improving tests efficiency : is it possible?</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/3ogz69Pz9U4/</link>
		<comments>http://blog.kalistick.com/Tests/improving-tests-efficiency-is-it-possible/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 10:05:24 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/fr/?p=1633</guid>
		<description><![CDATA[We like to share impressions with our clients. Regarding our platform or even other issues they are facing and possible solutions. Based on these observations, one thing stands out: improving test efficiency is a major challenge for almost all of them. One more thing they have in common: trying to achieve better efficiency, they are [...]]]></description>
			<content:encoded><![CDATA[<p>We like to share impressions with our clients. Regarding our platform or even other issues they are facing and possible solutions.</p>
<p>Based on these observations, one thing stands out: improving test efficiency is a major challenge for almost all of them.</p>
<p>One more thing they have in common: trying to achieve better efficiency, they are always slowed down by the same problems, again and again…</p>
<p>We decided to share with you these problems that are poisoning a lot of test teams. Then, we will introduce the solutions that our clients have implemented for their testing.</p>
<h2>Why test teams need more efficiency?</h2>
<h3>Top 3 major and recurring issues</h3>
<p>According to our clients, 95% of them encounter 3 major issues while testing:</p>
<ul class="style-none list_arrow3">
<li><strong>Increasing complexity of software:</strong> no more monolithic and autonomous applications, welcome to endless inter-integrations (through web services for instance). These integrations are increasing risks with every evolution and make testing more complex. Better testing become unavoidable: despite increasing risks, time and people allocated to software testing remain the same.</li>
<li><strong>Acceleration of the pace of versions</strong>: application’s evolutions are a must for business teams. New versions may contain fewer evolutions, but tests aren’t much easier. Of course there is no way to re-test all over every time. Better test strategies are then essential.</li>
<li><strong>Endless modification on every level</strong>: new functionalities are added to applications; new applications are added to IS… In summary: a ton of new risks are added. Quality requirements might not change, but means are never increased either!</li>
</ul>
<p>&nbsp;</p>
<p>Two weeks ago, a client was telling us about his rather unpleasant experience:</p>
<div>
<div class="testimonial">
<blockquote><p>« Every time we go in production, feedback is very fast. We rapidly reach a hundred users, and the way they use the software, if there are hidden bugs, they find them very quick. If the bug is a stop, we got a quick and violent feedback. Covering this risk is a top priority and we must increase our testing efficiency. »</p></blockquote>
<p><span class="by"></span></div>
</div>
<h3>Identified inefficiency sources</h3>
<p>Beyond the increasing need of efficiency, our clients share three important sources of efficiency loss during testing:</p>
<ul class="style-none list_arrow3">
<li>A bad visibility on delivered version content</li>
<li>Low quality modifications</li>
<li>A high number of iterations to validate a new version</li>
</ul>
<p>&nbsp;</p>
<h2>3 cannonballs testers are chained to</h2>
<h3>No good test without good visibility</h3>
<p>In most cases, test teams complain about the lack of visibility on developments made by project teams. The impacts can’t be clearly identified and it is not possible to turn the test strategy toward these risks (or with a very limited confidence).</p>
<p>This bad visibility is due to multiple situations:</p>
<ul class="style-none list_arrow3">
<li><strong>Test teams and dev teams work in a “silo” mode</strong>. This mainly happens when development is externalized to a contractor, but not only.</li>
<li><strong>Developers and testers work together in the same open space</strong>; but they don’t speak the same language! When developers say file, class or code, testers want to hear about test case, business need and functional scenario.</li>
</ul>
<p>&nbsp;</p>
<p>The first attempts to improve it are the release notes. Here again, the content is too technical to be used by testers, sometimes too general (just a list of requirements associated to the delivery) or even just declarative and judged not reliable enough.</p>
<p>Consequently, functional validation manager can’t get a clear picture of modifications and their impacts to select the appropriate scenarios to cover risks.</p>
<p>To better understand the consequence of the lack of visibility, here is a customer case:</p>
<p><em><span style="text-decoration: underline;">4 days before validation ending </span></em><em>–</em>a last version of the software just arrived. It contains 10 fixes that have to be validated and we have to make sure no regression have been introduced.</p>
<div class="box box-light">
<div class="box-title">Customer case</div>
<div class="box-content">
<p><em><span style="text-decoration: underline;">D-DAY-4</span></em><em> –</em> evaluation of changes perimeter:</p>
<ul class="style-none list_arrow3">
<li><strong>Are there only the 10 announced fixes?</strong> Not 100% sure…</li>
<li><strong>What are the impacts of these changes on the overall functionalities?</strong> We don’t even know the exact changes, so knowing the impacts…</li>
<li><strong>What about regression risks?</strong> Impossible to evaluate accurately. We chose to validate the fixes first, and then we’ll go on the usual priority regression tests.</li>
</ul>
<p>&nbsp;</p>
<p><em><span style="text-decoration: underline;">D-DAY-2</span></em><em> &#8211; </em>Regressions are showing up on theatrically unmodified features.</p>
<ul class="style-none list_arrow3">
<li>An urgent new version including new fixes is required!</li>
<li>We urgently validate these fixes but we can’t go further with non-regression testing.</li>
</ul>
<p>&nbsp;</p>
<p><em><span style="text-decoration: underline;">All good, we go live to production</span></em>, but… first feedbacks: bugs and unhappy users! Where do the bugs come from? That’s a good question…</p>
</div>
</div>
<p>Not only this circumstance generates bugs that will be found when the software is on production, but moreover, finding the bug’s source will be particularly difficult.</p>
<h3>Low development quality: an obstacle for testers</h3>
<p>Development low quality has a strong impact on business test teams. The link might not be obvious, but we often encounter this context:</p>
<ul class="style-none list_arrow3">
<li><strong>Frequent regressions on every delivery</strong> as the code is hardly maintainable: any change is very hazardous. A real case with got with many clients: copy / paste in the code. This means more iteration to correct the same bug everywhere!</li>
<li><strong>Technical anomaly found by business testers </strong>that are very hard to reproduce, to document and thus to correct. These anomalies are generally classified as “not reproduced” but surface in production context.</li>
<li><strong>A development team that prefer delivering on time </strong>even if they didn’t pass all the necessary technical tests (sometimes with little unfinished development). As a result, many changes in the next delivery (back to “Lack of visibility point”!) and test results very questionable. A very common regression source!</li>
</ul>
<p>&nbsp;</p>
<p>The lack of quality is not noticeable only in production. With “black box” tests, linking certain issues and their origin is very difficult. Yet, if this “black box” could be opened, the link is obvious!</p>
<h3>Number of deliveries: a key performance indicator ?</h3>
<p>To every new delivery in a validation stage, there is an associated risk that generally is badly handled. Any change can question the result of an already passed test while the risk won’t even be perceived!</p>
<p>Many studies, like the ones of IBM and Caper Jones, are pointing that the impact of such circumstance is huge:</p>
<div>
<div class="testimonial">
<blockquote><p>“5 to 8% of anomalies found in production are coming from changes done during test stage.”</p></blockquote>
<p><span class="by">IBM &amp; Caper Jones</span></div>
</div>
<p>In order to avoid this situation, some companies choose to delay the non-regression test campaigns. But it is impossible to delay it forever, and issues always catch them up.</p>
<p>Thus, tests perception is degraded: they look useless whereas test team is doing its best to avoid the problems. The team tries to adapt test plans to each delivery and increase the test efforts when approaching the deadline.</p>
<h2>Improving test quality: a dead end ?</h2>
<p>There are solutions out on the market that allow test teams to focus and anticipate these problems that undercut their efficiency. We will analyze the solutions our clients implemented in an article series to come. We will talk about how to:</p>
<ul class="style-none list_arrow3">
<li>Get a good visibility on received releases</li>
<li>Exploit test coverage in order to manage and anticipate risks</li>
<li>Define a non-regression test strategy really efficient</li>
</ul>
<p>&nbsp;</p>
<p>Meanwhile, if your company is facing problems we didn’t talk about; please share with us in the comments!</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/3ogz69Pz9U4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Tests/improving-tests-efficiency-is-it-possible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Tests/improving-tests-efficiency-is-it-possible/</feedburner:origLink></item>
		<item>
		<title>Kalistick’s video: what do you think about it?</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/JZd5Ymgo8vg/</link>
		<comments>http://blog.kalistick.com/Kalistick/kalisticks-video-what-do-you-think-about-it/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 09:21:10 +0000</pubDate>
		<dc:creator>Julien Liabeuf</dc:creator>
				<category><![CDATA[Kalistick]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/fr/?p=1655</guid>
		<description><![CDATA[After a few days of work, we finally finished our introduction video ! We needed a new way to introduce Kalistick, more friendly and dynamic. The video seemed to be the perfect mean to quickly present our product (1 min 10) in a simple way. But what kind of video ? After a bit of [...]]]></description>
			<content:encoded><![CDATA[<p>After a few days of work, we finally finished our introduction video !</p>
<p>We needed a new way to introduce Kalistick, more friendly and dynamic. The video seemed to be the perfect mean to quickly present our product (1 min 10) in a simple way. But what kind of video ?</p>
<p>After a bit of hesitation, we stopped our choice on an After Effect template. A few days of customization to make it match our needs, and the first feedbacks: mostly positive.</p>
<p>Enough talks, here is the video (720p available for full screen):</p>
<p><iframe width="640" height="390" src="http://www.youtube.com/embed/kgQa0zq1GvU?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe>
<p>We tried to convey our main point:</p>
<p><strong>How to anticipate risks and to make sure the application is well covered by tests during testing process, so to lower regressions.</strong></p>
<p>We answered that by the 4 strenght of our platform:<br /> 
<ul class="style-none list_arrow3"></p>
<ul>
<li>See changes and impacts</li>
<li>Focus on the right strategy</li>
<li><a href="http://www.kalistick.com/test-coverage-insights.html">Control test coverage</a></li>
<li>Secure Go-live decision</li>
</ul>
</ul>
<p>So what is your opinion ? Do you think this video is clear and dynamic enough ?</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/JZd5Ymgo8vg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Kalistick/kalisticks-video-what-do-you-think-about-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Kalistick/kalisticks-video-what-do-you-think-about-it/</feedburner:origLink></item>
		<item>
		<title>Why Java folks should stop looking down on C# [3/4] The ecosystem</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/bXhB-j79xOU/</link>
		<comments>http://blog.kalistick.com/Java/why-java-folks-should-stop-looking-down-on-c-the-ecosystem/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 12:17:39 +0000</pubDate>
		<dc:creator>Julien Hoarau</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1533</guid>
		<description><![CDATA[At Kalistick we are a Java shop from the beginning: the first version of our product analyzed only Java code. But we are not bigot, we are using and analyzing C# too since 2008. We notice that Java developers generally tend to look scornfully at C#, as a copycat created by Microsoft and used by [...]]]></description>
			<content:encoded><![CDATA[<p>At Kalistick we are a Java shop from the beginning: the first version of our product analyzed only Java code. But we are not bigot, we are using and analyzing C# too since 2008. We notice that Java developers generally tend to look scornfully at C#, as a copycat created by Microsoft and used by dummies. In theses blog series, I am going to try to sweep this nonsense and show some of the C# goodness.</p>
<p>In the previous posts, I talked about the C# language: its differences with Java and its &#8220;unique&#8221; features. In this one, I am going to introduce the ecosystem. A language can be the best one in the world if its platform and tools are not as good, it will be useless. That is why I will focus, in this post, on the .NET platform in a whole: framework, libraries and tools. The time when knowing the language in and out only was enough is long time gone now.</p>
<ul>
<li>Part 1: <a href="http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/">Differences in similarities</a></li>
<li>Part 2: <a href="http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-csharp-a-brand-new-world/">A brand new world</a></li>
<li>Part 3: <strong>The ecosystem</strong></li>
</ul>
<p><span id="more-1533"></span></p>
<h2>No good building without a good foundation.</h2>
<p>Apart from the language itself, the standard framework is the part with which you interact the most. It is crucial that this framework provides facilities for basic day-to-day operations needed when writing an application, like reading/writing a file, parsing a text or sending a request over the network.</p>
<p>Long story short, the .Net Framework base classes offer the same features as Java, but in general they are more intuitive, easier to use and more concise compared to Java.</p>
<p>Let’s compare some basic operations.</p>
<h4>String manipulation</h4>
<p>String manipulation is a big chunk of the programming job.</p>
<p>Have you ever needed to check string references equality? String is more a Value Object than an Entity, we are only interested by its attribute not by its identity. So it is inconvenient that we cannot use the == operator in Java for checking equality. Thanks to operator overloading, in C# you can compare two strings either with the equals method or the equality operator. This seems insignificant but it is a frequent source of confusion in Java (we check this violation on our platform), it is even more error-prone because the equality operator can sometimes lead to the expected results due to string interning.</p>
<p><a href="http://xkcd.com/208/">Regular expression</a> constitutes a significant part of string manipulation; Regex manipulation is eased in C#, thanks to verbatim strings and named captures. Verbatim string helps prevent cluttering of the regular expression with escaping characters; named captures give names to group, making the regex easier to read.</p>
<pre class="brush: csharp; title: ; notranslate">Regex urlRegex =
  new Regex(@&quot;\\b(&lt;protocol&gt;https?|ftp)://(&lt;domain&gt;[-A-Z0-9.]+)(&lt;file&gt;/.*)?&quot;);
string domain = urlRegex.Match(&quot;https://cockpit.kalistick.fr&quot;).Groups[&quot;domain&quot;].Value;</pre>
<h4>File IO</h4>
<p>File IO is a fairly common operation and should be painless. In Java, without third-party library this is not true. Java beginners often ask what it is the best way to read of file, they do not know if they need to use a <code>FileReader</code>, a <code>FileInputStream</code>, a <code>BufferedReader</code> or a <code>Scanner</code>.</p>
<pre class="brush: csharp; title: ; notranslate">// In C#
string s = System.IO.File.ReadAllText(path);

// Equivalent in Java
String s = null;
FileInputStream stream = new FileInputStream(path);
try {
  Reader reader = new BufferedReader(new InputStreamReader(stream)); // Use default encoding
  StringBuilder builder = new StringBuilder();
  char[] buffer = new char[8192];
  int read;
  while ((read = reader.read(buffer, 0, buffer.length)) &amp;gt; 0) {
      builder.append(buffer, 0, read);
  }
  s = builder.toString();
} finally {
  stream.close(); // Potential issue if this throws an IOException,
}</pre>
<p>Of course with a third-party library, this can be done in one line (Apache Commons IO for example).</p>
<h4>Date manipulation</h4>
<pre class="brush: csharp; title: ; notranslate">// In C#
DateTime now = DateTime.Now;
DateTime nextWeek = now.AddDays(7);

// Equivalent in Java
Date now = new Date();
Calendar c = Calendar.getInstance();
c.setTime(now);
c.add(Calendar.DATE, 7);</pre>
<p>(Use <a href="http://joda-time.sourceforge.net/">JODA Time</a> for date manipulation in Java)</p>
<h4>Concurrency</h4>
<p>Before .NET 4, C# was behind Java concurrency-wise. But now it offers the same functionality than Java and even more.</p>
<pre class="brush: csharp; title: ; notranslate">// Parallel For
int[] numbers = { 2, 5, 8, 4, 7, 9, 13 };
int[] squaredNumbers = new int[numbers.Length];
Parallel.For(0, numbers.Length, i =&amp;gt;
  squaredNumbers[i] = (int)Math.Pow(numbers[i], 2)
);

// Parallel LINQ
var fibonacciNumbers = numbers.AsParallel().Select(n =&amp;gt; ComputeFibbonacci(n));</pre>
<p>To sum up, I find the .Net framework base classes easier to use and more intuitive, in general, than their Java equivalent but all the third-party libraries available in Java alleviates this point. (Apache Commons, Guava, Joda time&#8230;)</p>
<h3 id="pk">Good Artists Borrow, Great Artists Steal</h3>
<p>Many C# open source library are a direct port of successful Java library. They have since evolved to take advantage of the C# benefits, promoting DSL-like syntax instead of XML configuration file, but at the beginning they were direct &#8220;rip-off&#8221; of their Java equivalent.</p>
<ul>
<li>Hibernate =&gt; <a href="http://community.jboss.org/wiki/NHibernateForNET">NHibernate</a></li>
<li>Spring =&gt; <a href="http://www.springframework.net/">Spring.NET</a></li>
<li>Log4J =&gt; <a href="http://logging.apache.org/log4net/index.html">Log4Net</a></li>
<li>JUnit =&gt; <a href="http://www.nunit.org/">NUnit</a></li>
<li>&#8230;</li>
</ul>
<p>Example of a &#8220;fluent&#8221; NHibernate mapping:</p>
<pre class="brush: csharp; notranslate" title="">
public class CatMap : ClassMap
{
  public CatMap()
  {
    Id(x =&gt; x.Id);
    Map(x =&gt; x.Name).Length(16).Not.Nullable();
    Map(x =&gt; x.Sex);
    References(x =&gt; x.Mate);
    HasMany(x =&gt; x.Kittens);
  }
}

&lt;!-- Equivalent XML mapping --&gt;
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
  namespace="QuickStart" assembly="QuickStart"&gt;  

  &lt;class name="Cat" table="Cat"&gt;
    &lt;id name="Id"&gt;
      &lt;generator class="identity" /&gt;
    &lt;/id&gt;  

    &lt;property name="Name"&gt;
      &lt;column name="Name" length="16" not-null="true" /&gt;
    &lt;/property&gt;
    &lt;property name="Sex" /&gt;
    &lt;many-to-one name="Mate" /&gt;
    &lt;bag name="Kittens"&gt;
      &lt;key column="mother_id" /&gt;
        &lt;one-to-many class="Cat" /&gt;
      &lt;/bag&gt;
  &lt;/class&gt;
&lt;/hibernate-mapping&gt;
</pre>
<h2>Frameworks: one vendor to rule them all</h2>
<h4>Desktop application</h4>
<p>Once the platform of choice, the desktop is becoming less and less important with the rising of web application. Nevertheless, desktop applications are still significant and cannot be ignored.</p>
<p>For a cross-platform desktop application, you do not have much choice but to choose Java. But if your audience is Windows only you should consider using the .NET Framework. Two API are available: WinForm which is a wrapper around the old Win32 API and WPF which uses DirectX and provides vector graphics allowing elements to be scaled without loss in quality.</p>
<p>WPF employs XAML, a derivative of XML, to define the UI in a declarative way, allowing the developer to describe the interface and behavior without the use of procedural programming. The use of XAML provides a better separation of model and view and allows designers to contribute to the application development cycle more.</p>
<pre class="brush: csharp; notranslate" title="">&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Xaml Example" Height="290" Width="300" Background="#eee"&gt;
  &lt;StackPanel Margin="10"&gt;
    &lt;ScrollViewer Height="200" Width="260" Margin="0 0 0 10"
                  VerticalScrollBarVisibility="Auto"
                  HorizontalScrollBarVisibility="Auto"&gt;
      &lt;TextBlock Text="{Binding TextContent}" Background="#fff"/&gt;
    &lt;/ScrollViewer&gt;

    &lt;StackPanel HorizontalAlignment="Left" Orientation="Horizontal"&gt;
      &lt;TextBox x:Name="TheLineTextBox"
               Text="{Binding TheLine, UpdateSourceTrigger=PropertyChanged}"
               Width="205"
               Margin="0 0 5 0"
               KeyUp="TheLineTextBox_KeyUp"/&gt;
      &lt;Button Content="Enter"/&gt;
    &lt;/StackPanel&gt;
  &lt;/StackPanel&gt;
&lt;/Window&gt;</pre>
<p>Desktop application development is an area where the .Net framework shines.</p>
<h4>The Web</h4>
<p>For a long time while the .NET community was dragging and dropping controls onto an ASP.net page, the Java community was building highly scalable web application using one of many web frameworks available. Here is the difficulty… information overload.  If you take a look at the list of Java web frameworks, you can see there are many of them to choose from, and each one requires pretty extensive research to understand.</p>
<p>Until 2008, Web development in C# was analogous to ASP.Net and Web Forms. The main purpose of Web Forms was to ease the transition to the web development for people with a desktop development background. Same skills are transferable between the two, for example you can handle button clicks with events and delegates like you will do in a desktop application and all of the complexity is handled by ViewState and PostbackModel. The flaw of this is that it tries to inject state into what should be stateless: the web. The beauty of this model is its flaw too: by simplifying web development it abstracts and hides the inner bolts from the developer and produces developers who don’t understand the basics.  Clean applications with separation of concern are feasible with Web Forms but require more discipline, everything is done to push you into using the RAD tools.</p>
<p>On the other hand, ASP.Net MVC, the new web framework of Microsoft, is a more lower-level component, closer to the standard method of Web Development. It looks like the other MVC frameworks that could be found in Java (Spring MVC) or in Ruby on Rails.</p>
<h4>Rich Internet Application (RIA)</h4>
<p>Both Java and .Net have competitors to Adobe Flex and Air. JavaFX is the RIA framework of Java, but it never took off.</p>
<p>Silverlight is the one for .NET, it is like a subset of WPF aiming rich internet application. It uses the same tool Visual Studio, Expression Blend, the same UI syntax XAML and a subset of the .NET Framework.</p>
<p>These last four years, Microsoft have brought Silverlight to the fore, releasing a new version at a rapid pace. That way it manages to reach a penetration rate of <a href="http://www.riastats.com">73% (June 2011)</a>, which is quite good but still low compared to the <a href="http://www.riastats.com">97%</a> penetration rate of Flash.</p>
<p>The problem is that Microsoft seems to have a change of mind and they are now gone full in the HTML5 bandwagon, leaving the Silverlight developers doubtful. That&#8217;s the problem with languages and tools lead by a unique vendor, you are dependent of its internal politics.</p>
<h4>Mobile</h4>
<p>Mobile development is the new battleground, and I am afraid that Microsoft has already lost, killed by Apple and Google. The choice of language and platform is more driven by adoption than by convenience. It’s sad because the tools provided by Microsoft for Windows Phone 7 development are very nice: C#, Silverlight, XNA, Visual Studio, Expression Studio.</p>
<p>To sum up, nothing that can be done in Java that cannot be done in C# but you’ll have less choice in your framework choice in the .NET ecosystem than in Java. This is bad per se but avoids the information overload and the scattering that can be found in Java.</p>
<h2>&#8220;A workman is only as good as his tools&#8221;</h2>
<p>A comparison would not be complete without the comparison of the tools. As important as the framework, tools can make a hard job seems easy and inversely.</p>
<p>Visual Studio, the IDE from Microsoft, is the official choice for .Net development. It offers the same features that can be found in a Java IDE and some more like IntelliTrace, a historical debugger that records all events and allows the code execution to be rewound for debugging (an equivalent exist in Java: <a href="http://www.chrononsystems.com/">Eclipse Chronon</a>), but also an architectural and modeling module allowing to draw a dependency graph of the application and check them (A bit like what we do in the Cockpit with the technical architecture) and more&#8230; Unfortunately, all these features have a cost and Visual Studio is neither free nor cheap.</p>
<p>Open source IDE exist too: <a href="http://sharpdevelop.net/opensource/sd/">SharpDevelop</a> and <a href="http://monodevelop.com/">MonoDevelop</a> (develop by the Mono team), they have less features than Visual Studio but evolve quickly. The good point is that, unlike Java IDE, they all share a common project file, so you can switch back and forth between them. In Java, you will have to use a Maven POM file to have a similar feature.</p>
<h2>Write once, run&#8230;somewhere</h2>
<p>&#8220;Write once, run everywhere&#8221; is the slogan created by Sun to promote the cross-platform benefits of the Java language. The same slogan cannot be used for .Net but the situation is not as limited as people may think, C# and .Net in general are not for Windows only.</p>
<h4>Silverlight</h4>
<p>As I have explained earlier in this post, Silverlight is the Rich Internet Application framework of .Net, Silverlight application can run on Windows of course but also on Mac and Linux (the Mono team develops the linux port, under the name of <a href="http://www.mono-project.com/Moonlight">MoonLight</a>, with the cooperation of Microsoft). Silverlight is also used for Windows Phone 7 development.</p>
<h4>XNA</h4>
<p><a href="http://create.msdn.com/">XNA</a> is a set of tools for game development and management in C#. Targeting indie game developers, it allows them to develop games in C# for Windows, Windows Phone 7 and the Xbox 360.</p>
<div id="attachment_1553" class="wp-caption aligncenter" style="width: 610px"><a href="http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-the-ecosystem/attachment/lumi/" rel="attachment wp-att-1553"><img class="size-large wp-image-1553 " title="Lumi" src="http://blog.kalistick.com/wp-content/uploads/2011/06/Lumi-600x326.jpg" alt="" width="600" height="326" /></a>
<p class="wp-caption-text">Lumi &#8211; A game created with XNA</p>
</div>
<h4>Mono</h4>
<p>Mono is a free and open source project led by Xamarin (formerly by Novell) to create a .NET-compatible set of tools. Mono brings C# and the .Net framework not only on Linux but also on BSD, Solaris and even on the Wii.</p>
<p>The Mono team also develops MonoTouch that allows developers to create C# and .NET based applications that run on the iPhone, iPad, and iPod Touch devices, while taking advantage of the iOS APIs. As well as MonoDroid which is the equivalent of MonoDroid for Android devices and MonoMac for developing Mac OS application.</p>
<h4>Netduino</h4>
<p>Like for Java, the .NET framework comes in several edition:</p>
<ul>
<li>.NET Framework, equivalent to Java SE/EE</li>
<li>The Compact Framework, equivalent to Java ME</li>
<li>The Micro Framework, the smallest edition, targeting embedded device development. For example, a specific version of the Arduino (an open-source single-board microcontroller): the <a href="http://netduino.com/">Netduino</a> uses the Micro Framework.</li>
</ul>
<h2>It&#8217;s a wrap</h2>
<p>In this post I have presented the .NET ecosystem which essentially offers the same features than Java but with a limited diversity/choice. Starting a project using .Net is more straightforward, you almost don&#8217;t have to search for a given solution. That can save you a considerable amount of time. But if the solution doesn&#8217;t fit your need, fewer  alternatives are available.</p>
<p>In the last post of this series I am going to present the .Net community to see if it can match the very strong one of Java.</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/bXhB-j79xOU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Java/why-java-folks-should-stop-looking-down-on-c-the-ecosystem/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Java/why-java-folks-should-stop-looking-down-on-c-the-ecosystem/</feedburner:origLink></item>
		<item>
		<title>Why Java folks should stop looking down on C# [2/4] A brand new world</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/lfS0QrLb3T8/</link>
		<comments>http://blog.kalistick.com/Java/why-java-folks-should-stop-looking-down-on-c-24-a-brand-new-world/#comments</comments>
		<pubDate>Mon, 30 May 2011 09:32:38 +0000</pubDate>
		<dc:creator>Julien Hoarau</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=1019</guid>
		<description><![CDATA[At Kalistick we are a Java shop from the beginning: the first version of our product analyzed only Java code. But we are not bigot, we are using and analyzing C# too since 2008. We notice that Java developers generally tend to look scornfully at C#, as a copycat created by Microsoft and used by [...]]]></description>
			<content:encoded><![CDATA[<div>At Kalistick we are a Java shop from the beginning: the first version of our product analyzed only Java code. But we are not bigot, we are using and analyzing C# too since 2008. We notice that Java developers generally tend to look scornfully at C#, as a copycat created by Microsoft and used by dummies. In theses blog series, I am going to try to sweep this nonsense and show some of the C# goodness.</div>
<div>In the previous post, I showed the “minor” differences between C# and Java in features shared by the two languages. In this post, I am going to show you the <span class="ks-strong">features that truly differentiate C# from Java</span>.</div>
<ul>
<li>Part 1: <a href="http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/">Differences in similarities</a></li>
<li>Part 2: <strong>A brand new world</strong></li>
</ul>
<p><strong><span id="more-1019"></span></strong></p>
<h2>Delegate: Method as a first-class citizen</h2>
<p>A delegate is a special type that <span class="ks-strong">defines a method signature</span>. Delegates are like C <span class="ks-strong">function pointers with type safety</span> that allow methods to be passed as parameters and stored in a structure or a class.</p>
<pre class="brush: csharp; notranslate" title="">// Declaration of a delegate type
delegate string StringOperation(string str); 

public class Delegates
{
  public static string Reverse(string str) // doesn't support full unicode charset
  {
    char[] arr = str.ToCharArray();
    Array.Reverse(arr);
    return new string(arr);
  }

  public static void Main(string[] args)
  {
    StringOperation normalizeOp;

    // Creation of a delegate instance
    normalizeOp = Delegates.Reverse;
    Console.WriteLine(normalizeOp("abcd")); // dcba

    // Instantiate the delegate using an anonymous method.
    normalizeOp = delegate(String str) { return str.Trim(); };
    Console.WriteLine(normalizeOp("  abcd "));  // abcd
  }
}</pre>
<p>To mimic this feature in Java, the developer will have to create a class implementation (generally an anonymous inner class) where one method performs the action.</p>
<pre class="brush: csharp; notranslate" title="">interface StringOperation
{
  String invoke(String str);
}

public class Delegates
{
  public static String reverse(String str)
  {
    return new StringBuffer(str).reverse().toString();
  }

  public static void main(String[] args)
  {
    StringOperation normalizeOp;

    normalizeOp = new StringOperation(){
      public String invoke(String str)
      {
      	return Delegates.reverse(str);
      }
    };

    System.out.println(normalizeOp.invoke("abcd")); // dcba

    normalizeOp = new StringOperation(){
      public String invoke(String str)
      {
      	return str.trim();
      }
    };

    System.out.println(normalizeOp.invoke("  abcd ")); // abcd
  }
}</pre>
<p>The ability to refer to a method as a variable or as a parameter makes delegates ideal for a lot of usage, delegates are used everywhere in C#, as event handlers, thread actions, callbacks in asynchronous programming, in LINQ&#8230;</p>
<h2>Event</h2>
<p>In a GUI environment, any number of controls can raise an event (button click, menu selection, completion of a file transfer). Other classes will be interested in responding to these events but the publisher of the event is not interested by how classes receiving the event will respond. C# provide a specific syntax to enable <span class="ks-strong">event-driven programming</span> implementing the <span class="ks-strong">publish/subscribe pattern</span>.</p>
<pre class="brush: csharp; notranslate" title="">class Button
{
  public delegate void Action();
  public event Action Click;

  public void PerformClick()
  {
    OnClick();
  }

  private void OnClick()
  {
    if (Click != null)
    {
      Click();
    }
  }
}

class Program
{
  static void PerformAction()
  {
    Console.WriteLine("Work!");
  }

  public static void Main()
  {
    Button button = new Button();

    // Subscribe to the event
    button.Click += PerformAction;
    button.PerformClick(); // Work!

    // Unsubscribe
    button.Click -= PerformAction;
    button.PerformClick(); // Nothing
  }
}</pre>
<p>In Java, there is no general mechanism for event handling, instead events are manually implemented with the <a href="http://en.wikipedia.org/wiki/Observer_pattern">observer pattern</a>: anonymous inner classes are commonly used to implement the listener, allowing the developer to define the body of the class and create an instance of it in a single point in the code.</p>
<pre class="brush: csharp; notranslate" title="">public interface ClickListener extends EventListener
{
  public void click();
}

public class Button
{
  protected EventListenerList listenerList = new EventListenerList();

  public void addMyEventListener(ClickListener listener)
  {
    listenerList.add(ClickListener.class, listener);
  }

  public void removeMyEventListener(ClickListener listener)
  {
    listenerList.remove(ClickListener.class, listener);
  }

  public void performClick()
  {
    onClick();
  } 

  void onClick()
  {
    Object[] listeners = listenerList.getListenerList();
    for (int i=0; i&lt;listeners.length; i+=2)
    {
      if (listeners[i]==ClickListener.class)
      {
        ((ClickListener)listeners[i+1]).click();
      }
    }
  }
}

public class Program
{
  public static void main(String[] args)
  {
    Button button = new Button();
    button.addMyEventListener(new ClickListener() {
      public void click(EventArgs evt)
      {
        System.out.println("Work!");
      }
    });

    button.performClick();
  }
}</pre>
<h2>Lambda Expression: Delegate on steroids</h2>
<p><span class="ks-strong">A lambda expression is an anonymous function</span> that can be used to create delegates. Syntacticly it is composed of three parts: an input parameters list, the lambda operator <code>=&gt;</code>, and a method body. Thanks to type inference, you often do not have to specify a type for the input parameters: the compiler can infer the type based on the body and the underlying delegate type.</p>
<pre class="brush: csharp; notranslate" title="">delegate bool Assertion(int value);

// Equivalent to (int x) =&gt; x == 42;
Assertion isUniverseAnswer = x =&gt; x == 42;
isUniverseAnswer(42); // true</pre>
<p>One of the most important features of Lambda Expressions (and anonymous methods) is that they <span class="ks-strong">execute in the context of their declaration</span>. Therefore, they can use the values of variables defined in that context.</p>
<pre class="brush: csharp; notranslate" title="">List&lt;User&gt; FindAllYoungerThan(List&lt;User&gt; users, int limit)
{
  // The lambda expression uses the outer variable "limit"
  return users.FindAll(user =&gt; user.Age &lt; limit);
}</pre>
<p>Lambda expressions can be used to implement <span class="ks-strong">closures</span>. Closures can be defined as functions that capture the state of the environment that is in scope where they are declared.</p>
<pre class="brush: csharp; notranslate" title="">delegate void Action();

static Action CreateAction()
{
  int counter = 0;</pre>
<pre class="brush: csharp; notranslate" title="">  // Returns a delegate, the action is not executed here.
  return () =&gt; Console.WriteLine("counter={0}", counter++);
}

void Main()
{
  Action action = CreateAction();
  action(); // counter=0
  action(); // counter=1
}</pre>
<h2>LINQ&#8217;s awakening</h2>
<p>LINQ (Language-Integrated Query) is a set of technologies based on the <span class="ks-strong">integration of query capabilities directly into C#</span>. With LINQ, <span class="ks-strong">queries are a first-class language construct</span>.</p>
<pre class="brush: csharp; notranslate" title="">IEnumerable&lt;int&gt; query =
              from user in users
              select user.Age;</pre>
<p>Query expressions are written in a declarative query syntax allowing filtering, ordering, and grouping operations. The <span class="ks-strong">same query expression could be used to query and transform data in from various sources</span>: databases, datasets, XML documents, and collections. A single query can retrieve data from a SQL database, and produce an XML stream as output. The execution of the query is deferred until the result is requested. <span class="ks-strong">Deferred execution</span> can greatly improve performance when manipulating large data collections with a series of <span class="ks-strong">chained queries</span> or manipulations.</p>
<pre class="brush: csharp; notranslate" title="">// 1. DataSource
int[] numbers = new int[] { 0, 1, 2, 3, 4, 5, 6 };

// 2. Query creation.
IEnumerable&lt;int&gt; numQuery = from num in numbers
                            where (num % 2) == 0
                            select num;

// 3. Query execution.
foreach (int num in numQuery)
{
  Console.Write("{0,1} ", num); // 0 2 4 6
}</pre>
<p>There is no magic behind LINQ: at compile time, query expressions are converted to <strong>standard method calls</strong> using query operators.</p>
<pre class="brush: csharp; notranslate" title="">IEnumerable&lt;int&gt; querySyntax =
              from user in users
              select user.Age;

IEnumerable&lt;int&gt; methodSyntax = users.Select(user =&gt; user.Age);</pre>
<h2>No more StringUtils with Extension method</h2>
<p>It is rather common to have classes full of utility methods that mostly enhance the functionalities of some other classes (<span class="ks-code">StringUtils</span>, <span class="ks-code">ArrayUtils</span>…)</p>
<p>Extension methods enable you to<span class="ks-strong"> &#8220;add&#8221; methods to existing types</span> without creating a new derived one or modifying the original. They are called as if they were instance methods on the extended type. The extension methods will hang on the type, so they will be easier to find with completion than an Util class.</p>
<pre class="brush: csharp; notranslate" title="">string reversed = "Example".Reverse();
reversed = StringUtils.Reverse("Example")</pre>
<p>Extension methods are used for LINQ to add standard query operators on existing IEnumerable types (<span class="ks-code">Select, Where, GroupBy, OrderBy, Average</span>…).</p>
<h2>Pass by reference</h2>
<p>In Java, arguments to a method are passed by value; a method operates on copies of the items passed to it instead of on the actual items: a copy of the value for primitive type and a copy of the reference for objects. Because of that simple things like swapping two numbers in a method are not easily doable in Java (must use a wrapper or some arithmetic).</p>
<p>By default, it works the same way in C# but it is possible to specify that the arguments of a method must be pass by reference. This is particularly useful when you want to create a <span class="ks-strong">method that returns more than one object</span>.</p>
<p>A common pattern in the .NET framework is the <span class="ks-strong">TryXXX pattern</span>. For example methods <span class="ks-code">int Int32.Parse(string)</span> and <span class="ks-code">bool Int32.TryParse(string, out int)</span> use this pattern, <span class="ks-code">Int32.Parse</span> is used to convert a string to an integer. The <span class="ks-code">TryParse </span>method is like the <span class="ks-code">Parse </span>method, except that <span class="ks-code">TryParse </span>does not throw an exception if the conversion fails. It eliminates the need to use exception handling in case the string cannot be successfully parsed.</p>
<pre class="brush: csharp; notranslate" title="">// Using Parse method, with exception handling
int quantity;
try
{
  quantity = int.Parse(input);
}
catch (FormatException)
{
  quantity = 0;
}

// Using TryParse
int quantity;
if (!Int32.TryParse(txtQuantity.Text, out quantity))
{
  quantity = 0;
}</pre>
<p>This feature could also be used to <span class="ks-strong">improve performance when dealing with value type</span>. When a value type is passed to a method its value is copied, if the value type is large (e.g. a 4&#215;4 matrix includes 16 floats) it is better to pass a reference of the value type instead of a copy of it.</p>
<pre class="brush: csharp; notranslate" title="">Matrix view = ...;
Matrix projection = ...;

Matrix viewProjection;
Matrix.Multiply(view, projection, out viewProjection);
// viewProjection = view * projection;</pre>
<h2>Partial type</h2>
<p>.NET is big into <span class="ks-strong">automatic code generation</span>: Visual Studio uses this for Windows Forms, Web service wrapper code creation. <span class="ks-strong">To facilitate the usage of generated code</span> it is possible to <span class="ks-strong">split the definition of a class</span>, a struct, an interface or a method over two or more source files. Each source file contains a section of the type or method definition, and all parts are <span class="ks-strong">combined when the application is compiled</span>. That way one part of the type is edited by the code generator while the other part could be edited by the developer without the risk of the generator overwriting that code later.</p>
<pre class="brush: csharp; notranslate" title="">// In file A
partial class HumptyDumpty
{
  private string name = "Humpty Dumpty";

  public void Rhyme()
  {
    Sat();
    Fall();
    TryPutTogether();
  }

  public void TryPutTogether()
  {
    string putTogether = @"All the king's horses and all the king's men
                           Couldn't put Humpty together again.";
    Console.WriteLine(putTogether);
  }
}
// In file B
partial class HumptyDumpty
{
  void Sat()
  {
    Console.WriteLine("{0} sat on a wall,", name);
  }

  void Fall()
  {
    Console.WriteLine("{0} had a great fall.", name);
  }
}</pre>
<p>One useful usage is unit testing: the set of unit tests for a class is often much larger than the class implementation itself; the tests could be split into chunks using partial types. That way it is easier to work with the test suite but all the tests could still be run in one session (it is still a single test class).</p>
<h2>Is that all?</h2>
<h4>Dynamic</h4>
<p>Since version 4, C# provides a <code>dynamic</code> type. The main point is <span class="ks-strong">interoperability </span>with COM API (Office API for example) and dynamic language such as IronPython or IronRuby (Python and Ruby running on the CLR). This feature will not be used by many developers in their day-to-day coding, but it can be useful and the cleaner way in some situation.</p>
<p>Example of C# code calling a python method through dynamic and IronPython.</p>
<pre class="brush: csharp; notranslate" title="">ScriptRuntime py = Python.CreateRuntime();
dynamic random = py.UseFile("random.py");

int[] items = new int[]{0,1,2,3,4,5};

random.shuffle(items);</pre>
<h4>Null-coalescing operator</h4>
<p>The null-coalescing operator <code>??</code> is used to define a default value. It is like a conditional binary operator tweaked for null value.</p>
<pre class="brush: csharp; notranslate" title="">string address = user.BillingAddress ??
                 user.ShippingAddress ??
                 user.ContactAddress;

// Equivalent to:
string address = user.BillingAddress;
if (address == null)
{
  address = user.ShippingAddress;
  if (address == null)
  {
    address = user.ContactAddress;
  }
}</pre>
<h4>Automatic Resource Management</h4>
<p>The <code>using</code> keyword provides an easy way to manage resource by handling resource disposal automatically.</p>
<pre class="brush: csharp; notranslate" title="">string line = String.Empty;
StreamReader reader;
try
{
  reader = new StreamReader("file.txt"));
  line = reader.ReadLine();
}
finally
{
  if (reader != null)
    reader.Dispose();
}</pre>
<p>This sample which uses the <code>using</code> keyword is equivalent to the previous one.</p>
<pre class="brush: csharp; notranslate" title="">string line = String.Empty;
using (StreamReader reader = new StreamReader("file.txt"))
{
  line = reader.ReadLine();
}
Console.WriteLine(line);</pre>
<p><span class="ks-strong">Automatic resource management will be introduced in Java 7</span> as well (through <code>java.lang.AutoCloseable</code> interface).</p>
<pre class="brush: csharp; notranslate" title="">try ( FileInputStream in = new FileInputStream("input.txt");
       FileOutputStream out = new FileOutputStream("output.txt"))
{
  int c;
  while((c=in.read()) != -1 )
    out.write();
}</pre>
<h4>And more</h4>
<ul>
<li>Easy<span class="ks-strong"> lazy iterator</span> with <code>yield</code></li>
<li>Nullable type</li>
<li>Unsafe code</li>
<li>Conditional compilation</li>
<li>&#8230;</li>
</ul>
<h2>It&#8217;s a wrap!</h2>
<p>In this post I have showed C# features that differentiate the language from Java and which make C# a broader language with <span class="ks-strong">functional and dynamic</span> pieces, with the objective of <span class="ks-strong">improving the expressiveness of the language</span>.</p>
<p>In the following post I am going to describe the platform and infrastructure: framework, ide, build tool, continuous integration server&#8230;</p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/lfS0QrLb3T8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/Java/why-java-folks-should-stop-looking-down-on-c-24-a-brand-new-world/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/Java/why-java-folks-should-stop-looking-down-on-c-24-a-brand-new-world/</feedburner:origLink></item>
		<item>
		<title>Why Java folks should stop looking down on C# [1/4] Differences in similarities</title>
		<link>http://feedproxy.google.com/~r/kalistick_blog_en/~3/9gmqngOdhD0/</link>
		<comments>http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/#comments</comments>
		<pubDate>Fri, 20 May 2011 08:34:20 +0000</pubDate>
		<dc:creator>Julien Hoarau</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.kalistick.com/?p=897</guid>
		<description><![CDATA[At Kalistick we are a Java shop from the beginning: the first version of our product analyzed only Java code. But we are not bigot, we are using and analyzing C# too since 2008. We notice that Java developers generally tend to look scornfully at C#, as a copycat created by Microsoft and used by [...]]]></description>
			<content:encoded><![CDATA[<p>At Kalistick we are a Java shop from the beginning: the first version of our product analyzed only Java code. But we are not bigot, we are using and analyzing C# too since 2008. We notice that Java developers generally tend to look scornfully at C#, as a copycat created by Microsoft and used by dummies. In theses blog series, I am going to try to sweep this nonsense and show some of the C# goodness.</p>
<ul>
<li>Part 1: <strong>Differences in similarities</strong></li>
</ul>
<p><span id="more-897"></span></p>
<p>&nbsp;</p>
<p><a rel="attachment wp-att-1003" href="http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/attachment/croppercapture44/"></a><a rel="attachment wp-att-1004" href="http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/attachment/croppercapture45/"><img class="aligncenter size-large wp-image-1004" title="CropperCapture[45]" src="http://blog.kalistick.com/wp-content/uploads/2011/03/CropperCapture45-600x251.png" alt="" width="600" height="251" /></a></p>
<p><strong>Java and C# are more alike than they are different</strong>: both are curly-bracket languages like C and C++, both are statically, strongly and explicitly typed, both are class-based object-oriented, both are designed with runtime compilation in mind and both use garbage-collection.</p>
<p>In this post, I will focus on differences about common features that they share.</p>
<h2>Unified type system</h2>
<p>In Java the primitive types (<code>byte, int, bool, float, char</code>…) are special, they are not object-oriented and do not share a common ancestor with reference types. But they do have class type wrappers, that can be used to represent them and plug them in the Object hierarchy (i.e. Integer for int). This choice was made to improve performance.</p>
<p>On the contrary, C# has a <strong>unified type system</strong> in which all types derive from a common root type: <code>System.Object</code>, even the primitive types. So all types implement the Object methods (<code>ToString, Equal, GetHashCode</code>…), and you can do things like <code>3.ToString()</code>. Mixed with extension methods this could provide nice dsl-like syntax :</p>
<pre name="code" class="csharp">TimeSpan workingTime = 7.Hours() + 30.Minutes();</pre>
<p>The beauty is that <strong>value types are just as efficient as Java primitives</strong>, as long as the developer use them as values. Only if he tries to treat them as objects do they become heap allocated, through boxing/unboxing.</p>
<h2>Explicit virtual methods</h2>
<p><strong>In Java all methods are virtual by default</strong> (although they can be sealed by using the <code>final</code> modifier to disallow overriding) while in C# they are not. To make a method virtual in C#, the programmer must explicitly declare it virtual using the <code>virtual</code> keyword.</p>
<p>There are several reasons for this choice, the first one is performance: there is a <strong>performance overhead associated with virtual methods</strong> as they cannot be inlined normally and require an indirect call via the vtable. (Sun JVM implementation implements inlining of the most commonly called virtual methods). The second and more important issue is versioning: C# is designed so that versioning between base and derived classes in different libraries can evolve and maintain backward compatibility. For example, the introduction of a new member in a base class with the same name as a member in a derived class is completely supported by C# and does not lead to unexpected behavior. The last one is readability: the developer intent is clearly stated. In Java, if the <code>Override</code> annotation is not used you never know if the developer intent was to override the method or not.</p>
<pre name="code" class="csharp">class Meme
{
  public virtual void Spread() {}
}

class ThreeHundred : Meme
{
  public override void Spread()
  {
    Console.Write("This is sparta!");
  }
}

class Dbz: Meme
{
  // Not a method override
  public void Spread()
  {
	Console.Write("It's over nine thousaaannnd!");
  }
}</pre>
<h2>True Generic</h2>
<p>Regarding generics, Java and C# show a syntactical similarity, but when you look under the hood they have deep differences.</p>
<p>Java generics are implemented in the compiler only; the runtime has no knowledge of the generic type system. Instead, a process called <strong>type erasure</strong> transforms generics classes and methods during compilation: all generic types are replaced by their raw version and casts and checks are inserted in client code. The resulting byte code will contain no references to any generic types or parameters. Java generics are a syntactic sugar, they don&#8217;t get you any of the execution efficiency.</p>
<p>C# generics are not a language feature only, they are implemented in the CLR (Common Language Runtime, equivalent to the JVM) as well. During compilation, generics are verified for correctness, but the generation of the implementation is deferred to class-load time. Code invoking generics are fully compiled and can safely assume generics to be type-safe. This is called <strong>reification</strong>. Unlike with Java, there is no need to inject casts or type-checks. Generic types and methods can be constructed with both reference (classes, delegates, interfaces…) and value types (primitive type, struct, enum…)</p>
<p>The benefits of C# implementation are <strong>performance improvement</strong> (no cast and no boxing/unboxing of value types), <strong>deep type safety verification</strong> and <strong>reflection capability</strong>.</p>
<pre name="code" class="csharp">public void AwesomeGenericMethod&lt;T&gt;(T t) where T : new()
{
  T newInstance = new T (); // Causes a type creation error in Java
  T[] array = new T [0]; // Causes generic array creation error in Java
  T defaultValue = default(T);

  Type type = typeof(T);
  List&lt;T&gt; list = new List&lt;T&gt; ();
}

// Generic with same name but a different number of generic type
public void AwesomeGenericMethod&lt;T,U&gt;(T t, U u) where T : new()
{

}</pre>
<p>Mark Reinhold (Chief Architect of Java Platform Group at Oracle) talked about reification at Devoxx 2011. But this feature is still not planned for next major releases of Java.</p>
<h2>Farewell checked exceptions</h2>
<p>Exceptions in Java and C# fairly work the same way, there is only one major difference between the two:  Java contains the notion of <strong>checked exceptions</strong>.  In Java you can declare <code>throws ExceptionType</code> in the method declaration, this forces any callers of that method to handle the exception.  This is a great idea on paper but in practice it tends to be an annoyance more than anything, bringing new issues:</p>
<ul>
<li> Versioning: adding a new checked exception to a method declaration in a new version breaks client code; it&#8217;s like adding a method to an interface. In version one you create a method <code>foo</code> that declares it throws exceptions A and B, in version two you add a bunch of features and throw exception D, this is a breaking change because existing callers do not handle this exception.</li>
<li> Scalability: in large application with a lot of dependencies, the number of exception grows exponentially and people will often shunt the feature by throwing the generic Exception or use empty catch block.</li>
</ul>
<p>The idea behind checked exceptions is great but they tend to intrude to much, specially in big application. That’s why there is no checked exception in C# or any other mainstream languages: it’s up to the developer to handle them.</p>
<h2>Double rainbow accessors</h2>
<p>Java uses naming convention for its accessors and modifiers (i.e. <code>getAddress</code>, <code>setAddress</code>, <code>isValid</code>&#8230;). In <strong>C#, accessors and modifiers are built-in</strong>; with properties no need to write getters and setters, everything looks like a direct field access, even if it isn’t. (many languages uses the same idiom, by the way)</p>
<pre name="code" class="csharp">class Meme
{
  // A private backing field is created by the compiler
  public string CatchPhrase { get; set;}
  public string URL { get; set;}
}

Meme meme = new Meme();
meme.CatchPhrase = "Rick roll'd";
meme.URL = "http://www.youtube.com/watch?v=EK2tWVj6lXw";</pre>
<pre name="code" class="java">// Equivalent in Java
class Meme
{
  private String catchPhrase;
  private String url;

  public String getCatchPhrase()
  {
    return catchPhrase;
  }

  public void setCatchPhrase(String catchPhrase)
  {
    this.catchPhrase = catchPhrase;
  }

  public String getUrl()
  {
    return url;
  }

  public void setUrl(String url)
  {
    this.url = url;
  }
}</pre>
<p>When you declare a property as an auto-implemented one, the compiler creates a private, anonymous backing field that can only be accessed through the property&#8217;s <code>get</code> and <code>set</code> accessors. It brings consistency: the field is always used via the accessors even within the class and it looks cleaner and shorter!</p>
<p>A special kind of accessors exist that doesn’t exist in Java: the indexer; it is like a get/set with a parameter. C# collection like <code>Dictionary</code> (equivalent to Java <code>Map</code>) use indexer :</p>
<pre name="code" class="csharp">var keywordsMapping = new Dictionary&lt;string, string&gt;();
keywordsMapping["super"] = "base";
keywordsMapping["boolean"] = "bool";
Console.Write("Java =&gt; C# : {0} =&gt; {1}", "super", keywordsMapping["super"]);</pre>
<h2>You Say I&#8217;m Crazy, I got Your Crazy! You&#8217;re nothing but an Initializer!</h2>
<p>You often has to create an object and initialize it right after, this can be done with constructor if one is available. Otherwise you has to create the object and then call the different setters.</p>
<p>Object initializers let you assign values to any accessible fields or properties of an object at creation time without having to explicitly invoke a constructor.</p>
<pre name="code" class="csharp">Meme leeroy = new Meme {
	CatchPhrase = "Leeroy Jenkins",
	URL = "http://www.youtube.com/watch?v=LkCNJRfSZBU"
};</pre>
<p>It works with collection too:</p>
<pre name="code" class="csharp">List&lt;int&gt; digits = new List&lt;int&gt; { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Dictionary&lt;string, string&gt; keywordsMapping = new Dictionary&lt;string, string&gt;() {
	{"super", "base"},
	{"boolean", "bool"},
	{"import", "using"}
};</pre>
<h2>Verbatim string</h2>
<p>Escaping characters in string literal is a real pain, it clutters the string meaning, especially with Regex! In C# verbatim string allows backslashes, tabs, quotes and newlines to be part of a string without using escape sequences.</p>
<pre name="code" class="csharp">string pattern = @"\d{3}-\d{3}-\d{4}";
string input = @"Multiline string
   325-532-4521";
Regex.IsMatch(input, pattern, RegexOptions.Multiline);</pre>
<h2>It&#8217;s a wrap</h2>
<p>In this post I have showed that despite its similarity with Java, C# is meant to make developers life easier, to ease their burden (and these are only samples among others). Not too bad for a copycat!</p>
<p>Java developers have brought responses to these lacks in their favorite language by introducing new scripting languages on top of the JVM. For instance, Groovy has most of features presented here. But Java language still does not change!</p>
<p>In the following post I am going to describe the totally different features that bring C# to another level of expressiveness and effectiveness: <code>lamda expression, LINQ, dynamic, extension methods...</code></p>
<img src="http://feeds.feedburner.com/~r/kalistick_blog_en/~4/9gmqngOdhD0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		<feedburner:origLink>http://blog.kalistick.com/java/why-java-folks-should-stop-looking-down-on-c-differences-in-similarities/</feedburner:origLink></item>
	</channel>
</rss>

