Sunday, April 30, 2006

Windows XP Tips

Yahoo published the Top 10 Windows XP Tips Of All Time and I found some of them useful for me. So I decided to share them with you.

Tip 10: Halt background services to improve performance
Tip 9: Increase available disk space by scaling back System Restore
Tip 8: Scrub your hard drive clean
Tip 7: Run two displays on the same PC
Tip 6: Force unresponsive applications to close at shutdown
Tip 5: Automatically optimize your hard drive
Tip 4: Set a custom resolution
Tip 3: Stay on top of registry changes
Tip 2: Recover lost data
Tip 1: Automatically log when and why shutdowns have occurred
In particular I like the tips 6, 5 and 1, so here they are:

Tip 6: Force unresponsive applications to close at shutdown

  1. Launch RegEdit (select Start > Run, type regedit and click OK) and browse to HKEY_USERS\.DEFAULT\Control Panel\Desktop

  2. Find the string called AutoEndTasks. Right-click it, select Modify from the pop-up menu, and change the data value from 0 to 1. (If you can't find this string, create it by selecting Edit > New > String Value and set the data value to 1.)

  3. Close RegEdit and reboot your PC.

Tip 5: Automatically optimize your hard drive

  1. Open RegEdit and browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout

  2. Find the string called EnableAutoLayout, and change its data value to 1. (If this string doesn't exist, create it and set the value to 1.)

  3. Exit RegEdit and reboot your PC.

Tip 1: Automatically log when and why shutdowns have occurred

  1. Open RegEdit and browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability

  2. Set the ShutDownReasonUI data value to 1. (If this string doesn't exist, create it and set the value to 1.)

  3. Exit RegEdit and reboot your PC.

The greatest tips in history of Windows XP on Yahoo!

Free Code Coverage Tools

What is code coverage? When the query "define:code coverage" is run in Google, you will find the following definitions:

  • An analysis method that determines which parts of the software have been executed (covered) by the test case suite and which parts have not been executed and therefore may require additional attention.
    www.testingstandards.co.uk/living_glossary.htm

  • Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is distinct from black box testing methods because it looks at the code directly, rather than other measures such as software functions or object interfaces.
    en.wikipedia.org/wiki/Code_coverage

There are some great tools that will help you to measure the coverage of your code. Some are commercial, some are free. I used to use Clover that was great. I used point beta versions (0.9x) prior Clover went commercial with the release 1.0. My company did not see much value purchasing anything like that as unit testing and XP was not well know at that time. So I was using the last "free" Clover and I was happy as I got all I needed to keep track the code coverage of my unit tests.

With the explosion of open source projects on the web I was hoping that there would be a good free alternative to Clover after all those years. And there is. As a matter of fact there are many. Lets have a look at the free ones.

Good starting point for hunting for free stuff is at java-source.net. For code coverage tools follow this link. That is the one that I used and will cover in more details.

EMMA

EMMA is an open-source toolkit for measuring and reporting Java code coverage. EMMA's main features are:
  • either offline (before they are loaded) or on the fly (using an instrumenting application classloader) instrumentation,

  • coverage types: class, method, line, basic block,

  • stats are aggregated at method, class, package, and "all classes" levels,

  • output report types: plain text, HTML, XML. All report types support drill-down, to a user-controlled detail depth. The HTML report supports source code linking,

  • output reports can highlight items with coverage levels below user-provided thresholds,

  • EMMA is 100% pure Java, has no external library dependencies, and works in any Java 2 JVM (even 1.2.x).

For few sample reports generated by Emma have a look at http://emma.sourceforge.net/samples.html.

Most of my past projects used Ant for builds. Emma offers several components that expose its functionality as an ANT task and a command line tool, which is very convenient. The documentation is very well written and covers all questions that you might have.

There is also a NetBeans plug-in for Emma. Read some doco about it here.

Unfortunately, if you are looking for an Emma plug-in for Eclipse, there isn't one. Well I could not find any easily. If you do find some, please let me know. If you need a plug-in for Eclipse that will give you a code coverage, use Coverclipse .

Happy testing and getting your code coverage reports!


On May 01, 2006 Jeroen van Wilgenburg said:

You should take a look at Cobertura: When Clover went commercial the project was forked into the commercial Clover and open source Cobertura. It works with Ant, Maven2 and commandline. I think the reports of Cobertura are a bit better than Emma's
There is also an into on Getting started with Cobertura written by him.


On September 26, 2006 Marc said:

You may check out this free EMMA integration for Eclipse: EclEmma

Thursday, April 20, 2006

Don't test everything!

There was a lesson we learnt today. Don't test everything if you cannot write the universal test for it.

I recently joined the great team at Atlassian that is behind JIRA - bug tracking, issue tracking and project management and Confluence - the enterprise wiki. We released JIRA version 3.6 just few days ago and we are already working on 3.6.1. The Jira team is more or less pragmatic team and we decided that we will try to do things XP way. We started with story cards on the wall. We took one each, one meaning one pair as we also embrace the pair programming. The first stories we had were mostly outstanding issues or bugs in the current version. We nailed them very well by writing unit or func test to cover or test as much as possible and fixing the bug itself.

Unfortunatelly, there are always some things that are impossible to test. And if not impossible, then so hard to test that the time and effort spent writing such test would not be paid off by the value of the test anyway. So sometimes you can't test, but sometimes you can. The question is how far will you go with your tests. I usually write tests until at least 80% of the existing code is covered by my unit tests. It should be nearly 100% for the new code as you write the test first and then you keep implementing the class until it passes all tests, right? But for the existing code, I am comfortable with anything above 80% (your comfort zone can be different).

In this case we were creating the test around an issue with two sub-tasks and we wanted to make sure that those sub-tasks will be displayed on a particular page in the application. So we wrote the test. The test checked that these sub-tasks appear on the screen one after another. All tests succeeded and we went home happy.

Next morning we learnt a valueable lesson. Our test failed on one of the testing environments (we support and test on JDK 1.3, 1.4, 5.0 + several supported servers and RDBMS on top - helluva lot of tests run everyday, if you can imagine). There was a slight difference in one of the testing environments that resulted in the order of the sub-tasks to be different than in the others. The order of sub-tasks was not important, it was not a business rule, nor a requirement, so we removed the condition that was based on the order of the two. Now the test only verifies that the two sub-tasks are present and the order is ignored. Cool! Everything works now and what we needed is tested.

So the lesson is, stick to the principle of XP and write only minimum code required to implement the required functionality. That applies to your tests as well. Test everything you can, but don't waste time testing something that is not required. Write a test for it once it becomes a requirement.

Tuesday, April 18, 2006

Is Yahoo spamming itself?

I have a Yahoo account. I had it since forever. It was very convenient at the time as I could access my mail from anywhere at any time. I used it for everything and put it onto lots of websites that required to log in or to register in order to access the content. Now I receive a lot of spam to it. And I don't use it anymore, except for registering for "free stuff".

One of the reasons I stopped using Yahoo as my primary e-mail account was their commercialization. Yahoo disabled free access to POP service. There are some cool utilities (free and commercial) that will let you access Yahoo, Hotmail and other webmail clients. The one I use is MrPostman.

MrPostman is a java program that allows you to access Yahoo Mail, Hotmail and other webmail services directly from your favorite mail client. It converts the web pages of your favorite webmail provider to e-mails and provides the standard POP3 interface to your mail client (e.g. Outlook Express, Netscape or Mozilla Mail, Thunderbird, Pegasus).

As Yahoo also has a whole deal of useful websites interlinked I also have my contacts and appointments online. Some appointments or reccuring events can be set with reminder. And when it is due, Yahoo automatically sends an e-mail to you.

Recently I had one reminder that was due. I looked into my Inbox and the reminder was not there. It was in the Bulk folder, which is Yahoo's I-think-this-is-a-spam-email folder. For some reason Yahoo's own reminders are being recognized as spam.

I understand that these days the spam filters have to be really smart, but hey guys, didn't you go too far this time? Just a thought...

Friday, April 07, 2006

Sun Developer Days in Sydney

I went to Sun Developer Days here in Sydney last week. The two days were packed with sessions running in two halls. I was curious about what was new in Java space. I attended sessions from both tracks. Most of them were showcases of new Sun products such as NetBeans 5.0 and 5.5 Preview and Java Studio Creator.

Some of the sessions I'd like to highlight were:

  • Java SE: Tiger, Mustang and Dolphin
    • This session was a nice summary of Java language evolution, its current features and features of Java SE to look forward to in the future releases;

  • Persistence for Java SE and Java EE Applications using the Java Persistence API
    • This session gave me a new perspective onto the persistence beyond EJBs and ORM such as Hibernate. It's a whole new API that can be used if you don't want to do EJBs;

  • Effective Database Strategies for Developers & Deployers
    • This one was given by Tom Daly, an Aussie originally from Adelaide living in California;
    • It was a very good session focused on embeddable databases.

Some other session didn't match their titles and were rather confusing in a sense that I went there to get something and I got something else. Some of those session were:

  • Building great games for the mobile world
    • This one covered APIs for building mobile games, but failed to deliver anything that I would consider cool or great - it was just an ordinary mobile games development guide;

  • Optimizing Performance for Java SE and Java EE applications
    • I expected something else here, but it was a nice coverage of JVM internals in terms of memory management, similar session I saw 3 years ago at Sun Developer Day in Melbourne;
    • Oh yeah! Did you know that when you start JVM by calling java on the command line there are around 350 parameters you can set?

The excellent sessions I want to talk about were given by Angela Caicedo on Java ME and NetBeans Mobility Pack. Angela's easy to absorb approach was well met with the audience. You could see that she loves NetBeans and Java ME. She was very keen to explain everything. I give her 5 stars even when one of her demos did not work. I highly recommend to see her presentations even if you are not into ME yet, like myself. Now I am converted. I came home, installed mobility pack on top of NetBeans 5.5 Preview and started developing and deploying to my latest mobile phone. It's fun, and it's much easier than two years ago when I tried it first.

Overall, my impressions from Sun Developer Days in Sydney were very positive. Sun is making a big push for Java ME, Java 6 and community around Java. They also offer some good Java dev tools for free. As Bob Brewin, engineer and architect for Sun Developer Tools said, if you are using IDE other than Eclipse or NetBeans and you are paying for it, you are making a mistake.


Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.