Friday 21 February 2014

Android Programming: Day 2... (Yes, this blog post is really going to be that exciting!)

Sadly, there’s been no word from Joleen, she of the big boobs and even bigger butt, but I have managed to create a SQL database inside Android, so you needn’t be too downhearted.

[Counts to three before he opens his eyes and looks to see who’s left in the room…]

If you’re still reading, it means you’re one of the better few who are less interested in pornographic internet SPAM and more interested in a misguided dabbler’s attempts to wrap his brain around Javascript. How easy is it to develop an app to run in Android, you ask? I’d say surprisingly easy, though the Android SDK running on Eclipse does create a functioning ‘Hello world’ App for your as soon as you install it. So in that sense: it’s very easy. In some ways, it’s actually easier than developing software for the PC, especially if you have an Android device plugged into your machine. The updated app code runs straight on the device so you get fewer of those ‘bugger, I’ve just crashed my PC’ moments you get when developing things for the PC.

I started this little ‘project’ about two days ago and I already have an app which does quite a bit more than say ‘Hello world’ and it’s running on my old Android phone which has become my unofficial test bed. I also have it running on my tablet but since I use that almost constantly, it’s not as easy to keep it plugged into the PC and it won’t be until my new ultra-cheap-but-long micro-usb cables arrive from China.

I don’t exactly know why I’m writing an app except the other day I was searching for something to do a specific task related to my cartooning. Not being able to find anything suitable on the Play Store, I began to wonder how difficult it would be to simply write it myself. I used to program databases after I did my computer degree – which, I should add, taught me next to nothing about programming – and before that I’d been a complete computer junkie making simple games with even simpler graphics. Every meaningful thing I’ve ever known about programming has been self-taught yet I’ve never truly taken the time to learn Object Orientated programming and what little I know about Javascript is based on my somewhat limited knowledge of C. I am an old school programmer completely out of his depth with newer code. In the past, I’ve often written simple things to run inside a web browser, to change the various random phases on this blog, for example, but I’ve always wanted to know how to develop a proper app. My cartooning hasn’t been going so well – no bugger seems to ever like anything I draw – and my writing is at a standstill given that the agent still hasn’t replied yet it’s probably a little too soon to send the book elsewhere. My enthusiasm for blogging is also at a new low and my ‘real’ work is just destroying my will to live. What better time to add another string to my bow?

The last couple of days have been about information overload and absorbing as much as I can. I’ve been selectively reading chunks from different huge tomes on Javascript written by clever people who don’t know how to write. That’s not to say that they’re incapable of writing but they’re incapable of writing for the audience to which the book has been marketed. The best I’ve found so far is ‘Android Apps for Absolute Beginners’ by Wallace Jackson, which has become my new Bible and I’ve read from cover to cover. Last night I also attempted Jeff “JavaJeff” Friesen’s ‘Learn Java for Android Developers’, which I thought I didn’t necessarily need but hoped it might help me remember the stuff I’ve long forgotten. About half way through an early chapter, I fell asleep and woke up to realise that I didn’t have a clue what he was talking about. Only a few pages earlier, I’d been told how to declare a variable and then I was suddenly deep into the murky territory of inheritance, polymorphism, and upcasting.
Following the cast, the contract’s reflexivity, symmetry, and transitivity requirements are met by only allowing Points to be compared with other Points, via expression p.x == x && p.y == y.

Sometimes clever folk need somebody a lot less clever to put a hand on their shoulder when they get excited and ask them to rephrase that for people without a doctorate in abstract logic. Of course, the fault might well be my own. I’m a terrible student since I never attempt the examples they write in the course of these books. I always want to get to the meat of the business. I get frustrated having to read five pages about how to change the colour of text, which is the sort of thing I tend to figure out quite easily. More difficult for me was learning how to open new screens from the main screen. It was obvious in the end but it was the kind of top down structural approach to software development I really needed at the beginning. Had they said that an Android app is made up of many ‘Activities’ which are essentially concurrent and each declared in their own file, I might have had a better idea of what I was doing.

I don’t think learning things my way is necessarily bad. It forces me to have an active knowledge of real programming rather than the kind of passive knowledge you get by simply reading other people’s code. I believe writing is best learnt by writing and speaking a language best learnt by speaking a language. Programming is best learnt by getting the hardware to do what you want it to do. My app might not break any records and surprise people with its originality but it will do what I want it to do and that’s a better achievement than simply producing the same code as you could have downloaded from your tutor’s website.

At this point, my ‘App’ is like some kind of Texas Chainsaw hillbilly with pieces chopped from different places and stitched together. Yet it actually does what I wanted and I’m delighted it works. I only have one functioning button, a menu system which deletes the database and then restores it by reading in data from text files, and my Settings page only reports things about the database just to assure me that the database actually exists. I wasted three hours yesterday trying to figure out why my database wasn’t being created only to later discover that my database existed and was fully populated with fake data but my ‘checkDbExists’ routine was flawed.

Christ… Does anybody find this kind of rambling blog post interesting? I’m not bright enough to actually write a meaning post about Android programming but I’m too dumb to realise I should just shut up and get back to it.

Today I’d like to figure out how to open a file selection dialog to import and export data. Later, I’d like to allow them to modify records and then start extending the functionality to the actually things I’ll hopefully find useful.

No comments:

Post a Comment