Pramatr Blog

A collection of articles from pramatr.com on technology, security, software and anything we find interesting

Archive for the 'Development' Category

WebIssues Mylyn Connector

Posted by pramatr on 29th March 2010

Pramatr announces the release of Pramatr WebIssues Mylyn Connector for any Eclipse-based IDE.

WebIssues is an open source, multi-platform system for issue tracking and team collaboration. It can be used to store, share and track issues; highly customisable and easy to use. Mylyn is a task framework for the eclipse IDE maintained by Tasktop. It can connect to many popular Issue Trackers as Trac, Jira, Bugzilla. With this release from Pramatr Mylyn can now communicate with WebIssues Issue tracker and team collaboration system.

No more logging in to WebIssues or downloading the WebIssues client, Pramatr WebIssues Mylyn Connector brings WebIssues right in to the Eclipse IDE.

Pramatr WebIssues Connector Eclipse feature consists of two parts :-

1. An API library that talks the WebIssues protocol that is completely re-usable available from our website here

2. The Eclipse/Mylyn implementation classes that adapts the Mylyn task model to the API library and provides task and query editing GUI components

Integration of WebIssues Mylyn Connector

i. Prerequisites

  • Working installation of WebIssues Server. Download and installation instructions can be found here.
  • Working version of Eclipse 3.5.2 onwards. Download latest installation from here.
  • Installation of Mylyn plugin within working version of eclipse IDE. Mylyn installation instructions can be found here.

1. Install Connector in eclipse

  • Start eclipse, from Help->Install New Software.. add the latest Pramatr WebIssues Mylyn Connector update site listed here,  Pramatr WebIssues Mylyn Connector
  • Pramatr WebIssue Mylyn Connector will be available for download. Select, download and restart eclipse

  • Once downloaded eclipse will require restarting. Once restarted select Planning perspective
  • from Task Repository tab, right click, select Add Task Repository. List of available connectors will be visible. Select the new WebIssue connector

2. Configure Connector

  • Connector configuration dialog will open; fill in required details and check Save Password (configuration should be tested)
  • Once successfully connected configure initial search query
  • Pramatr WebIssue Mylyn Connector will execute query against defined WebIssues server and return requested data

3. Ready for Use

  • Pramatr WebIssues Mylyn Connector is configured and ready to use. Tasks, features, issue artifacts from WebIssues server will be visible within the Mylyn Planning perspective. Artifacts amended, created, altered within Eclipse will be synchronised against the main server.
  • Final step is to start using it. Remember, Pramatr forums are always open for your thoughts and feedback.

Tags: , ,
Posted in Development, Technology | Comments

Testing Times Concluded: There’s always tomorrow, isn’t there?

Posted by pramatr on 29th September 2009

In the previous three articles we discussed the difficulties that can be encountered when introducing automated testing into a team and how to try and address these when they occur. Although the principles are very straight forward, many teams have great difficulty adapting to an automated testing approach. In the final part of this series, we take a look at why the testing shouldn’t wait for another day.

How can we get teams to write tests as they write code?

For many developers the biggest challenge to writing tests as they write the code is a behavioral one. They are not use to writing tests alongside the code and usually test-last once all the code has been written. Some developers do exactly the same thing when writing JavaDoc, with very similar results. If developers don’t like writing tests, they really don’t like writing lots of tests right at the end of a project. Typically when jobs like this are left right until the end of a project, they either don’t get done, or don’t get done very well.

The main problem with this approach is that the developer doesn’t really benefit from the tests during development. When the code is developed, there is a reliance on logging, debugging and manual testing to ensure the code works as expected. When changes are made to the code, the whole cycle must be repeated again. This feedback cycle can very quickly decrease the velocity of development.

By writing the tests at the same time as the functionality, it not only saves a marathon session of writing tests at the end of a project, it also means the tests are used to help develop the code. There is confidence in the changes being made, and if tests are continually run it’s easy to know which code change broke the tests. This leads to a much shorter feedback cycle when developing and subsequently over time, developers are more productive.

@Test(expected=IllegalArgumentException.class)
public void nameCannotBeNull() {
    // now we've finished coding
}

@Test(expected=IllegalArgumentException.class)
public void nameMustNotBeEmpty() {
    // it's time to write some tests
}

@Test(expected=IllegalArgumentException.class)
public void nameIsTooLong() {
    // I really wish I'd started sooner
}

Developers really don’t like writing lots of tests for code they’ve already written.

What about all the existing untested code?

If developers don’t like writing lots of tests at the end of a project, they really really don’t like writing tests for legacy code. This single task is one of the most hated and time consuming to complete. The typical problem is that the code wasn’t designed for testing, hence the code must be refactored before tests can be written. The real problem with this approach is that tests are actually supposed to catch changes that might break the code. It really is a catch-22 situation, as performing the refactoring to allow tests, may actually introduce changes which break the code.

Writing tests for legacy code can be extremely time consuming. One of the biggest problems (if it is actually possible to write tests), is that it isn’t always obvious what the code was supposed to do in the first place. Even if the original author is still working on the project, the code isn’t fresh in their mind, and as such, there is going to be an initial period of familiarisation. Even if this is successful, it can be extremely time consuming and sometimes very haphazard.

Can the project afford to not refactor the code and have limited test coverage? Can the developers risk making changes and potentially introduce bugs in the short-term thus allowing long-term stability? Ulimately there is a tough decision to make here, but the situation isn’t going to get any better. Retrospective testing costs more time and money as development progresses, can this be left for the time being or is it wiser to tackle this problem now? Fixing defects later in the process will inevitibly cost more time and money. Is manual testing alone sufficient enough to find enough of the defects?

When modifying or adding to legacy code I personally prefer either writing tests first, or performing the minimum amount of refactoring required to add tests. The sooner the code has tests, and the less code changes I have to make to allow testing, the happier I am.

public class TestsForReallyComplicatedCode {
    @Test
    public void todo() {
        // ok now I'm scared!
    }
}

Is it a really a good idea to let this problem get any worse?

Conclusion

Test-driven and test first development have become very fashionable over the past few years. Ensuring code has tests is one of the core Extreme Programming rules, but it can also be one of the most difficult to introduce to a team. Although the principles are very straight forward, many teams have great difficulty adapting to an automated testing approach. Some of these teams don’t have any existing testing strategies in place, meaning that incorporating automated testing into development seems like an unattainable goal. In this series of articles we’ve covered some of the common problems encountered when trying to incorporate testing into development including:

  • We DON’T do testing
  • I don’t write tests
  • I don’t know what I’m supposed to be testing
  • Nobody knows anything about testing
  • We aren’t allowed to write tests
  • How can we get teams to write tests as they write code?
  • What about all the existing untested code?

Developers are willing to write tests, they just need some guidance. Anyone trying to encourage the adoption of automated testing needs to make sure they are approachable and on hand throughout the process to answer any questions and try to quell any frustrations before they occur. Once developers understand how to write tests effectively, it soon becomes second nature to them. These are indeed testing times.

References

Tags: , , , ,
Posted in Development, Opinion, Testing | Comments

I'm Sick of Restarting My Server!

Posted by pramatr on 3rd August 2009

Anyone that has been following @pramatrdev on Twitter will have seen a recent tweet in which I stated that “I’m Sick of Restarting My Server!”. This was borne out of extreme frustration on a particularly bad day after several hours unproductive development AND multiple server restarts. From that moment on I’ve continued to realise just how sick I’ve become of restarting my server.

I’ve been developing using Java for around ten years now and during that time it’s been a pretty happy relationship. I’ve got used to the fact that some changes I make require a server restart whilst others can be seamlessly hot-swapped leaving me free to carry on with my work. I’ve accepted this for a long time, but for some reason I’ve really started to get sick of restarting my server. As discussed previously:

The longer a build-deploy cycle takes, the more compelling testing becomes. On many occasions I’ve seen people finally give in and start to write unit tests not when shouted at and told to by the lead developer, but instead, when they are sick of waiting for their application to load for the 100th time and just want to get their work finished.

These frustrating server restarts have led many people, to rely on testing much more than ever before and to shift the focus away from debugging and logging. By moving the focus away from compile-build-deploy-test and forcing testing earlier into development, productivity can be greatly improved helping the developer to say in the zone. Although testing helps, it’s still not enough and sometimes it feels like there needs to be more support.

After searching for more I stumbled across JavaRebel which boasted some very impressive features in comparison to the standard hot swap technology. After using their ROI calculator it claims the cost of JavaRebel could be repaid within six days which would seems like a pretty convincing argument to even the most frugal of managers. This all sounds great and confirms exactly how I’ve been feeling lately. There has to be a better way to do things, it has to be easier and simpler to be more productive. Maybe JavaRebel is the answer, but after recently spending some time using Grails, I wonder if I’ve found another potential solution to my problem.

In one evening of coding with Grails, I recently managed to clock up several hours without a single server restart (this was only cut short by the need to sleep). This is made possible by a feature within Grails known as auto reloading. As the documentation states this isn’t without it’s quirks, but when using this with Grails I really do feel productive. By removing the necessity to restart my server when I make changes, I’ve removed that frustrating minute between stopping and starting which not only seem to take an age but also distract you from your train of thought and send you over to have a quick browse on DZone. Grails has so far provided a really impressive and effortless development experience and most of all it’s confirmed something to me, “I’m Sick of Restarting My Server!”.

Posted in Development, Opinion | Comments

Testing Times Part III: Are developers able to write tests?

Posted by pramatr on 21st July 2009

In the previous two posts we discussed the difficulties that can be encountered when introducing automated testing into a team and how to try and address these when they occur. Although the principles are very straight forward, many teams have great difficulty adapting to an automated testing approach. In the third part of this series, we take a look at some of the reason that developers can’t write tests.

Nobody knows anything about testing

So many teams I’ve encountered in the past don’t automate testing because neither they nor any of their team have used this approach in the past. In the previous article one of the comments from PhiLho was about this very subject.

Beside the classical problem of time, there is even some base questions. For example, I write a private method in Java doing some algorithm, pattern matching, date computation, etc. How do I test it since it is private?

A typical response to a question like this is, What do you think about it? How would you test the method? Have a discussion about it in the team, have a debate about it. Try something out and see how well it works out. Throw it away and try something else completely different.

Well we could use reflection but is that really such a good idea, it seems a little hacky and a complete sledge hammer for a simple problem. We could just lower the visibility rules, how about package private? If the test hierarchy mirrors the original source are what issues are we introducing here? Do we really need to test the method directly, won’t it be tested implicitly by executing the calling code?

All of these questions have many answers and I’m sure a quick search will yield results to prove these debates have and still rage on. The interesting part in all of this is having a go and seeing what works for your team. “I didn’t want to do it because I didn’t want to do it wrong”, is such a common attitude amongst some teams. I would actively try to convince people that you have to fall down and make some mistakes to learn, most of the time without any previous experience the only way to find out is to try! If you want to jump start this process there are many excellent blogs, discussion groups, mailing lists, forums and books you just need to search for them, ask for recommendations and see what works for other people. But if there is nobody in your team that knows anything about testing, somebody is always going to have to take the first step to encourage the learning process.

We aren’t allowed to write tests

There are still some teams out there that are not allowed to write unit tests. There seems to be a couple of popular variations on this story; people that are not allowed extra time to add unit tests to their project and managers that don’t want developers wasting their time writing tests. In either of these situations, people have to understand the positives that come from testing and how this can improve both the teams development and it’s overall velocity.

One of the biggest preconceptions about testing, is that developers who write tests deliver code slower than those who don’t. Although some developers can release code more quickly without tests, this trend doesn’t typically last. When new code is developed it requires testing, when it’s integrated with the rest of the code base it has to be tested again, and each an every time the code is modified it requires further testing. If this testing has to be performed as a manual activity, it either doesn’t get done, doesn’t get done very well or doesn’t get done at all.

It is simply too time consuming to undertake this type of testing on a regular basis. The untested code can be a constant source of recurring bugs or in the best case it just takes longer to maintain than it should. In this situation, automated testing has to be an essential part of the development process. Manually testing can start to become a bottle neck in the process very quickly. Once automated tests are written however, a development team can prevent then wasted effort of excessive manual testing.

Some developers may initially take longer to develop code with tests, but this is a common symptom of any new approach. Once developers understand how to write tests effectively, it becomes second nature to them. Developers then tend to write test-backed code at least as fast as using a logger and debugger to develop the code. The longer a build-deploy cycle takes, the more compelling testing becomes and also the more productivity gains can be achieved.

@Test
public void codeDeliveredOnTime() {
    assertTrue(true);
}

@Test
public void confidenceInCode() {
    assertTrue(true);
}

If the code is still delivered as expected, does it matter if automated testing is helping this process along?

Tags: , , , ,
Posted in Development, Opinion, Testing | Comments

Fun with Grails

Posted by pramatr on 19th July 2009

Anyone that has been following @pramatrdev on Twitter will have seen the numerous tweets recently about Grails. I first started looking at Grails back in 2006? after a recommendation from a work collegue. It looked quite interesting and I managed to hack together something quite simple but it was a little hard work in places to get what I wanted out of it. It was early days for the project however and it looked very promising.

I’ve since recommended it several times to other people who were interested in building applications new applications. Most of the this feedback has been extremely positive so I’ve managed to get around to having another look at it recently. After @snaglepus suggested I check out Build twitter in Grails in 40 minutes (registration is required) I have to say I was very impressed. Since watching that I’ve gone from knowing absolutely nothing about Grails (three years it too long to keep information in memory) to building a sample application very quickly. After finding plugins for many of the tasks I wanted, I’ve implemented the logic I need and let the tool do the rest of the heavy lifting work which led to a very productive evening of coding.

I really love it when you find technology which just seems to work and does exactly what you expect it to do. There is still much I want to learn about Grails and I’m sure there are many other tips and tricks I can pick up along the way. At the minute I’m just looking through the many Grails books to find a winner and I think I have in The Definitive Guide to Grails, Second Edition. If you haven’t looked at Grails before, I really recommend you check it out and see what it can do for you. And if you aren’t following me on Twitter, I’m @pramatrdev and I’m sure there will be a few more tweets about Grails before the month is over ;-) .

Tags: , , , , ,
Posted in Development | Comments