If you’re like me, you have a dozen or more books on your bookshelf that you will never ever read again, but you have never considered throwing them away. With titles like “Learn C++ in 30 days” and “3D Game Programming in Java” or whatever. Maybe even something like “PHP 4.0 Tips and Tricks” (ok I made that one up, I don’t even want to look at my bookshelf right now). Because once you learn something and do a few projects in it, you don’t really need to read the books anymore. Well, those are the good books. The bad books, you bought them because you thought they would help you and they turned out to be utter crap. Most computer books are like that. You walk into a bookstore and there’s 10 books on C/C++/Objective C/C design patterns/C#, and “C is the new Cobol”. Maybe a dozen more on C game programming, Linux programming in C, and a dozen more, and you sit there and shake your head. Then you walk over to the Java section and the situation repeats. Except this time it’s worse because in addition to all the normal bloat you have the “Android Section”. And this is where your hell really begins. Because most android books really suck.
Thank god for the internet, I always say. So I went home and downloaded a dozen books on Android development. I ended up buying only two of them which I will name shortly. The losers deserve no mention by name, although I will talk of them first. They were all current (2.1/2.2 and up as of writing). They all looked good. Some of them seemed to be the best in their class. Some were from famous publishers and some were by relatively well-known and experienced people. The main problem is that they were obtuse. And this is a difficult thing to get around since programming for Android is a whole new world from Java. Yes, it’s Java, but it’s like nothing you have ever seen before. Personally I think the people who designed this system were genius dropouts. Genius because the system works, but dropouts because it is a horrid pile of crap from the standpoint of getting in the door.
See in the past you would do programming for an interface by loading the values you wanted into a data structure and sending that data structure to some sort of class library slash interface. This is just how things have been done for billions of years. But along came things like Ruby and AJAX and CSS and suddenly it began to look like the Lisp guys won. You have major services like Twitter using Scala. Scala. Why? Because it’s not mainstream.
But this is besides the point. There is so much XML and other cruft you have to wrap your head around that it is like programming in a different language. There’s absolutely no reason why you have to type stuff into an XML file when Java has a perfectly good way of instantiating arrays of values in code. XML is NOT more human-readable than Java code for doing this, especially for people who have been in deep with the Java for a long time. I’ll give you an example. The layout and value XML code is full of stuff like this:
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="25dip" android:text="@string/main_title" android:textSize="24.5sp" />
ok. ‘splain this to me. How is this any different from a simple Java class file, where say a .layout() method is like…
View view = new TextView(); view.layout_width="wrap_content"; view.layout_height="wrap_content"; view.layout_gravity="center"; view.layout_marginBottom="25dip"; view.text="@string/main_title"; view.textSize="24.5sp"; this.setView(view)
Short answer: It isn’t. It’s just more difficult to switch contexts and switch files all the time. And it’s more expensive to process by the computer as well. Which, surprise surprise, ends up converting it into machine code along with everything else and running it. The XML crap is a bane, and you have no choice but to learn it.
So, about those failed books? All of them beat you over the head with this stuff. They make things so ridiculously complex, cutting and pasting things in 4 or 5 different places just to declare a class and have it fit in the “Activity” model — which in itself is a giant .wtf().
But I promised I wouldn’t whine about the poor design decisions that went into setting up a public Android Development Environment. This is about books. And the best book I ever read was “Hello Android” by Ed Burnette. I cannot believe how good this book is. If you read anything else, you are wasting your time. Well, that isn’t entirely true. I did read another book which was just as amazing as Ed’s. But I won’t tell you what it is yet. I’ll save that for part 2.
“Hello Android” was really a godsend for me. The examples they use were not assinine (like making a social network app – Jesus Christ which marketing guru got fired over that one) and not useless (no names, no names). The book was also COHESIVE which I cannot stress enough — no other book was as cohesive. What do I mean? Well it’s difficult to describe. Halfway through other books I just felt lost and was like “Shit I better keep reading, and maybe something will sink in”. But nothing ever did. It was one useless paragraph of long winded bullcarp after another. But not “Hello Android”. No, this amazing book was easy to read. For the first time I found myself actually understanding layouts and actually understanding getting from point A to point B with things like buttons and handlers and Activities and Views.
Thank God for “Hello Android”. Thanks to Ed Burnette, my Android adventure has only just begun.