Last week I was fortunate enough to attend my 4th annual DroidCon UK. DroidCon is a 2 day conference held at the Business Design Centre in Islington. London and encourages Android developers and enthusiasts to come together and share their ideas, apps, and advice.

As with previous years, the first day is a bar camp (45 minute talks that are decided on the day, based on who is there and who wants to present something). The second day is more structured with a pre defined schedule of talks. There are also vendor booths around the main hall promoting their products and services.

The purpose of this post is for me to summarise the event and mention some of the key things I took away from it.

Dependency Injection on android
The first talk discussed dependency injection and how it can be achieved on android via libraries such as RoboGuice and Dagger.  A quick show of hands made it clear that very few people in the room are actually following DI. Coming from a predominantly Java/Spring background, I understand the benefits of using DI (giving objects exactly what they need, loose coupling and easier testing), but there is a certain stigma that DI holds when mentioned alongside android. RoboGuice is often assumed to be the “go-to” DI framework, however there is a new kid on the block, dagger, from square.

TestFairy
Without a doubt, this was my favourite session from the conference, I was impressed with the service they offer, and its free! For those of you that have at some point developed an android app, chances are you’ve emailed the APK around to a few friends and asked them to check it out. They may have encountered some errors, but all you’ll likely hear is “it crashed when I clicked the blue button”, which isn’t entirely helpful.

Fortunately, the guys over at TestFairy have developed a service whereby you can upload your APK to your online account, and distribute it to your friends. When your friends install and open the app, their interactions are recorded, so if there is an error you can see a video clip of what they pressed in order to get the error. Logs are included, along with various other useful information such as battery, cpu, memory usage. Finally, you spot that bug that only occurs if an incoming call occurs whilst on your app! Please, please go check them out.

OCR on android
Next up was another bar camp discussion around OCR on android and how it can be achieved by using OpenCV. I was quite interested in this talk as I have done some work with OCR on android/iOS for Aviva. The discussion covered the basics of using the OpenCV library, however the emphasis was mostly on how non-trivial OCR is. I can certainly vouch for that, in order to get results that are even remotely close I needed to use blacklists and whitelists for characters, and pre-process the image. If you’re interested in OCR on android I’d highly recommend having a look at the tess-two project on github, which is a fantastic java wrapper around tesseract tools.

Cupboard
I haven’t delved too deeply into SQLite storage on android, but from what I did experiment with it wasn’t the easiest of APIs to work with. Fortunately there is a library called Cupboard that makes this easier with its fluent API. Hugo Visser, the creator of Cupboard gave a brilliant talk on how to get started using it.

Instant backends with Windows Azure
Microsoft, at an android conference, not what you’d typically expect, however they did provide a great session on how to get started building mobile backends on the Azure platform. Microsoft provide an intuitive interface so you can quite quickly create and deploy a backend with social sign in via the usual providers (Google, Facebook). You’re also able to download client libraries so that you can quickly and easily exchange data between your backend and the mobile client. Whilst this looks like a promising offer enabling you to get moving fast, I’m quite sceptical about whether or not ease/speed is still a benefit once your backend becomes more complex.

There is an excellent tutorial here

Mobile backend starter, from Google
Google is also on the BaaS scene, offering the mobile backend as a starter. This is based on the existing Google cloud platform services like app engine and cloud store. Similar to the Azure offering, you’re able to deploy a sample backend in a few clicks and are given client libraries to make the communication as easy as using a Java API.

A colleague of mine, Charlie Simms also attended the event, here is his take on it

A variety of SDKs were promoted at this years event, such as :

So what did it for me:

The event had 86 line ups so there was plenty to choice from, but having done my MSc at Surrey and been on a Satellite Communications Workshop (http://www.surrey.ac.uk/ee/study/pd/courses/satellite_communications.htm ) I was very interest and puzzled in the Keynote on Friday morning “Smart-Phones in Space” http://uk.droidcon.com/2013/sessions/keynote-smart-phones-in-space-a-guide/ why would you want to put a mobile phone in space. Dr Chris Bridges lead a small team at Surrey University Space Centre (http://www.surrey.ac.uk/ssc/ ) to launch a Nexus 1 into low Earth orbit. This talk provided the journey of the first of many ‘phone-sat’ projects and how hardware and software challenges were overcome to achieve this scientific feat in teaching and research. A brilliant talk both interesting and demonstrating what advanced technology is packed into a smart phone.

The second thing that did it for me was the talk by Benjamin Cabé  “Leveraging Android for the Internet of Things with Eclipse M2M”. Benjamin is an Open-Source M2M evangelist and chair of the Eclipse M2M project (http://m2m.eclipse.org). This talk briefly introduced the Eclipse M2M projects with cool end-to-end examples, combining the use of Android API for doing fleet tracking, remote monitoring, and home automation. Also discussed importantly is the challenge of operating large fleets of M2M devices, with the need for cloud-based scalable infrastructures. With the vast amounts of data being collected from possibly billions of sources there will be an ever greater need for cloud base services and the support for big data. The internet of things still in its infancy but it won’t be long before it starts to impact all our lives in the same way as mobile technology is doing today. Certainly a space to be watched closely.

The weird and wonderful

If you’ve made it this far, then lets end the post on some of the weird and wonderful ways that android is being used.

This year we had the worlds (probably) only android powered hydroponics system for growing plants indoors.

20131025_155750

Android powered hydroponics system from Seraku

There was also an android enabled car, an android powered mirror (which you can operate with your best Tom Cruise “Minority Report” impression), and a guy controlling an android powered robot via his android powered smartwatch

Lego Mindstorms robot controlled via AndroidScript / Smartwatch

Lego Mindstorms robot controlled via AndroidScript / Smartwatch

Conclusion
I feel that every year droidcon has a bit of a theme to it, well perhaps not a theme as such, but there will be one or two topics that are in the limelight of the conference, last year felt like the focus was on NFC, this year there was quite a focus on the backends and security, which may pinpoint androids evolution into the B2E space. With presence from Motorola Rhomobile promoting their enterprise platform, droidcon isn’t just attracting indie developers and B2C solutions.

Please share this blog using the social buttons below or via this short URL  http://bit.ly/1astU7y

Please Rate and Like this blog.  Our readers want to know what YOU think, so please take a moment to leave a Comment.

Being relatively new to the IT profession, I wasn’t really too sure what to expect from JAX.  Over the years, I’ve been to plenty of other non-IT conferences; some of them great, some of them awful.
However, JAX 2012 did not disappoint.
Located in the depths of Park Plaza, Victoria, the venue was pretty ideal.  Spacious conferences rooms that easily accommodated any interested attendees (and then some) with plenty of communal seating areas to mingle with the other conference-goers.  Plus, it’s directly opposite a Pret and, as any regular London commuter will tell you, that is no bad thing.  The event staff were very efficient and helpful and there wasn’t a single hiccup in organization over the entire two days, which is a huge indication of the amount of effort that went into the planning of such a big event.
After a brief welcome by one of the conference’s organizers, the first session was a keynote by Brian Goetz (@BrianGoetz ), a language architect from Oracle, centered around Java 8, in particular, Lambda expressions.  It was a really eye-opening insight into the evolutionary forces in play that drive forward Java as a language and a technology to adapt to the fast-moving technological landscape whilst, at the same time, maintaining backwards compatibility with legacy code.  The new features of the language, due for release in Summer ’13, have definitely captured my attention.  There are definitely a lot of features ‘borrowed’ from Scala, in particular the use of parallelism in iterating over Collections, but these can only work to Java’s advantage.  Overall, a fantastic talk and has genuinely excited me over the future of Java.
Next up, a live coding session with Sandro Mancuso ( @sandromancuso ) as he showed us his philosophy on testing and refactoring legacy code.  Whilst endorsing the traditional test-driven development (TDD) approach and the manta of always leaving the code in a better way than you found it, quite a few hints and tips that he gave, such as start testing from the shortest branch of code and refactoring from the deepest branch, are small changes that can make working with legacy code that much easier.  A useful session overall.
I’d never really had much exposure to the Big Data world before so I jumped at the opportunity to attend a few of the Big Data lectures available.  First up was a lecture on Apache Cassandra by Tom Wilkie ( @tom_wilkie ).  Amongst the frequent plugging of Acunu, a reporting tool that sits on top of Cassandra, it gave me a decent understanding of the way that Cassandra works and the advantages, such as providing realtime analytics, and the disadvantages, such as having to declare your queries up-front, that the technology has to offer.
The second Big Data lecture I attended was regarding Hadoop and its evolution.  Similarly to the previous talk, this gave me a good basic understanding of the workings of Hadoop and how it has progressed over the years.   Very interesting indeed.
Having worked on mainly Agile Scrum projects at Smart421, I was quite keen to attend Roman Pichler’s ( @romanpichler )lecture, entitled ‘Choosing the Right Agile Innovation Practices: Scrum vs. Kanban vs. Lean Startup’.  It was really interesting to see Roman’s take on when each of these agile processes are relevent depending on the level of risk and uncertainty in the product.  Having never had any really exposure to Kanban and Lean Startup, this was a great session to get more of a feel for these paradigms.
Next up, was Heiko Seeberger’s ( @hseeberger ) ‘Scala In Action’ talk.  I was very excited about this talk because I’ve heard great things about Scala and had been meaning to experiment with it for a while.  I was not disappointed.  This live coding session showed the basics of the Scala programming language, as well as its interoperability with Java projects.  Whilst the syntax may take a bit of getting used to for existing Java developers, the readability of the code drastically increases, condensing what may take several lines of Java code into a single line of Scala.  As well as this, there are a plethora of features, such as parallel collections and lazy values that make this language very appealing.  A fantastic presentation and I’ll definitely be coding some Scala of my own very soon.
The second of Roman Pichler’s lectures I attended was about his concept of the Product Canvas.  The Product Canvas, in a nutshell, is a document for a new piece of product functionality that captures the stakeholder’s needs, user journies and UX design, constraints and developer stories all in one document.  It was suggested that, once created, this document is displayed for anyone in the business to see.  This is perhaps quite handy for ensuring that all parts of the business are, quite literally in this case, on the same page, but in reality, I’m not sure if this would really be feasible in a fast-moving Scrum team where the requirements are constantly changing.  Definitely an interesting concept though and provides much food for thought on how development teams can work more closely with the rest of the business.
‘Rock Arts and Rockets’ was the title of the next keynote from IBM’s Steve Poole.  This talk was a captivating insight into the Java community as a whole and was a cry of help to encourage us, as Java developers, to get more involved to help drive the future of the programming language.  An eye-opening talk that was very thought-provoking.
At conferences, I’ve always found that there is usually one talk where someone has a good whinge.  Russel Winder’s ( @russel_winder ) talk on Closures didn’t let that hypothesis down.  A lot of the content in this talk was material that had been covered by Brian Goetz’s keynote and the rest seemed to be a long rant about how Java isn’t object-oriented(!) and slides of squirrels.  The wasn’t really much to take away from this talk, which was a pity, as it sounded quite interesting.
Next, was a high-energy and entertaining talk by Holly Cummins ( @holly_cummins ) and Martijn Verburg ( @karianna @diabolicaldev ), which seems odd for a lecture about Software Complexity.  Covering a range of areas concerning software complexity, such as dependency management, issues with classloading and modularity principles, there was plenty to take away from this talk and apply to my day-to-day development with Java, which was fantastic.
Another keynote followed, given by Patrick Debois of Atlassian, regarding DevOps, in particular the importance of sharing in such a development methodology. Patrick took us through the 6-phases of implementing the DevOps way-of-thinking into a pre-existing workspace.  The key theme throughout showed that improved communication can do wonders for development and operational teams working in harmony.  I see this methodology getting a lot more attention over the coming years.
Having recently been involved in helping out with the performance testing for a client, I thought it would be good to attend a couple of talks relating to that area that could perhaps give me some useful skills to apply.  First up was a FAQs about Performance talk by Trisha Gee ( @trisha_gee ).  Aimed at the beginner performance tester, Trisha covered a wide range of different types of performance tests that can take place, as well as considerations and common pitfalls.  A very down-to-Earth session and gave me some very useful advice to apply day-to-day.
The second performance-related talk I attended was by Kirk Pepperdine on the topic of garbage collection logs.  I must admit, I’ve never really thought of analyzing garbage collection logs, purely because I wouldn’t really have a clue where to start.  However, this session showed that it’s not quite a scary as it first appears.  Kirk talked us through a few different garbage collection algorithms and how these can be applied to the heap, complete with practical examples.  Whilst one would need to do a lot more research to become fully comfortable delving into the logs themselves, this lecture gave a great overview of how to tweak the garbage collection mechanisms to make your code more high-performance.  Highly enjoyable!
The final lecture of the conference that I attended was entitled ‘Multi-tenancy in a Platform-as-a-Service’ and this was given by Paul Fremantle ( @pzfreo ). This talk seemed like a ‘shameless plug’ for a product called Stratos but it also highlighted the issues that Stratos came across when building their PaaS solution, which made for an interesting final session.  It’s also made me keen to get more exposure to cloud-based solutions.
Overall, this was a fantastic conference, both is organization and in content.  It’s a great opportunity for any developer to keep up to date with the latest goings on in the Java ecosystem.  It’s given me plenty of mind-food to munch on for the coming year.  The JAX 2012 team deserve a big pat on the back.

© Jameswimsel | Stock Free Images & Dreamstime Stock Photos

Having arrived at the Park Plaza Hotel early, I was the first attendee and got to chat with the girls on reception. Then I sat sipping coffee, alone, reading the gumpf in the goodies bag. Not much really, so I go check out the t-shirts and chat with some of the sponsor dudes: Mr Git-Hub has the best t-shirts.

I’m starting to get excited. Hey, there’s someone else. Looks like a geek.

Starting to get really excited now: “Lambda, Lambda, Lambda”, goes the chanting in my head.

Lambda Under the Hood

Here’s Mr Brian Goetz ( @BrianGoetz ): “It’s a cool time to be in Java in London”, he says.

An engaging speaker, he talks about the choices made to implement closures in java. One of the biggest headaches has been retaining Serialization; backwards compatibility is mandatory.

Key words: invokedynamic, MethodHandle, LambdaFactory.

The point about closures is that they allow iteration (and more) to be delegated to the library (“client says what, library decides how”), allowing library developers to implement, in particular, parallelism in new Collections methods.

For example, a “filter(…)” method (among others) will be added to java.util.Collection so that the following code can be written:

    List<People> adults = people.filter( p -> p.getAge() >= 18 );

Default methods on interfaces (new in Java 8) allow interfaces to be evolved, extended so they won’t break existing code.

Mr Goetz encourages us to download the Java 8 early access releases and start playing around with this stuff. He highly recommended the following read: “How to talk about parallel programming – Not”.

http://www.infoq.com/presentations/Thinking-Parallel-Programming

Cassandra: Realtime Analytics

The Acuna guy Tom Wilkie ( @tom_wilkie ) was in a hurry. I could tell that straightaway because he was breathing fast and heavily.

“Know anything about Cassandra?”, he began: a few hands went up.

“How many attended the previous session on Cassandra?”, he continued: most hands went up but not mine, I had been in the session about Lambda.

“Weren’t she that greek bird what told the truth but no-one believed her?”, someone said, presumably to develop the ambience.

“Erm…, I don’t know”, said the Acuna guy.

What we needed to know was that Cassandra is really good at:

  • Writing random inserts
  • Range queries

And, that all the work is moved to the data ingest phase so all the queries must be pre-defined.

Acuna does realtime analytics, approximate analytics; one can pick no more than two from: “realtime”, “large-scale”, “exact”. The acuna guy then showed us an algorithm for computing an approximate (probablistic) number of distinct values based on hashing values and counting the number of their leading zeroes.

Origin of Hadoop

Bit disappointing, we learnt:

There are 2 components

  • HDFS: storage
  • MapReduce: compute

Moreover:

  • Its scalable: affordable, distributed, reliable
  • Its style of use: schema on read
  • It started as batch only, with Hbase the first non-batch component.

The speaker strongly recommended reading the following paper from Google:

http://research.google.com/archive/spanner.html

Back to Basics: Codemanship

This was an entertaining talk by Jason Gorman, essentially debunking the methodologies mire. The speaker walked us through his 11 hype free principles of software development.

Pretty obvious stuff really, but worth it for the following:

“No developer ever suggested using a waterfall model, nor ever would”.

“In software, perfection is so close to ‘good enough’ that we might as well aim for perfection”.

http://www.codemanship.co.uk/backtobasics.pdf

The Scrum Hangover

Two guys from UBS,  Mashooq Badar ( @mashooq ) and Sandro Mancuso ( @sandromancuso  ) talked through their company’s experiences over the past few years participating in projects with offshore/onshore teams.

Key items:

  • Focus on quality – reserve time for improvements (developers make the call on what to improve and when)
  • Quality is a team concern
  • Stop and fix attitude – no broken windows
  • Boy scout rule – leave the campsite cleaner than you found it.
  • Continuous and frequent delivery to production.
  • Emphasis on TDD – automated tests at all levels.
  • Business domain reflected in the code and design – readability, maintainability.
  • Simple design.
  • Healthy intolerance of bad code – develop an allergy for bad code smells.
  • DO NOT satisfy your need to use a pattern.

Connected Data

Mr Ian Robinson at Neo Technology (@iansrobinson ) gave the best talk of the conference. I could immediately see how I could use this stuff in my genealogy project.

He explained that:

  • Semi-structured data in RDBMS leads to sparse tables and lots of null-checking logic.
  • Highly connected data in RDBMS leads to lots of join tables.

Graph databases (such as Neo4j) address semi-structured, highly connected data.

It’s property graph data models are volatile and easy to evolve. They are constructed from nodes, relationships between nodes, and properties (of nodes and relationships).

Neo4j provides a language for:

  • describing graphs
  • creating nodes, relationships and properties
  • querying data
  • pattern matching

Neo4j is ready to go!

Day 2

We start, all together, in the plenary room.

Go join a JUG

“Lower your reverence levels and get involved in OpenJDK”, we are requested by Mr Steve Poole.

“Does java stay in a dark cave guarded by acolytes, or do we reignite the java flame?” he asked us.

“Reignite the flame”, I could just manage to lipread on someone’s lips.

Mr Steve Poole gave us a brief overview of the language jungle, and the key java ethos: compete on implementation, collaborate on specification.

Closures

Having had his thunder stolen by Mr Goetz the previous day, Mr Russel Winder ( @russel_winder ) still gave a talk on closures. He suggested that closures would bring the opportunity to: “stop using 70’s techniques and use 30’s ideas and maybe finally do some OO programming (in java).

Key observation: “Its about how your data evolves. Its not about the flow of control”.

Spaghetti

No more noodling with code!

A vaguely humorous talk about dependency management and the Liskov Substitution Principle (http://en.wikipedia.org/wiki/Liskov_substitution_principle).

The perpetual problem is getting hold of an implementation; factories (factories (factories…)), and home-rolled frameworks. Dependency injection externalises the factory problem; be strict about dependency management we are advised.

Jar Hell – jars are transparent: classes encapsulate data, packages contain classes, jars contain packages, but there are no jar-scoped access modifiers.

  • There is no means for a jar to declare its dependencies, no versioning, no modularization charactistic.
  • At runtime a jar is just a collection of classes on a classpath.
  • In a normal jar, an implementation is as easy to use as an interface.
  • In fact its easier as there are no worries about factories, encouraging the breaking of encapsulation.
  • Don’t think jars, think modules!
  • Understand dependencies: What other code does my code touch?, when does it connect?
  • Retro-fitting modularity is hard.

We are advised to check out OSGi, it’s a lot easier than we might think.

NB: project jigsaw (modularity in Java) will not appear in java 8.

Complexity Theory & Software Development

Mr Tim Berglund ( @tlberglund ) gave an entertaining review of simple complexity theory and a demonstration using golly (game of life: http://golly.sourceforge.net/)

There was very little to do with development other than that we have super-huge complex projects and should be aware and look for emergent behaviours.

He used the excellent term “afferent coupling” (the number of classes and interfaces from other packages that depend on me), and I intend to use it myself sometimes.

Stinkin’ Locks

Not for the first time we began a talk with a schematic of a processor. Mr Mike Barker explained what actually happens in the processor when locks are invoked in code. Lines of cache memory get binned, forcing the re-retrieval of data (that may just be unlucky enough to be in the same line of memory).

He introduced us to the processor memory model, and compared its brevity with the java memory model (NB: this arrived in Java 1.5 and is a big, although underrated, thing).

We walked through some simple algorithms using the Atomics classes, and he explained why “hard-spinning” screws up hyper-threading.

Hmm… I’m not sure I want to use a class whose name is “Unsafe”.

http://stackoverflow.com/questions/5574241/interesting-uses-of-sun-misc-unsafe

Microsoft 8 and HTML/Javascript

I rounded out my conference by attending a talk on building Metro apps for MS8 using HTML and javascript.

Pretty slick, if you want to do that sort of thing. You have to have Windows 8, and you have to have Visual Studio or it just can’t be done.

Not sure I’ll be doing this myself though.

Flooded
Photo by East Coast Main Line

I have had the luck to attend the WUG at the Royal Society of Edinburgh on George Street again this year. This is a bi-annual event hosted in Edinburgh in the Autumn and, from this year, at IBM’s facilities on the Southbank in London in the Spring.

The good luck was attending, when maybe a third of people failed to go when the weather was bad, but the bad luck was when the East Coast mainline was flooded on the way down, causing a very late return home.

There were a few interesting sessions, including the Worklight acquisition for developing mobile applications on to a variety of target devices, including iOS and Android. Possibly more on that later. There was also a good session by Alan Chambers on sample use-cases for using WebSphere eXtreme Scale, which is a distributed in-memory caching technology. This is an interesting area, which merits further attention. The slide deck for the various sessions, including ones I could not get to, are on the WUG site.

David Sayers of MidVision also gave a talk about DevOps, which is the set of disciplines for bringing development and operations closer to each other. Although MidVision supply a tool in this space, David was keen to stay away for instances of tools, and to say that there is no magic bullet, and that it’s about process and people too.

A phrase which struck a chord with me went something like: “many firms don’t want to make a change in a production system because ‘Steve’ is on holiday and he’s the only person who understands this”.

It’s a spooky coincidence, as we have just published a development policy stating that all environments, and deployments to those environments should be 100% automated, as part of our policy refresh.

The presentation I want to elaborate on a bit this time, is the “How Lightweight is the [WebSphere] Liberty Profile” which is part of WebSphere Application Server (WAS) 8.5.

Simon Maple  (Twitter @sjmaple) – one of IBM’s technical evangelists on WAS – explained that this profile is an OSGi-based application server kernel which only loads up the libraries and subsystems, as you need them. The end result is a *very* lightweight application server.

So much so, that the session involved showing the application server running on a Raspberry Pi (£20-odd computer, the size of the palm of your hand, delivered as a circuit board).

To follow this up Simon then started up a WAS instance on his older android phone which was then serving up a blogging application via the phone’s wireless hotspot. I connected to it with my phone, and posted: “Amazing!” (yes Oscar Wilde won’t be looking over his shoulder), which then showed up on his monitor, along with some more imaginative posts.

I have the tooling, which was provided on a memory key in our “info” shared area for any Smarties to download.

The liberty profile tooling (eclipse plugins) even runs on a Mac, along with the dev runtime. Even though this runtime is not supported in production on Mac, this is a pretty major step for IBM. I would not have imagined it five years ago.
In terms of production use though, the liberty profile WAS is still a standard WAS install from the perspective of licensing… though I’m not sure how many PVU’s a Raspberry Pi has.

IBM also have a new Head of WebSphere Software, Stuart Hemsley, who was keen to get feedback from the delegates, both by announcement at the keynote, and by walking around during the breaks.

Our feedback was that the application server just costs too much compared to the likes of Tomcat and JBoss, and includes technologies which are starting to be less relevant (e.g. session clustering), as the application architecture moves to pursue session-statelessness. Yes you would expect to pay a premium for a big-league vendor-supported product, but not 10x as much.

It would be a shame for IBM to loose out on market share because of pricing, when they provide excellent tooling and support, as shown by a session on performance tuning the JVM… but that (as they say) is another story.

The reason for this post is because I am still seeing Helper, Utility and Singleton implemented code in large enterprise scale solutions today. It is almost as bad as coding in Hungarian notation. Now this is to say that practices like Hungarian notation had a place and a purpose, notably when using dynamically linked languages such as C++ for example where you did not have type safety. Things have moved on since those days so PascalCase and camelCase are now the preferred convention, certainly within the .NET space and camel case preferred in the Java space.

Microsoft has a good post on Design Guidelines for Class Library Developers.

So really Helpers or Utilities come from (in my view) procedural languages and by definition they tend to be static types that often equate to “general stuff” that doesn’t fit anywhere else which is very much a procedural mind-set as when you build software in OO languages such as C# or Java, everything has a single responsibility.

This discussion has been flogged for years especially when .NET was becoming popular. But it seems all these discussions haven’t really changed peoples mind sets. Many developers still believe that a helper is a good thing. I am not sure how these patterns are perceived in the Java space but in .NET they are generally considered anti OO and there are good reasons for this which we will go into in this post. Nick Malik from Microsoft wrote this post 6 years ago about this very topic. I have to say I agree 100% to Nick’s comments. It’s actually quite scary to the responses Nick got to that post.

I have copied a particular comment here for reference from a chap named Nate on Nick’s blog, not to pick on Nate but purely for a discussion and example perspective:

This is all good and all, but if helper classes are undesirable, where do you put miscellaneous code that you would normally put in a helper class? Where does that method go that say, helps encode a URL? Or that function that converts an array to a comma delimited list? Or in C#, that wrapper for a certain Win32 API? In all practicality, I find that I often have these piddely tasks that don’t really lend themselves to encapsulation within an object and are pretty much on their own, but are called from myriad places. If I was coding in C++, I would place it outside of a class, but languages like C# and VB.NET don’t allow me to do that. Does it violate OO principles? Of course it does. But OO principles are not meant to be a straightjacket. All that said, I do agree that if they show up in a UML diagram, your helper class is probably doing more than isolating a “piddely task” and that something is probably wrong.

Helpers

For starters I’d like to say what “miscellaneous” stuff. This is one of the biggest issues with things like Helpers actually more with Utilities, they start out being quite small, but before you know they become a dumping ground for all things to man and beast. And to make things worst they tend to be of type static so very hard to test.

In Nates response above, I’d respond to possibly putting URL encoded functions as an extension method to the String class. But then you might say two things:

  1. Extension methods were not available back in 2005 when that blog post was written
  2. Extension methods are really helper classes anyway

The answer to the above is yes and yes! With point 2 the usage is rather different. Extension methods are helper classes in that you can only write static methods. But there is one major difference; you do not actually call the helper class directly. Instead extension methods are an extensibility point in the .NET type system that extends .NET. They often should only be very short functions that normally should not have dependencies. So the developer using an extension method should be very clear what the function is doing and should be able to use those functions in his unit tests without issues.

By the way, my extension method post linked above needs updating. Extension method classes should have the name <class>Extensions. I.e. for IEnumerable extensions, it should be IEnumerableExtensions. So here it’s very clear what are extension method classes and what are not.

So where should those URL encoded functions go back in .NET 2.0 before extension methods existed? The answer, I would incorporate a new class called URL with no static methods and make it part of my framework for my application. This then gives me the power to inject dependencies in the future should I need to and makes testing very easy.

So if class URL required dependencies I.e in the future we might want to send a sample message to a given URL which has a dependency on a custom communication adapter for example, it wouldn’t be a suitable candidate for extension methods anyway.

So take above scenario, if we had a helper class that looks like the following:

public static class Helper 
{ 
    public string static EncodeUrl(Url url) 
    { 
       // call encryption 
    } 
}

That looks ok, so for now forget about testability. But for one thing the class name is not particularly useful. So we could change it, or leave it as is. Often it will get left as is. So then another developer will think, “oh there’s a helper class for library functions”. “I’ll add my FoobarAppSpecificFeature method to it”. And so it goes on and then you end up with a god class.

God Classes

God classes are classes that do or know too much. They breach the Single Responsibility Principle. They are often a result of a procedural developer trying to implement an object oriented system with a global variable mind-set. They often do not fit in well with TDD (Test Driven Development) purely because the classes are hard to test in that they rely on external dependencies which are very hard to mock out. Also, they do not model the system in any way so maintainability comes into question as if you have god classes, you will also have god unit test classes and projects too.

Are Singletons Really bad?

I personally don’t think they are when used in conjunction with an IoC container. The reason here is that a singleton when used in conjunction with an IoC container looks no different from a non-static instance type. This is one of the major benefits of using IoC in that the life cycle is controlled by the container and not the consumer consuming the class. And this configuration should be in the composition root.

There are many valid reasons you would want such a class and the fact you can piggy back on an IoC gives great power and flexibility.

Singletons when used with IoC do not prevent you from testing unlike static types which are mostly bad for reasons already mentioned and should be avoided when possible.

Singletons <> Static types

The moment you define a static type, you immediately write off any use of IoC and testability. That really is the key message here.

The other thing to remember is that, if you implement a static type via an Extension Method or other means, remember that the developer needs to understand what is actually happening and that he wouldn’t be interested in mocking out those calls in a unit test. If the consuming developer would be interested in mocking out those calls, then reconsider the use of an extension method/static type.

So I think Singletons are ok so long as they are not static types and are made singletons are part of the container configuration they are part of.

Utilities

Utility and helper classes in terms of naming are often interchangeable. A Utility class is often equal to a helper god class.

I’m interested in your views on this post, so please comment.

I also had the opportunity to attend the    Websphere User Group (WUG) meeting on 23rd March 2011 at Bedfont Lakes. The WUG is a very popular topic amongst colleagues at Smart421 as its a great community

As someone who doesn’t have much direct WebSphere experience on a day-to-day basis, I was wondering if I would struggle to follow the content. However, I can say that I was pleasantly surprised as the tracks were designed for a variety of skills levels. There were several talks that any Java developer would find interesting. There were actually 13 streams running over the course of the day. Many focused on specific IBM products (as you’d expect) but also some focused on more general topics such as Java, and OSGi.

The first session I attended was the WebSphere Foundation Update and Technical Direction in the WAS 1 stream. This session by Ian Robinson gave an overview of forthcoming features in WAS v8. While this was a very WAS specific session it also provided useful updates on several areas in the J2EE space. To download the slides, click here.

The second session I attended was in the WAS 2 stream on JAX-WS 2.2 and JAX-RS 1.1 support in WebSphere Application Server Version 8.0 Beta . The presenter, Katherine Sanders, a software engineer at IBM Hursley,  gave a very good introduction to these two technologies without being tempted to delve into a lot of overly-heavy WAS-specific details. To download the slides, click here.

The third session I attended was given by Simon Cashmore, a Lead Engineer within the Global Middleware team at Barclays Bank.  This talk, Changing the way Java Application Hosting is delivered at Barclays Bank , stood out by a mile as it was the only session in the Customer stream (c’mon WUG Committee, more like this please). It was informative because it focused on Barclays’ new approach to hosting Java applications. Barclays have essentially built their own collection of virtualised WAS instances that can be made available in days rather than weeks or months. Previously, projects would buy brand new hardware that was not shared or reused, so costs and timescales were sky high. Now they have a shared resource that can be used and reused much more efficiently – and more cost effectively. I’m sure Barclays shareholders will be very pleased to hear that  ;o)

The fourth and final session I attended was a talk in the Java stream on Generational Garbage Collection: Theory and Best Practices. This was focused on how the IBM JVM works, but Chris Bailey, a technical architect in the Java Technology Center (JTC) team at IBM Hursley, gave a very detailed description of it which applies to any JVM that implements Generational Garbage Collection. To get a copy of Chris’ slides, click here.

So if you’re in doubt whether you should attend a WUG meeting because you feel don’t have enough WebSphere experience then let me reassure you that any Java developer will find something of interest. There were also suggestions of adding a more business focused stream to future meetings to widen the potential audience even more.

Details of all WUG activities and events can be found here.

WUG 10th Birthday Celebrations, IBM Bedfont 23 March 2011

Members of the WUG Board, past and present, cut the birthday cake. From left to right: Nigel Gale (founding Chairman), Simon Maple (IBM Representa tive), Alan Chambers (WUG founder and Board member), Chris Mason (Treasurer throughout the WUG's 10 years), and Jonathan Marshall (IBM Representa tive). Photo by kind permission of Alan Chambers.

On 23 March, over 200 members of the WebSphere User Group UK (WUG) and members of the WebSphere Integration User Group UK  descended on IBM Bedfont Lakes, Feltham, UK for the WUG’s spring-time gathering (2 annual meetings; March at Bedfont, September at Edinburgh). Smart421 was there with one or two of our bigs guns. More on that in a moment.

As longstanding members of the WUG, we get a lot out of these meetings - perhaps ‘cos we also put  lot in. A significant number of our customer engagements require deep Java skills and several depend on WebSphere technologies in some way or another. Most speakers are IBM-ers, many out of Hursley, or sometimes further afield. Delegates from IBM, end-users of WebSphere and IBM business partners make up the remainder of the rich ‘ecosystem’ that is today’s WUG.

Smart421 Lead Consultant, Stu Smith, had his proposal selected by the Committee, which carried the catchy little title ‘Software Development Life-cycle with Message Broker in end-to-end SOA’ [Download the slides]. Nevertheless, Stu pulled a bigger crowd than usual with his piece and people seemed to appreciate his content and the very good Q&A session he triggered; for the last session of the day, it was a lively interactive exchange among attendees, who by then probably had their minds on the drinks reception or what they had to do to catch the early train home.

Alan Mangroo, one of our elite tekkies, attended for the educational tracks and was last seen diving in and out of sessions he has pre-selected. Knowing him, he’ll have made copious notes, so try to make a point of reading his separate blog [posted 08 April, click here].

The WUG has been running for ten years in the UK (yeah…I know !) and the Committee didn’t run past the opportunity to celebrate with drinks and two rather impressive cakes to mark the occasion. I’ve included a photo, courtesy of Alan Chambers, so you can share the moment with us. Proof –  if ever you needed it – that even tekkies have soul, so long as you bring the candles ;o)    Actually, I only remember cute miniature marzipan figures: developers with laptops.

As is often the case, Smart421 ran a on-stand prize draw for a bottle of Bollinger and appropriately Nigel Gale, the WUG’s first chairman (pictured, far left), was the one who swooped the 1st prize. Good timing I’d say. Hope you enjoy that, Nigel.

This years Autumn JAX conference was actually two conferences in one. The OSGi DevCon shared two days with the main JAX event. Conference delegates were then free to attend sessions from either conference. This meant that developers with little experience of OSGI really benefited from gaining insight across sessions. This years event was very well attended, the huge conference room in the London Novotel was packed, with people standing. The sessions were only 50 mins each which meant they were kept concise and to the point, so no chance of getting bored. The smaller rooms were intimate and made asking questions much less intimidating. You could feel the enthusiasm of everyone during the breaks, people were chatting and networking rather than hiding away behind their laptops. Lets not forget the lunches, the food was excellent, a great choice of dishes to cater for all tastes.

The first session I attended was Ted Newards keynote speech entitled ‘Rethinking Enterprise’. Last year Ted spoke about developers needing to find their unique selling point in world of cheap developers. His speech this year started off along the same lines. He asked the question that all developers would like answered… “What do I do to ensure I don’t get replaced by a cheaper developer?” What does this have to do with rethinking the enterprise, I wondered?

We are all programmed to jump to the most obvious solution to a problem. When at school we learn a single subject then get tested on that subject. We learn another subject then get tested on that subject. Even if the questions in our test are different to what we are used to it is a good bet that they are related to the subject we have just learnt about. As adults we attend training courses. After attending a course we return to work with our newly gained knowledge and our boss assigns us a new project. We automatically assume that the new technology we have just learnt about is going to be what we should use to implement this new project. Why else would we have been sent on the course? The same goes for enterprise applications. When someone asks us to design or implement an enterprise application we automatically think J2E and more often than not EJB . Admittedly this is a highly simplified and contrived example, but there is no doubt that we have pre-programmed solutions to problems that we are asked to solve. We may think that we are choosing the ‘Best practice’ solution, however ‘Best practice’ suggests that we have finished and there is no room for improvement. Ted challenged us to rethink this and not settle on the first solution that comes to mind. We should really look for ‘Good practice’ as this allows us room for improvement. This kind of thinking allows us to design solutions that others may not think of and therefore give us that advantage and unique selling point that we need. Don’t just settle on the obvious solution, explore the less obvious and you never know what you may find.

Another interesting and more technical session was on the subject of RESTful services. This session was run by Neil Ford from Thoughtworks. SOAP based web services have been around for a while now and are widely used. This session started off with a brief introduction to REST and its benefits over SOAP style web services. SOAP based web services are often orchestrated using a heavyweight BPEL engine. This often couples together the application providing the SOAP service and the BPEL engine. The BPEL engine must maintain the state of the process, the applications involved in the process may also maintain knowledge of the process state. This is where HATEOAS provides a mechanism to manage the state in the applications that are involved in the process. At its most basic level a REST service request is simply an HTTP request using one of the four HTTP verbs, GET, POST, DELETE, and PUT. These requests are always resource based, so you GET an order, or DELETE an order etc. The parameter string of the request URL contains all the relevant input data. REST and HATEOAS provides the ability for the application providing the service to return the set of potential next links, ie state transitions. The state transitions of the process are stored in the links rather than a heavyweight BPEL engine. A simple example of this idea that we have all seen is a search engine result page. You submit a query to a search engine and are then presented with an HTML page of results. If this were a BPEL process the BPEL engine would know which page of the results you are viewing. If you click ‘next page’ the BPEL engine would know what page is coming next and return that for display. With HATEOAS the links on the page contain the actual next page number in the URL. So if we are viewing page 2 the next page link would request page 3 and the previous page link would request page 1. There is no need for the search engine to know what page you are viewing. The state of your search process is implied by the possible transitions stored in the links, therefore encouraging a stateless approach. HATEOAS may well be the future of SOA that provides an alternative to the usual SOAP based web services.

The final area that I’m going to write about was a session entitled “Software Quality – you know it when you see it” by Erik Dörnenburg. We all want to write quality software, but how do you spot quality software? We often have to work code that was written by someone else, or code that has been around for years evolving as requirements change. If we are working on a new project or legacy code we need to quickly determine problem areas and issues that exist. We need a view of the application. Our introduction to the applications will probably be a diagram consisting of some boxes with lines joining them together, the 30,000 feet view. If we are lucky a detailed design document may tell us what the application should look like, but these are often out of date and lacking in real detail so little use when looking at code quality. Lastly we have the code itself, the 0 feet view. Far too much detail when it comes to understanding an application. What we need is the 1,000 feet view that is generated from the code itself. Erik took us through several visualisation techniques that provided a very fast way of understanding an application. The “Code City ” was probably the most interesting visualisation.

This is essentially a 3D map of the application that allowed us to quickly understand the structure of application. In the above example classes are represented as buildings, while packages are represented as districts. Problem areas are easily spotted. For example a huge building may highlight a huge hard to maintain class. Dependencies between packages could be drawn onto the city allowing us to spot problem areas very quickly. These kinds visualisation give us that 1,000 feet view where we can see potential issues very quickly. As with all these new techniques it is the initial setting up the visualisation that is the time consuming part, but as tools mature this could be the future of metrics and tools such as Checkstyle.

Smart421 normally attend the Websphere User Group, however this is a very specialised event that may not interest many Java developers. I would certainly recommend the JAX conference to any Java developer no matter what level of experience you have. In our day jobs we often concentrate on a just few technologies for several months while working on a project. We don’t get the time to explore technologies, frameworks etc that give us the inspiration to ‘Rethink the Enterprise’ or just give us a head start on our next project This kind of conference is a good way to find out about cutting edge Java technology at a useful level of detail.

I was recently fortunate enough to be able to attend the JAX London conference at Hammersmith. The JAX series of conferences have been going since 2001 although this was their first event here in the UK. The event itself was held over 3 days at the Novotel London West in Hammersmith; it consisted of multiple speakers, over a series of different “tracks”, covering a variety of topics. These different tracks covered agile development, architecture and Java enterprise development. In addition, there were a set of keynote sessions. One of the nice things about the structure of the tracks was that you were not “locked into” a particular track each day but could move from session to session as different subjects caught your interest.

Unlike other conferences that Smart421 frequently attends or presents at, this was more focused on developers, architects and to a lesser extend Project Managers (mainly on the agile side) whereas previously Smart421 has focused on seminars and conferences aimed at business decision makers.

The first session I attended was entitled “the busy developers guide to iconoclasm”. An interesting title to say the least, I went into this keynote not knowing what to expect. The main thrust of Ted Neward‘s talk (an excellent speaker, by the way) was that with the expanding global job market, it is no longer sufficient for a successful developer to see himself as just a “code monkey”. Many emerging markets can provide coders at a rate far less than what any Western software developer would accept as a basic salary. In order to compete against this we need to bring more to the business than just providing code (even high quality code). The iconoclasts of the title are technology practitioners who were able to challenge preconceived ideas and succeed! These are people that just went their own way or did their own thing, these are people who made a success where others said “it can’t be done!” A suitable example was the rise of Apple Corporation thanks to the massive commercial success of the Apple iPod.

The idea of questioning what we accept as everyday decisions and the default “best practices” would be raised a few more times through out the conference. As new technologies arrive, the old ways may no longer be the best way forward. Every few years the best practices have been redefined, and the correct way of doing things has changed. Some of you will be able to remember when the mainframes ruled corporate IT. Since then we have moved to Client – Server being the “best practice”. This gave way to the “n-tier” architecture, then the web-enabled AJAX solution. Now, we have the rise of the Cloud. Procedural programming was superseded by Object Orientation. Now we can add Dynamic and Functional programming to that mix. Currently every enterprise solution starts with “a client application talks to a server which talks to a relational database”. This is the “default” option selected by business, architects and software companies as this is what they know, it’s familiar and it’s “what we have always done”. With these new paradigms we should be looking at this “default” option and asking “is it correct for this problem?” Does our data fit into the relational database model? Do we need concurrency across all our servers in the cloud right now? Can we survive with making our data consistent when it matters and not instantly?

With these shifts in thinking, we need to refocus on what is actually important to our applications. Entities such as “Transfer Object” are actually an oxymoron. What you are interested in is transferring data not objects. What defines your program is the data and the operations on the data, you are not really interested in the actual objects themselves. With the transfer object problem there is a real danger of exposing your data access details from yor data tier to your UI and presentation tier.

During the Tuesday evening there was an open panel discussion covering discussion on the future of Java, the JVM and the rise in newer languages such as Scala, Clojure, Groovy, Ruby, etc. With these new dyanamic and / or functional languages gaining more and more attention over Java there is some concern as to whether or not this was showing bad signs towards the future of Java as a whole. Dynamic languages, such as Ruby and Groovy, add scripting to the JVM platform and even feature interactive prompts unlike the current statically compiled Java language. Functional languages, such as Scala and Clojure, have been gaining more and more attention and provide features of interest that are not available in Java (e.g. closures). These languages have been gaining more and more attention instead of Java. One of the important things to gain from this was that these languages are being run on top of the JVM. Rather than replace Java, these languages are able to compliment Java by sharing the JVM. Any code written in a language like Scala is converted to byte code and run on the JVM, as is Java. Rather than seeing this as the death of Java, this shows how much power is available to the Java JVM thanks to these languages; do you require an object oriented solution? there is Java. Do you need to use a functional language? Well, we have Scala and Clojure running on the JVM! Dynamic language? You can have Groovy or Python on the JVM. Pick the tool that gives you the best solution to your problem.

When does a busy developer find time to learn or investigate one of these new languages? Well, this goes back to the opening of the event, if you are going to provide more value to your employer than an off-shore developer then you will need to invest in your own career yourself and spend some of your free time investigating these new languages. Anyway, you became a software developer because you enjoy coding right? And what could be more fun than learning a new language!

It would unusual to have a gathering of IT people without a mention of the cloud these days. Various parts of the architecture track focused on the cloud and cloud architectures. Without going into detail here on the differences of IaaS, SaaS or PaaS, the focus during JAX London was on the development of cloud solutions. When moving to the cloud there are several possible approaches depending on the amount of scalability required: is it a simple matter of adding more “tin”? do you require the use of parallel computing or are you going to use an already available platform? There was also some discussion on clustering and consistency of data across servers. When moving to a cloud solution, do you require all your data to be consistent across all your servers? If you can avoid this requirement then the overhead of maintaining every server in sync can be reduced or removed. Some examples of this are sites such as Amazon. The stock catalogue only needs to be update when you place your order, when you are browsing the site does it matter if the stock level drops from 80 to 60? When you are adding to your cart do you need a real time stock level of 54 items rather than the previous cached value of 62? Make sure your data is consistent only when it matters.

I found I gained a lot of useful information and insights into current Java development. The strength and quality of the speakers chosen only added to the event. If the opportunity would present itself I would be interested in attending a future event. The next JAX London conference is scheduled for 27-29 September 2010.

Following the recent acquisition of Sun by Oracle an interesting discussion kicked off via email within our WebSphere practice. The general consensus was that it probably wouldn’t change things that much but that it would be interesting to see how they handled their new toys while the BEA ones were still pretty shiny.

Today I came across this article http://www.infoq.com/news/2009/06/g1-paid. Whilst consisting of nothing more than speculation it raises some questions and elevates this a little higher up my list of things to keep an eye on.

Is there anything in this? Have Oracle got a masterplan to make money out of Java where Sun failed?

Follow

Get every new post delivered to your Inbox.

Join 1,084 other followers