All posts by David Saltares

Libgdx at the London Java Community Meetup


Next Tuesday 3rd of February I will be talking about Libgdx at the London Java Community Meetup. Things won’t get too technical, I’ll introduce the framework, explain why it’s so awesome, show who is currently using it in commercial products and give a quick demo at the end. Of course I won’t miss this golden opportunity to cheekily mention my Libgdx Cookbook!

If you’re interested, sign up and come to the The Skills Matter eXchange, doors open at 6.15pm and the presentation should be around 40 minutes long.

Ashley 1.3.3 released


As you can see, Ashley development has slowed down a bit. I would like to think it’s because we have a feature rich and stable framework rather than people having lost interest! Anyhow, there’s still been quite a bit of progress, enough to warrant a new release.

Ashley 1.3.3 is now out.

  • API addition: added getEntity() method to Engine, it is now possible to retrieve entities by their ID. This will ease networked entity systems.
  • API addition: added getEntities() method to Engine, which returns an immutable array of all the entities registered with said engine.
  • Bug fix: remove old component when adding a new one of the same type to an entity.
  • Bug fix: fixes component not being added to an entity when done from an entityRemoved() family entity listener handler.

The new nightly dependency is com.badlogicgames.gdx:ashley:1.3.4-SNAPSHOT.

All unit tests are passing, the wiki is up to date and life is good. Enjoy Ashley and don’t forget to report anything that doesn’t work as expected.

Recover history with Git

While doing some cleanup of old feature branches, I accidentally deleted one that hadn’t been pushed to origin yet. However, I didn’t realise at the time.

After a couple of weeks, a hundred commits and many other branches mingling about, I found myself looking for the one I had previously deleted.

Oh noes!

Luckily for me, Git is somewhat idiot-proof and rarely truly deletes anything. Using git reflog you can list the tip of branches, including the deleted ones. Once you find the commit you were looking for, you can just use git checkout to get it back. This will detach you from HEAD, so you will probably want to create the old branch again with git checkout -b name.

Most of the time, there will be too many commits and the search might be painful. In that case you can grep the results. Let’s say you know the commit message had feature x in it.

git reflog --grep='feature x'
git checkout 123456
git checkout -b feature-x

I really love Git.

Book review: Clean Code

clean code uncle bob

I recently had the pleasure to attend a few lectures by Robert C. Martin, also known as Uncle Bob. He’s a software consultant, speaker and fierce advocate of agile methodologies as well as TDD. Not only were the talks entertaining, but also deeply inspirational.

Seeking more information on his ideas, I decided that it would be good to take a look at his flagship book, Clean Code.

And so I read it.

It has definitely changed me as a developer. I cannot look at code the same way anymore.

Clean Code offers a set of very simple guidelines to help us improve the quality of our codebases little by little.

You start by looking at that unholy class nobody dares to touch. Once you get the gist of it, you realise some methods and variables should be named differently, for clarity’s sake. Immediately after, you identify some duplication and factor that out into a different function. Later on, you decide that a particular method is too big and it should be broken down. Maybe this class is doing too many things, lets split it up into smaller classes that do one thing and one thing only.

Oh my God, suddenly that monolithic satanic pile of garbage has been tamed. Future developers (including yourself) will be able to understand it and work with it much better.

Hang on! How can we make sure that it still works?

Unit tests!

As developers, it is very much our professional duty to work in such a way that allows us to thrive in the long run. We can only deliver and maintain a large project if we keep things under control. Doom is certain if we do things quick and dirty and absent discipline.

Clean Code is far from being the panacea but it does provide us with quite a few tools to work towards that goal. Uncle Bob exposes the reader to several practical exercises. A piece of bad code is listed, studied and refactored step by step until it becomes a much readable, cleaner and correct chunk of work.

I personally loved the book as it is fun, positive and tremendously useful, cannot recommend it enough.

By the way, you can ready more by Uncle Bob on the 8th Light blog.

Libgdx at Kingston University

kingston phones

Last Monday 24th of November I delivered a small lecture about Libgdx at Kingston University of London. This complements Alberto’s Libgdx workshop at Cadiz University last week as part of a series of activities to promote Libgdx and our recently released book.

I talked about what Libgdx can offer developers as well as the advantages of using open source tools as opposed to proprietary technologies, especially when it comes to students. Just like in Alberto’s talk, we gave two copies of our book away to a couple of lucky students!

Sadly, no pictures were taken this time round, you’ll have to take my word when I say that quite a few people showed up. Thanks for that!

As promised, here are the slides in case anyone is interested.