Archive for the ‘Uncategorized’ Category

Ground-Up Android, Part 3: Describing Your Layout

Wednesday, October 7th, 2009

This is part 3 of a 5-part series on introductory Android development. If you’re just arriving, you should head on over to Part 1.

In Part 2, we started an Android project, poked around it a little, and launched an emulator. Now we’ll move on to making the app look like what we want.

You’ll notice I titled this part “Describing Your Layout,” not “Coding Your Layout” or “Programming Your Views.” This is because Android gives you the tools to define most of the characteristics of your Activity’s visuals in descriptive, not procedural terms. This helps speed up development, thanks to the nice GUI-based tools for layout, and helps you keep your programming logic out of the places you define your application’s outward appearances (and vice versa). It’s important to know that you could create your entire app in Java, writing the descriptive code for your layout procedurally in your Activity instead, but it’s a much better idea to keep things separate wherever possible.

The resources

We’re going to build a basic Twitter client, so let’s make it look like one. Let’s switch back into Eclipse and poke around at what we have so far. You’ll recall that besides our Activity’s Java file, we have layout and strings files in the res/layout and res/values folders. Let’s go check them out.

Here’s the basic layout the wizard created for us in res/layout/main.xml:

the main layout xml

The main layout xml

(more…)

Things That Are Awesome

Wednesday, September 9th, 2009

Awesome: DC App Store, a repository of apps and mashups based on DC data feeds.

My fave: Park It DC, possible by the District providing useful data feeds.

15 New Kick-Ass Cupcake Features

Monday, April 20th, 2009

splashscreen-logoAndroid’s much ballyhooed 1.5 release (aka Cupcake) seems to be imminent. Last week, Google released a preview version of the SDK, and I’ve dug through it a bit and kicked the tires. In honor of the impending 1.5 release, here are 15 neat features I really dig.

(more…)

MySQL WTF: “1, 2″ == “1″

Wednesday, April 1st, 2009

MySQL, how ridiculous you are. But seriously, though – what are you thinking?

I learned today (belatedly perhaps) that joining a VARCHAR field to an INT field does something… interesting. To illustrate, try to follow along:

CREATE TABLE `test` (`col_int` INT, `col_str` varchar(10));
INSERT INTO test(col_int, col_str) VALUES (1, '1'), (2, '1, 2'), (3, '2, 3');
SELECT * FROM test t1, test t2 WHERE t1.col_int = t2.col_str;

A pickier database would probably scream about type incompatibilities. But MySQL… MySQL doesn’t care, and silently truncates “1, 2″ to “1″, which it then casts to an int. And this is how you get the string “1, 2″ being equivalent to the int 1.

Only in MySQL-land.

* PostgreSQL fans: I know, I know. Shut up already.

The Hidden Costs of Content Management Systems

Wednesday, February 25th, 2009

So, a few days ago Clay Johnson over at Sunlight Labs stirred up a bit of a hornet’s nest with his post entitled Content Management Systems just don’t work.

Much of the response has come from Drupal/Wordpress/[other CMS] developers, and channels a few common threads:

1. But what if you just want a blog?
2. But you get lots of stuff for “free” (forums, etc.)
3. But look at [awesome NKOTB CMS] – it solves every problem you mention!

Well, yeah. If all you actually want is a blog, then just use a blog – Clay himself points out that Sunlight uses Wordpress (as does this blog). The argument is really directed at larger endeavors. If you really do just want a blog, or for that matter any specific feature that has a well-tested, well-maintained off-the-shelf implementation, then by all means just use that. But that’s not the point.

The point is that when deciding whether to: a) spend serious money in CMS customizations, or b) roll your own platform with the help of Django/Rails/[other framework], option (b) is a better choice in more situations than people think. Why? Because the decision to customize a CMS vs. building something “from scratch” is deceptive, since the “framework tax” of a CMS is more hidden than the obvious blank slate you get when working with a framework.

To use a slightly facile analogy, imagine you’re looking to build a house, and you have (because you’re really picky) very specific requirements. Let’s say that you find a house in a perfect location that’s almost what you’re looking for – you just need to add a third bedroom. In that case, adding on to the existing house might be considerably cheaper than building it from scratch.

But let’s imagine now that the house you found is actually nothing at all like the house you want, and you’ll have to raise the house on stilts, dig up the foundation, add a floor underneath, re-do all the plumbing and electricity and add an attic to fulfill your particular requirements. At that point, it’s highly likely that just building it from scratch will be cheaper than bending over backwards to reuse parts of the existing house – particularly if you can get many of the same components for free elsewhere (let’s say the neighbors are giving away perfect pre-fab kitchens that can be easily plugged in to any house).

Obviously the analogy has holes, and I’ve probably barred myself from the building industry for life, but the point stands – the cost of working within an existing product can be deceptive because the difficulties of working within its rules are less obvious than the missing parts on a blank slate.

It always looks like you’re getting all this stuff with an off-the-shelf CMS – “We won’t have to write any login code! Forums come pre-built! The widgets fidget all on their own! Hallelujah!” The trick is, though, that if you’re already having a conversation about the 10 different things you need to customize in your CMS to make it fit your workflow, there’s a good possibility that the stuff you’re getting for “free” will actually make it harder to do anything else. (And some of the pieces – like user management – are standard parts of most mainstream MVC-style frameworks as well).

Will the “anything else” be possible? Of course. Apparently there are at least two full-featured shopping cart Wordpress plugins. Hell, you can implement a C compiler as a Wordpress plugin. That doesn’t mean you should, and in fact implementing a C compiler as a Wordpress plugin would be considerably more effort (and probably produce a messier result) than just writing the damn thing from scratch.

As with everything else, you have to assess the individual situation and make informed choices. If an off-the-shelf CMS (or other product) really fits your requirements perfectly, then of course go for it. But if you’re going to be making a substantive investment in technology, because nothing quite fits your needs and you’ve made the decision that doing X is a worthwhile effort, remember that even the “free” pieces of a CMS impose a higher “developer tax” when extending the system.