Monday, 23 March 2009

Build Your Software on Firm Foundations...

What makes for a successful software development project? I was mulling over a number of projects I had been involved with in the past, some very successful, some not so, and thinking about the key differences between the two. There are any number of aspects that can be considered - the quality of project management, clearness of requirements, thoroughness of the analysis, quality of execution and technical leadership to name but a few. Here I am going to focus on two key technical aspects, not being a career project manager, and explain why they are both important and also both frequently neglected. 


From my experience there are two main aspects to a technically successful software development project, the Software Architecture, and the Software Engineering Process (I am taking it as read that your teams have the basic capabilities to develop software using your chosen technical platform, which in my case is Java).


Software Architecture


When projects fail from a technical perspective it is generally down to a failure to satisfy the headline non-functional requirements of the system - performance and scalability are usually the biggest culprits here, often closely followed by transactionality and/or reliability. It should be said that the blame here is not necessarily on the heads of the engineering team alone; such requirements are all too easily swept under the carpet because the customer often doesn't know what they need in this area, or with bigger projects, isn't willing to invest the effort to find out what the requirements should be.


Enter the Software Architecture Document. The purpose of this document is to nail down the outline structure of the software, in the context of the hardware that it will run on, to satisfy the key non-functional requirements. These are the architectural goals and constraints - what do we want to achieve, what targets are we setting for performance, scalability etc - and how do we best structure our application to make optimum use of the environment in which it will run.


Now the process of preparing a Software Architecture Document is a subject all by itself, and one I will cover another time, here I want to get over the importance of having such a document, the benefits it provides, and the pitfalls it can help you avoid. 


The Software Architecture Document is in effect the launching point for your development project as well as providing the bridge between the non-functional requirements and the framework within which the functional requirements of the system will be implemented. It starts by framing the key non-functional requirements (also referred to as the architectural goals) and the architectural constraints. These can be such disparate items as "the system shall support 200 concurrent users", "the system shall respond to 80% of web server requests inside 1s", "the search function will use a Google search appliance", and "the system shall integrate with PayPal's Instant Payment Notification and Google Checkout". These are high level and should come straight from the customer's overall requirements for the system.


The non-functional requirements will have a fundamental influence over the design and implementation of the system. To not consider any of these requirements, or to ignore architectural constraints ("we have an Oracle license so you will be deploying to Oracle 10gAS", for example) can doom a project before a single line of code has been written, and it is vital that as many of these requirements and constraints are flushed out as early as possible, and documented. This will then allow the project team to develop a software architecture that allows the functional requirements to be implemented, but also ensures that the non-functional requirements are considered from the earliest possible stage of the project.


A failure to address the non-functional requirements at the start of a project is often fatal, as the cost and/or complexity of re-engineering a finished solution (and the delays associated with doing so) to meet 'new' requirements can be prohibitive, not to say unpopular with the customer. This is where strong project management is useful - both in ensuring that the customer provides some metrics (customer volumes, response times, infrastructure limitations etc), and in ensuring that the project team fold them into their design decisions.


Fundamentally, the Software Architecture Document is a vehicle for stating those metrics, and then outlining the software architecture that will support them and provide documentation of the framework for the developers to work against.  The document also allows the team to trace from non-functional requirements and technical constraints through to the architectural design decisions, demonstrating how requirements are satisfied and, where appropriate, why a particular approach was taken.


If the Software Architecture is lacking key metrics, or worse still does not exist at all, then the project is at severe risk of failing to meet its non-functional requirements. The customer may not even realise that they have non-functional requirements, and in the event of this it is the development team's responsibility to push their management team hard to agree a set of requirements with the customer. The larger the system, the more important and deeper the non-functional requirements need to be. Conversely it is only fair to point out that a small project with a small target user base may be able to get away with no such requirements specified - simply because the functional requirements can never tax the deployed system sufficiently for any non-functional issues to arise.


In summary then, the software architecture is important because it ensures that non-functional requirements have been explicitly drawn up and considered in the design and development of the system. The Software Architecture is frequently neglected however, for this very reason - it all to often serves to highlight what hasn't been thought of. Also it cannot help that writing such a document is sometimes viewed as a paper exercise with no immediate value to the project. Hopefully I have explained why this is an incorrect viewpoint, that the Software Architecture is a vital component of the development project, and that neglecting to undertake this work in some form increases the risk of a technical project failure.


Having ensured that both functional and (technical) non-functional requirements will be addressed during the architecture and design phase, your team can move on and start producing code. And this is where the other key technical aspect comes in.


Software Engineering Process


If we accept that developers are, by definition, good at producing code that satisfies the requirements laid down (both functional and non-functional) then I would also posit that developers each, by and large, have their own style of working. Left to their own devices, a project team of six people that produced a working system with no formal engineering process in place would produce six sets of differently styled code, six different approaches to unit testing, and so on. Of course, you may be fortunate and get less than six sets, but you will definitely have two or more unless you set out from the beginning to avoid such a situation. And the bigger the project, the bigger the problem.


This is where the Software Engineering Process comes in. It lays out a modus operandi for the development of code at a high level (so that everybody works in the same way, produces the same sets of deliverables etc), lays down standards for the deliverables being produced (coding and testing standards, User Interface design standards, documentation standards where applicable, etc) and finally and most importantly (and frequently the most neglected part) provides a technical environment that supports and promotes the process and the standards, and makes it easy to work with/to them.


Most companies have a culture that takes care of the first of these three parts of the process. New people join an existing team and are inducted, almost by default, into the way the team works to produce code, and the team work as a unit going through the same development lifecycle and producing the same deliverables. It happens so naturally that it is taken for granted.


The second part of the Software Engineering Process is that of working to standards. Fewer companies have pre-prepared standards and guidelines documentation to hand for a project team. With large companies this is not because they don't exist (exercises like ISO9001 certification ensure that they do), but more generally because the groups that develop such documentation are too far removed from the people expected to use them. Therefore adoption is low for all sorts of reasons - people are not aware of them, can't work out which to apply and how, or there is insufficient enforcement of their use by the company as a whole. With smaller companies, if these documents don't exist it is frequently because the emphasis is more on doing the 'real' work than documenting 'how to make the code look nice'.


The final part of the process is the concept of providing technical resources to simplify the implementation of standards within the overall development cycle. This is, in my experience, the part most frequently missing from a project team, despite the fact that this is now supported better than ever. Coding to another person's standards always takes more time and effort than coding to one's own "internal style guide", so to ensure a high level of compliance there are all sorts of things that can be done to make life, and conformance to standards, easier. For example in Eclipse you can set up templates, formatting rules, on-save actions and checkstyle rules which all help to produce code that is by default closely aligned to coding standards, with the IDE providing warnings to the developer when they diverge from those standards.


Other tools such as CruiseControl allow the project to run regular repeatable builds and to re-run all automated tests, thereby providing a high level of visibility as to the state of the code ("are the unit tests all passing?"). Further tools can attest to the level of quality present - Emma can highlight where testing is insufficiently thorough, FindBugs can highlight programming antipatterns in the code, and so on. All this can be scripted to happen, for example, every evening, so that any issues introduced into the code can be caught quickly and resolved.


All these tools support the development team in producing better quality and more maintainable code than would otherwise be the case (and for little additional cost too), aspects of the development process that become more vital as the project progresses through test and moves into live deployment and maintenance. A good engineering process, together with the tools and standards to match, can help ensure that your project delivers code to a known level of quality that can more easily be maintained, even if the vast majority of your original team move on.


In Summary


Firm foundations (in the Software Architecture Document) and a well supported, repeatable process with quality built in along the way (in the Software Engineering Process) are key to a successful development project. They help to ensure that key non-functional requirements are addressed from day one, that the development team produce code of consistent quality, and that testing happens early and often. It is easy to fall into the error of writing standards for the sake of standards (and causing many a developer to become disgruntled by their arbitrary nature), but with modern tools it is now possible to focus on promoting practices that are a more natural fit with the tools and therefore easier and less demanding to adhere to.

Monday, 1 December 2008

Hidden Files in Mac OS X

Having finally got around to uploading the original rss4jsp projects into SourceForge this evening I found myself with a problem - I was uploading all sorts of stuff that was not applicable. For example, Apple creates a .DS_Store file in every folder viewed by the Finder, to store information about how the folder looks in the Finder. Not essential to rss4java. For that matter, neither did I want to add my Eclipse files, but in they went...

A quick Google led me to Shane Duffy's blog post on showing hidden files (in Unix this is anything that starts with a full stop). However this did not show folders (like the Eclipse .metadata folder). This turned out to be even easier than using Google - I just tried the obvious extrapolation.

Here they are then, the commands to show hidden files and folders (run them at the command prompt):

defaults write com.apple.finder AppleShowAllFiles TRUE
defaults write com.apple.finder AppleShowAllFolders TRUE

Once you've done this you need to shut down all the Finder instances:

killall Finder

Now open up a new Finder window - e.g. click on the desktop and then type Command-N. Boy, I bet the window you're looking at is a bit messy now. However this enabled me to work my way through the project folders and remove all the hidden files.

Now I've done that I don't want all my Finder windows cluttered with stuff I don't need to work with every day. This then is how to hide all those hidden files again:

defaults write com.apple.finder AppleShowAllFiles FALSE
defaults write com.apple.finder AppleShowAllFolders FALSE

Once you've done this you again need to shut down all the Finder instances:

killall Finder

And that's all there is to it. Thanks again to Shane Duffy for the original tip for showing and hiding hidden files.

Monday, 24 November 2008

rss4jsp: A Tag Library for Project Rome

One of the features being introduced to Fantasy-F1.Net in the next few weeks is an RSS Feeds page. During the closed season it is useful to have alternative sources of material to keep people coming back to the site which would otherwise be all but dormant. The RSS Feeds page will provide access to material without the user leaving the site, and with new material being indexed by the search engines, a wider range of search terms have the potential to drive traffic to the site.


The first part of this exercise was originally to identify a suitable tag library to support this functionality. The site already uses the Project Rome library to generate RSS feeds from the site but a search quickly showed that there were no libraries available that either already performed the tasks required, or that could be extended to do so.


The rssutils project from Rodrigo Oliveira provided a useful introduction to doing some of what was required, but the code was old and unfortunately flawed, so the decision was taken to develop a tag library, in a similar vein to the rssutils project, but on top of Project Rome. Having written an initial set of tags the idea to share them for the benefit of others quickly followed and the rss4jsp project was born.


Having perfected the basics of a library I have written a tutorial here and set up the rss4jsp project on SourceForge.net. The distributions (there are two, the library itself and a samples distribution) are now available for download, and the source code (also included in the library donwload) will be uploaded in the next couple of evenings. As I think of ways to extend the library I will add feature requests to the project. Please read the tutorial, try the library, and give me feedback, it will all be appreciated.


rss4jsp is open source software licenced under the Apache Licence, Version 2.0

Friday, 14 November 2008

Looking Forward to JavaFX

Sun introduced JavaFX to the world at JavaOne 2007, touting it as a new way to build rich internet applications, and putting it into direct competition with Microsoft Silverlight and Adobe Flex. Coming to the party last, can Sun produce a winner and make lasting inroads into the rich internet applications space?

The concept looked interesting and Sun promptly went away to work on something that developers could play with. A year and another JavaOne later Sun had released a beta and at the Java Web Users Group in London I saw a demonstration by Peter Pilgrim. Despite Peter's best efforts it was quickly clear that things were not yet stable, with downloads of the daily build causing daily rework to his demo code.

Now we have the news that JavaFX will go production on December 2nd. And while I'm confident that the release will be stable and reasonably comprehensive in terms of functionality, I can't help but wonder to what extent JavaFX will be in a position to make an impact in the real world.

Adobe Flex is the defacto market leader in this space with quality tooling and a three year head start over nearest rival Microsoft. Macromedia had a bulletproof reputation that only got better with its purchase by Adobe; any newcomer to the marketplace must aim to produce something at least as good as Flex.

Microsoft's Silverlight went production in September 2007 but has not made significant inroads. Some of this may be down to the undoubted reluctance of some people to adopt yet another proprietary 'standard' from Redmond. Some will no doubt be down to tooling - Silverlight developer tools are part of Microsoft's Visual Studio toolset and therefore require significant investment. But overall I believe that Adobe just has too good a reputation in this space for people to consider switching to an upstart that is just 14 months old and still growing.

So why should Sun have it any easier?

Sun has clearly learnt from both Adobe and Microsoft. Although it has beaten its own path - creating a new scripting language JavaFX Script - they are supporting it with free developer tooling and have ensured that existing Java components are easily leveraged. They have already provided plugins for Photoshop and Illustrator that generate JavaFx code, thereby enabling existing Adobe-equipped development shops to try out the new technology with no capital outlay.

JavaFX requires that the end-user be running Java 6 update 10, also known as the 'consumer release', which was released about a month ago and is available for Windows and Linux but not, as yet, for Mac OS X (Sun and Apple are collaborating to get this shipping 'soon'), so making the runtime available is not an issue, especially as update 10 features a just-in-time download approach meaning that the whole JRE does not need to be downloaded in a single hit.
Does this mean that JavaFX will succeed?

With everything that Sun has done, particularly with reguard for tooling, I think that it is highly likely that JavaFX will establish a lasting presence provided that quality and stability are there from day one. 

The real win will depend ultimately on how successful JavaFX is in getting onto mobile devices. For the first time it appears that Sun is attempting to provide a runtime environment for desktop, browser-based and mobile scenarios that will not require completely separate applications to be written for each. If they can pull this off properly, and I can write a single JavaFX application that will adapt itself to the features and limitations of, and run in, all three environments - then the success of JavaFX is much more assured. 

Wednesday, 22 October 2008

Apple TV: Nice hardware, shame about the limitations

Recent weeks have seen me busy spinning, i.e. achieving very little on the technology front outside of work. A nasty cold and related sinus issues has kept me away from computer screens as much as I can get away with but now at last the problems are receding and I'm starting to get traction again.

As somebody who tends to fall into the trap of over-committing themselves I have a number of projects in a variety of states...

My Formula One site is approaching the winter maintenance window where I'd like to implement OpenId support. Which first requires me to pick up Maven properly. That all needs finishing by the end of the year. At the same time I need to move the site to new hardware provided by me, but before I can do that I need to sort out how to configure the DNS and mail server.

I've recently started working on another project which is called the Java Library Search Project. This is my first collaborative effort and I'll be writing more about that in the near future. To save cost that project is being hosted on a Mac Mini via my home ADSL connection and so far I've got the domain sorted, the wiki up and running, subversion installed though not, yet, as a service and again I have email to sort out. And thats before we start any real work on the project itself.

Now add in one or two other real back burner projects relating to consolidating my external hosting into one account with one provider and you can see I have enough to keep me busy for some time to come. Obviously this is the time to start yet another project. Step forth Apple TV.

When the Apple TV was launched I liked what I saw. A quiet, slim box that will sit discretely under the TV and provide access to all my media. Except of course there are a few teeny weeny restrictions. The box only supports a couple of video formats (H264, MPEG-4) while almost all of my video is MPEG2 or DivX. Oh, and to access material not already on the device's hard drive requires iTunes to be running on the machine that holds the media. All of my audio and video is on a NAS device and I don't want to run another machine just to get access to it.

The Apple TV is a good starting point for a home media centre because it is in essence a small, low power, Intel based PC but as always in the Apple world, there is a tie-in to iTunes thereby providing Apple with a revenue stream once you realise that all video has to come from them, or be converted first.

Under the covers the Apple TV is simply an underpowered Mac OS X and a specialised user interface, and this has given hackers a way in to 'customise' the device (which will, of course, void the warranty). However it is a relatively simple process to provide remote SSH access and from there move on to install additional CODECs and indeed other software to extend the functionality. Apple TV comes with either a 40Gb or 160Gb hard drive and it is possible to change those as well...

So I've bought a nearly new 40Gb Apple TV on eBay and after cloning the hard drive (I want to keep the original drive in its unmodified form) I will crack it and then upgrade it to be the machine it always should have been. About the only thing it won't be able to do is record. The things I am currently considering:
  • Adding a range of additional CODECs so that I can play non-MPEG4 format videos
  • Adding support for accessing media across the network without the need for iTunes to intervene
  • Changing the CPU, if feasible, to something with a little more grunt so that I can...
  • Run background processes to perform other useful tasks like downloading podcasts and other media resources from the internet.

I've already found one good source for achieving at least some of theses goals at appletvhacks.net.

My delivery is due any day, and I'll post updates as my customisation progresses.

Tuesday, 16 September 2008

Effective Java Second Edition

Apologies for the large gap - work has been busy and I've been on holiday too, as well as setting up my company web site. I now find myself with time to post once more.

I recently picked up a copy of the second edition of Effective Java having owned a copy of the first edition for several years. Its a book I have always recommended to anybody new to Java because whereas many books on Java discuss the letter of the language, this book discusses the spirit, and puts it into clear context, leaving the reader in no doubt of (a) how to use particular language features, but (b) where and why to do so.

Having worked with some Java 5 features for the last couple of years I have picked up autoboxing, generics and enums in a casual way. Taking the new edition on holiday proved a boon when the whole family fell ill - I had the chance to spend a couple of days reading in. Very quickly I learnt more about the right way to use the Java language, partly because I never read the original from cover to cover, but referred to it when I was puzzling over an implementation detail. Mostly, though, because the book is a very effective training course on the new areas of the Java language. I had been picking up the new features around generics - converting Java 1.4 code to Java 1.5 had left warnings that I had no urgency to address - but having read about half of the new edition I have been able to quickly eradicate most of the outstanding warnings in my code, either by fully utilising generics, or through annotations to suppress the warnings that occur when using legacy code from Java 5/6 code.

Mr Bloch has done an excellent job of rewriting his book and whether you have a copy of the first edition or not, I strongly recommend you purchase a copy of the second edition if you are serious about producing the best quality Java code you can.

My next post will discuss OpenId which I am currently investigating with a view to supporting on my Formula One web site Fantasty-F1.Net

Monday, 14 July 2008

Method Contracts! Method Contracts! Method Contracts!

I recently spent a few days back-filling test code to help a team meet one of its its quality objectives - namely unit test coverage - and the scany level of documentation within the code re-enforced my views on properly documenting the contract of a method. The methods I wrote tests for had the minimum of JavaDoc, enough to ensure no warnings from Eclipse, but nothing beyond that. So I had an idea of what the method was supposed to do, and roughly what the arguments were for - but no indication if null was a valid value for a given argument, or what would happen if an argument value was non-null but invalid. To write tests for the method contract I had to pick through the underlying code - far from ideal, as I'm now inferring the contract from the code, and the code may not be correct. And this particular organisation hadn't adopted the de facto approach to validating method arguments as documented in the excellent Effective Java (recently re-issued for Java 6) by Josh Bloch.

Briefly, the method contract consists of two component parts: the explicit contract - the method name, arguments and their types, and the implicit contract - which arguments can be null, the valid range of values for a numeric argument, etc. The degree of documentation for a method and its contract should be proportional to its complexity and the level of exposure the method is likely to receive - and it doesn't get much more exposed than a component interface, so these should be very well documented indeed. The objective is to leave no 'wriggle room' in the specification - either for those developing an implementation or those who might want to use it. Or indeed, test it.

By providing thorough documentation for a method you are in effect crystalising the purpose of that method. As a developer it clarifies what you are trying to achieve; for a user of the method it helps them to understand what the method does and how to use it correctly. It should also tell them what error conditions exist and therefore allow them to be catered for.

This may seem overkill for a one or two man project, and you may be justified in short-circuiting the process to an extent. However it is vital in larger projects, and putting the documentation with the method ensures that future maintainers and users of the code do not have to hunt around for supplementary documentation. Or the original author, to explain what is going on. And even for a one man project, coming back to code cold after, say, 18 months, you might just find that the documentation refreshes your memory...