May 22, 2012

NextBeer, a sample OpenApi application for T-Mobile

Last summer I responded to a request for proposal from T-Mobile in Poland. This rather large telco, wanted to share its services in an easy way on-line, so that every little private developer could use them, a bit like Facebook/Amazon does. We got the job, though the news came so late, I had already started another project (for yet another telco), and as an effect, could not participate in the one for T-Mobile.

The project has a fitting name: OpenApi, because that's what it really is. An open API for everyone who wants to use it. I've heard there was an initiative, to build a common API for all telcos, quite a smart move which would ease creating applications even further, but for now it's custom designed and build.

My friends finished coding a portal for developers, and I was asked to write a sample application. It made a lot of sense to me: the guys deeply in the guts of the system, should not create samples – their perspective is different to real users. I, on the other hand, while knowing what the system is supposed to do (I wrote the proposal together with Piotr Jagielski), haven't seen in yet.

And so, a sample application was born, created in Grails, though a bit Java-style (I wanted to keep it familiar to all those Java/C# folks, who know no Groovy).

The user story is simple. It's Friday, late evening, you are sitting in a pub, together with your friends, but the place is going to be closed at 10pm, which is very unfortunate, as the sweet brunette on your right has just noticed your presence.

You need to move the party forward, to another place, so you take your shiny, last-gen iSmartphone from your pants, only to find out its battery has died. Running all those apps of your design was really demanding.

So the sweet brunette on your right, pulls her old, dumb Nokia, and send an sms. Few minutes later she gets one back, with addresses and phone numbers of all the pubs in 3km range. That's how far she can get on her high hills.

Your party is saved. Your sweet brunette may be truly yours someday. The application which responded to the sms and saved the day, is the sample application I wrote, using OpenAPI and Google Places. It's called: NextBeer.

One picture is worth thousand words, so here is a sequence diagram for the whole thing.


You can find the code on github: https://github.com/jakubnabrdalik/nextbeer

I won't go into details, the code is self documenting, and there is even a nice tutorial for all those who know nothing of Grails (though it's in Polish, as that was the target audience of my example).

If you want to register to OpenAPI, to write your own, go here: https://developers.t-mobile.pl

Hope that saves you a nice brunette one day.

May 21, 2012

GeeCON 2012 review

Bruce Almighty!
GeeCON 2012 is over. This year I've decided to go for 3 days, where the first one was a „University day”, and the other two were regular conference days. „University day” is a misleading name, you'd think it's something for students, for beginners perhaps. The idea, as far as I know, was to have a day full of workshops, but as there was just one bring-your-own-laptop TDD workshop, it turned out to be a „normal” conference day, with 2h talks.

Now, „normal” doesn't mean bad. Quite the opposite.

As usually, this is my little review of the conference. Take into account, that with up to 5 parallel tracks, I've seen no more than 25% of the whole event.

Wojtek Erbetowski, pointed out, that as we gain knowledge, it's getting harder and harder to find something amazing at a conference. I was overwhelmed with new knowledge, the first time I went to one, but since I try to keep up to date, since I visit up to six conferences every year, and since speakers tend to give the same talks all over the country, I consider a conference fruitful if I take one thing that can help me in a substantial way.

I'm happy to report, that it was the case with GeeCON.

University Day started for me with Dierk König talking about concurrent programming in Groovy (GPars library). Dierk is a commiter to GPars and a co-author of „Groovy in Action”. Chances are, that if you're using Groovy, you already know the lib, but if you don't, it's got pretty a lot of ways to deal with parallel programming without touching threading manually. It's got STM (Software Transactional Memory), Actors, Agents, Communicating Sequential Processes (CSP), dataflow stuff and more. There's even a thing called KanbanFlow. Yeah, the Kanban in name is not accidental. And the best part: all of this is relativly easy to understand and use.

His talk was good, but to tell the truth, I've seen a GPars presentation at GeeCON 2011, by Václav Pech („Pick low-hanging fruit"), and even though Václav had just an hour, I think his talk was better.

Unfortunatelly, the following Dierk's talk: „Pro Groovy”, was both short (just 1h), and shallow. Dierk was talking about Abstract Syntax Tree transformations, but while I hoped for a show of how to write AST Transformations, Dierk managed only to show a few build in annotations, that were handled by them.

I wish Dierk was available for a whole day. If you are a planning a conference and thinking about whom to invite, please consider asking Dierk and giving him a whole day for a really pro workshop.  That would make my day.
   
Gavin King and Stéphane Épardaud were introducing us to Ceylon, a new programming language on the JVM. If you are wondering, why should you care about this one, you shouldn't. Give it a few years, and check again. The talk was nice, though.

Then came Bruce Eckel with „Atomic Scala”. Bruce is writing a new book, and the idea he has is to create something for complete newbies in programming, allowing them to learn Scala as the first programming language. The goal is noble, but that means you shouldn't probably buy it, because it's way faster to explain a lot of language constructs comparing to another language you know, than to explain it from the ground up. Bruce's talk was too basic even for such a dumbass as me.

Bruce also gave the opening talk “The Power of Hybridization”, the next day, and thought it lacked a thesis (Bruce had to finish at about 70%), his deep, multilingual perspective and tons of anecdotes, made it very interesting to me. By the way, if you've read about how slides should look like (no text-reading, only slogans, full screen pictures, etc.) Bruce is doing exactly the opposite thing. Nobody cares, when you have something to tell, though.

I'll skip Ivar Jacobson's “Liberating the Essence...” talk, as it lacked.. the essence. I'll also skip Gavin King's “Ceylon: the thinking behind a new language”, as it was just the same thing as with any other Java-replacement language I know of.  Let's move to Adam Bien talking Web Containers and Java EE.

Terminator @pub in Poznań
Adam Bien is a Java Rock Star, Champion, expert, writer, consultant and what else, so you'd correctly assume, his perspective will be very orthodox, especially when you consider that there were at least 4 other languages represented at the conference (Scala, Groovy, Ceylon, Kotlin). But he made a point – the main reason we take all those libs/languages, we change EE containers to web containers + frameworks, is that we do not know Java EE 6 well enough (before 6, using pure Java EE was masochism at best). And then we tend to reimplement/rediscover the things Java EE has already solved.

The thing he misses, though, is that it's easier to learn and use those “other” technologies, than do proper Java EE. And yes, after years of corpo-failures, programmers tend to be biased against Java EE.  Thus, while Java EE is finally good, and it makes perfect sense to stay with Java EE, if you are a Java EE master-blaster, I doubt you'll be as productive as with for example Grails. You'll do good to pick whatever you'd like to learn, and learn it throughly.

Adam's talk was refreshing. Apart from guys from SoftwareMill, I haven't seen anyone talking about Java EE 6 with such expertise and sanity.

And then came my favorite talk. Sam Newman from Thoughtworks, talked about design and architecture with emphasis on rapid release.

Wojtek Erbetowski showing a prototype
of an operating system on top
of a prototype of a hardware
There aren't many talks about architecture at Java conferences. In fact, there are hardly any. I guess  it's easier to fill one hour showing some language basics or a library, than to explain and explore an architecture and its consequences.  Thoughtworks was present at 33rd, with James Lewis and micro services, and I see that the lessons they've learned, are being propagated to other projects. I won't go into details of micro services, as I've already done that reviewing James' talk. Sam was happy to present a case of how to use system decomposition (micro-services at a service per Bounded Context level), and what the effects are.

Some of his learned lessons were:
  • beware of shared lib and serialization protocols (evil for microservices)
  • do not send internal representation of data across the wire (things change)
  • fuck WSDL, go with simple XML, Xpath, and let every service prepare stub-tests, so you can safely change the schema when you want to
  • codify the contract between services with writing a test (the reason is the same as above)
  • do not share database between services; you'll make it impossible to evolve them independently; you can use one database with different schemas
  • data should be owned by the service it uses (similar to above)
When I say I'm interested, and that I see potential here, I really mean it. I'm about to lead a development of a bank system, implementing such an approach. We are already using many small, dedicated to single purpose apps, written in different technologies (Java + Spring MVC, Scala + Play), that communicate via RESTful HTTP, and we are going to expand on that concept. We'll see whether we can keep it so simple as Thoughtworks implies. I'll let you know when we have some outcomes.
I was hopping between presentations for the next hour, as I have either already seen then somwhere else, or was uninspired after a few minutes. Then I went for James Williams, talking about Ratpack. I really feel sorry for James, he made quite a trip here, but as this was the last presentation this day, and he had guys like Bruce Eckel as an alternative, not many people showed up.

I've started the last of the conference with Thomas Sundberg and his rather basic talk about all the wrong things we can do to fail a project. As there was nothing new to me, I left early. Then I moved to Kevlin Henney to listen about OOP in Java (deja-vu? not really), and to Tomasz Kowalczewski talk about Closures in Java 8. That was similar to Simon Ritter at 33rd, but focused solely on Closures. Great talk, nice stuff, Tomasz did great work, though it's a bit disappointing that functions are not going to be first class citizens. Yet.

Oh, well, no reason to go back from Groovy, I guess.

And then there was Piotr Gabryanczyk with Scala, Akka and Camel. That was also a great talk, showing simplicity of programming using those technologies. I wonder how it fits Thoughtworks' micro-services, or are we getting too close to ESB and single point of bullshit that way.

Kevlin Henney closed the conference with examples of cool code. His talk was fantastic, funny, and inspiring. Especially examples. One of the best closing talks I've seen. Thanks.

And there were parties. But that's a completely different story.



Saturday was for Open Spaces, lead by Bruce Eckel, but I couldn't attend.


PS: Some pictures are courtesy of Michał Lewandowski. I've totally forgotten my camera.