Sunday, September 30, 2012

AdMob, a painless experience

I have a couple of android apps in the Play store at the moment. I am offering them for free because they are essentially something I wrote for myself and a way of testing the process of generating apps and managing the full life-cycle without having to do it on someone-else's code. I went through three iterations very quickly, with a first draft that had working features but a few niggly problems. A second draft that got rid of the errors thanks to Google's superb crash reporting scheme that helped me identify real bugs very quickly and trace them down to the line of code where the failure occurred. Finally, as an experiment I decided to add advertising support to the system with a view to using it in later applications.

AdMob was easy to set up, easy to integrate and has begun generating a (very) modest revenue even though the applications only went up with AdMob on board this afternoon.

My iPhone version of the app is almost complete, I sidetracked to complete the Ad support for the original and so now its full steam ahead for the iPhone version in a few days. All I need to do is re-instate my Apple developer status which I allowed to lapse a few months ago.

After this app, I will be full steam ahead for the Windows Phone version but I see that as more of a one-day job because I know pretty much all I need to about the platform and so there will be no discovery phase for me on that one.

All in all a very smooth experience!


Saturday, September 29, 2012

Its templates all over again!


Many years ago I worked in the world of C++ developer tools and had the job of creating libraries that some other poor sod had to buy, understand and use. Through many years of doing this, I came to a few conclusions about how reusable architectures should be created and the sort of programming techniques that should be used.

Sort of in the middle of my time as a tools developer, ATL, which, if you don't know it, is a system based upon the principles of C++ templates that essentially rely on massive amounts of multiply inherited classes. Its a very "clever" way of programming to be sure but is incredibly hard to read and trying to follow program flow within a templated class is a nightmare.

I think that Anders Hjelsberg actually had recurring nightmares about C++ templates and so invented C# which is singly inherited apart from interfaces and is generally straightforward to work with and eminently readable.

One of my colleagues was a template guru. Lovely fellow, very productive and wrote nice tools but having a style of programming that just made me wince every time I read through his code. It was so esoteric and overly templatised that the whole lot of it just became a blur. The customers had a hard job understanding it too.

So, years pass and Anders decides to add some nice little language features to C#. Features that start off with generics and go on to anonymous methods, lambdas and so-on.

Today I've been programming an Android application in C# using Monodroid from Xamarin and I suddenly realised that my classes only have one method. All the event handling, asynchronous calls, and even marshalling back to the UI thread is done with lambda expressions. I am horrifically reminded of templates just simply because trying to follow the program flow through an activity that uses reverse-geocoding via Google's map APIs, progress bar indication on the phone screen and reporting to a web-service of user actions puts me in mind of the code complexity of C++ templates.

I have become my own worst nightmare!

AXML got a designer!

A while back i reported an issue to Xamarin regarding the failure of the axml (android form markup) designer. I updated this morning and lo-there was a designer in Visual Studio!

I don't know why but I find axml particularly annoying to work with when hand coding. Maybe its my familiarity with WPF that has bred contempt for it. Anyhoo, a new design time tool for Android apps is a good thing.

Friday, September 28, 2012

Apple screws up. Microsoft too, Whats up?

The recent debacle of Apple's mapping software probably has poor Steve Jobs spinning in his grave. It's exactly the type of utter balls-up that he hated and would have taken the time to deal with personally before that crap went out the door. The post Jobs era looks to be shaping up as "more of the same" corporate incompetence with lack-lustre CEOs and uninspiring products.

Likewise the failure of Windows 8 to capture the imaginations of developers and the hopelessly ivory tower approach of Steve Ballmer leaves Microsoft in the gutter again.

Where has all the passion gone from the computer business? What has happened to people with the balls to stick their necks out for a principle and to make products that inspire some sort of emotion in the user? 

I've been a professional developer for all of my thirty plus year career and I can see today that despite the incredible opportunities for technology that would make your head spin right off your shoulders, greed, desire for a status-quo and lawyer driven crapware has become the norm.

Oh for the days of Steve and Bill!

Thursday, September 27, 2012

Monodevelop and DefaultKeyBindings

Frustratingly, MonoDevelop has a custom key binding scheme such that if you come from the Windows world and expect your End and Home keys to work in the time honoured tradition you're out of luck.

I just spent a few hours scratching my head over the problem because I habitually press the end key to go to the end of a line and on a Mac it goes to the end of the document. It is possible to remap this behaviour using the DefaultKeyBindings.dict file however, MonoDevelop overrides this too and defeats all your chosen bindings once again.

So, if you want to be able to use the key bindings on Monodevelop on a Mac but retain the editing style that Visual Studio / Windows developers are used to, and why not because if you're using MonoDevelop on a Mac it's because you're used to C# development but want to write MonoTouch, then you must go to the preferences section of the MonoDevelop application and add your own preferences for those keys.

Tuesday, September 25, 2012

API changes. Someone needs a kick in the pants.

Some years ago I worked in the heady world of developer tools and learned the hard way that changes to an API that other people rely on must be carried out in a careful way. Failure to do so will result in people's code being broken or them being forced to do a lot of work and people being pissed at your product doesn't do sales any good.

Unfortunately, the newbie programmer cubs at Apple don't understand this. They obviously see API changes being a way of sweeping out old mistakes and replacing those ideas with the new-hotness of their own.

I despair of so-called "architects" who have no concept of how to maintain and develop code. Too many cub-programmers solve problems at the keyboard, that is to say that they type stuff in rather than draw a flowchart or "design" a coherent API. As a result, interfaces get changed, API's don't have consistent parameter usage, API's don't get consistent naming and so on.

Cubs are cute, they run around doing cute cub things and they are all fuzzy and lovely. However, when it comes down to the business of being a bear, the cub has a shitload of growing up to do and a lot of scars to obtain before they can be big and badass when they need to be. Hey Apple. Don't leave cubs in charge!

Saturday, September 22, 2012

Android -> IOS

Ok, rolling up my sleeves today with the idea of transferring my recently released Android App to IOS.

For me, this will be the proof of concept that creating multi-platform apps from similar base code works. How much discovery and head-scratching will I have to do to make the very simple droid app run on an IOS platform. Moreover, can I use similar techniques on that app to the ones used in the Android world?

The clock is ticking!

Low Maturity

Once again the ridiculous effects of a world run by lawyers conspires to make an innocent thing into a sordid one.

When creating an Android app, one is forced to declare a rating of "Low Maturity" if the app uses the GPS. Never mind that the app might be used solely to inform you of your own position, the implication is that use of a GPS automatically suggests use for sexual predation of some sort. Of course, when masturbating, most people like to know exactly where they are by using a couple of billion dollars worth of orbital atomic clocks to verify the position using Einstinian relativity calculations. I know I do!

Friday, September 21, 2012

C++ and C# programmers are too smart!

It seems that way anyway. I was browsing around today and discovered that Visual Basic projects in Visual Studio 2010 have the option of importing an XML document and inferring a schema using a wizard.

Of course, we C++ and C# programmers are "Real programmers" who, unafraid of the command-line interface and of the complexities of the XSD.EXE parameters are quite capable of shelling out and generating our schemas by hand. Ha! I say. What happens when the lowly VB programmers want to generate a set of classes for their schema??

MWAHAHAHAHA! We should hold all the schemas to ransom and MAKE THEM PAY FOR THE DESERIALIZATION CODE LIKE THE WUSSIES THEY ARE!!


Freeware at what cost. Part 2

You may know my stance on freeware. I'm not generally in favour of it because it degrades the intrinsic value of the programmers art. Freeware can have many purposes though. There is the purpose of pride in having created a great solution to a problem coupled with the altruistic notion that one doesn't need remuneration for  some work. There is the purpose of camaraderie, wishing to provide something interesting to like-minded people and there is the purpose of commercial exploitation when a freeware is in fact generating something that might be even more valuable than money, such as for example, trust.

The last time I offered any freeware it was in the early 1990s. I became incredibly impressed with the game Myst by Robyn and Rand Miller. It was everything I wanted in a game. Rich, challenging, enthralling and with a visual impact that brought fantasy landscapes to life, albeit in 256 colours, in a way that enabled the dullard graphics of the day to make the experience as immersive as it could be. Myst inspired me to write a wireframe scene editor that output 3D images via the Polyray and Persistence Of Vision ray-tracers that were also freeware at the time. My editor, called WinModeller was a C++ editor for shapes that had some nice features and that I wanted to use to make educational content along the lines of Myst. In the end, I got a job working for someone else and nothing came of it. Eventually, someone bought the code from me for 25,000 dollars but then didn't do anything with it because times seemed to have moved on I suppose.

Today I am offering some freeware again. I have my android apps which are on Play under the name of BPApps and I will probably create more for iPhone and Windows Phone platforms. I had not intended to choose a free model for these packages and had originally decided to make them freemium with a small payment to unlock full functionality but, really, looking at the market place and the software already available I didn't feel that I could truly justify even a meager demand for money. I may go to an ad-based monetization of later applications but these ones, which I really wrote for my own use, can be shared with like minded people and will, I hope, engender trust in my brand. Of course I wouln't be churlish enough to flatly refuse a donation or two for the code but that's at the discretion of the user. The app works well for me so I'm cool with that.

Interestingly however I do have a different angle. In developing the code for Android machines I've come up with a way of making that code very much easier for porting to other platforms. I hinted at this in March of this year when I spoke at the Software Passion conference about creating multi-platform applications. I have a nice method for doing this now and I will be releasing some tools later that I hope will generate a little revenue.

So, is free really free? Who can say. As I get older I tend to think not. Does not-free imply paying money? Nope, definitely not. Facebook is free but the currency of Facebook is in the data generated by it's users and the spinoff sales of stuff other than the Facebook social app itself.


All is vanity

I am fifty two years old and have a lot of, well, not gray, but more like white hair. I went out with a couple of friends the other day, both of them a bit older than me. Their hair is not gray, their hair was dark for one or a sort of ginger for the other. I suddenly realised that these sixty year old dudes coloured their hair! Not even a wisp of gray was to be seen on the men and especially not on the women.

I suppose that I had not seriously thought of colouring my hair in the same way that I wouldn't wear a backwards baseball cap or allow the waistline of my jeans to show a large expanse of arse, well, not intentionally anyway. Besides, my underpants, not that you're interested are not classy or make the right, if any, sort of statement.

My vanity is sort of opposite. My Grandfather, William Anderson was born in 1906 and became a granddad because of me when he was fifty four years old. At that time his hair was gray and later turned a snowy white. White enough to make a polar bear jealous in fact. My granddad was a man who was constantly interested in something, even up to just before his untimely death at the age of one hundred and two years. Granddad gave me my sense of curiosity and a desire not to waste my time. Granddad gave me Charles Dickens, Robert Lois Stevenson, Jules Verne, George Orwell. Granddad  showed me what trigonometry was for when I had berated a math teacher for being a boring twit. Granddad showed me how to ride a bicycle when my dad was working and my mother didn't care. Granddad told me that all the important things in my life would happen by complete accident which I remembered when a girl I really really fancied fell over, I helped her up and she held my hand all the way home.

I could never dye my hair or cover up the shocking gray and soon to be white that I will inevitably carry until the day I die because to do so would be to insult the genetic code of one of the greatest men on earth. My white hair is a badge of honour for me. Thanks Granddad!

Thursday, September 20, 2012

Android app crashes

I just got my first two independent Android apps up online and was pleased to see the error reporting service that appears in the developer console. My app crashed on someone's phone, I got an error report, fixed the problem and issued a release immediately.

If you're interested in my apps which enable camper-van or RV owners to find tank-emptying points, check out BPApps on Google Play.


Friday, September 14, 2012

I've told you a million times!

To enunciate "I've told you" a million times would take eleven and a half days if you did it non stop...

For really pedantic parents that tell their children a billion times not to do something, that would take about thirty one thousand years.

Donations gratefully received

Can some kind soul get me an iPhone 5?

Mono Android html asset localization

While on the subject of localization, I have created some activities of my app as static web-pages. These pages can be stored as an Android asset and loaded at runtime. This provides an easy option for creating complex layouts without the hassle of doing it all in that horribly tortuous axml format.

A static web page can be saved in the Assets directory and reconstituted using Assets.Open(...). This can present problems however because assets are not localizable in the same way that strings are. Rather than duplicating the HTML in the strings.xml files and localizing each on individually, I created a barebones file with replaceable chunks that are themselves localized.

An HTML file could contain:

<html>
<head>
<title>{TITLETEXT}</title>

here be scripts and good stuff...

</head>
<body>

{BODYTEXT1}

Here be boilerplate...

{BODYTEXT2}

</body>
</html>

Obviously the html would need to be complex enough that you wouldn't want or be able to duplicate the whole thing. A good excuse is that maintaining the same page info in one place is better than maintaining it in every localized resource file.

So, to load my HTML in I use:


            var wv = (WebView)FindViewById(Resource.Id.registerwebview);
            var sr = new StreamReader(Assets.Open("reg1.htm"));
            string barebones = sr.ReadToEnd();
            barebones = barebones.Replace("{TITLETEXT}", Resources.GetString(Resource.String.registertitle));
            barebones = barebones.Replace("{HEADERTEXT}", Resources.GetString(Resource.String.registertitle));
            barebones = barebones.Replace("{BODYTEXT}", Resources.GetString(Resource.String.registerblurb));
            wv.LoadDataWithBaseURL("file:///android_asset/",barebones, "text/html", "utf-8", "");


Et voila.. a localized HTML page that looks great, contains images also pulled in from assets, scripts, links and JQuery interactions with the backend...


Six impossible things before brunch...

This week in scientific news there have been reports of a mathematical proof to the ABC conjecture, apparently junk DNA isn't, scientists have taken a picture of molecular bonds, high-temperature superconductivity has been induced with the aid of scotch tape, a neural implant in a monkey's brain has restored decision making capability and the Higgs Boson data has passed peer review.

Developments such as these were traditionally few and far between but the rate of advancement today is reaching a truly phenomenal pace. Almost every day, a breakthrough in some esoteric scientific discipline that has far-reaching consequences for green energy, medical science, electronics and computing or some other high-profile area of study is brought forth upon the world. What we know already is being applied to discover what we need to know that the rate of actually learning the principle or truth vastly outstrips our meager capacity to use it in a practical way.

Today, a woman with a spinal injury that would have rendered her immobile for life is walking around, albeit with the aid of a robotic exoskeleton. What would that have done for Christopher Reeve? Self driving cars collaborate to show each other what's around the corner that they cannot actually detect on their own. Thought-directed helicopters, games and wheelchairs are not even newsworthy any more. Microsoft has patented a "holodeck".

I wonder what tomorrow's breakfast will bring?

Tuesday, September 11, 2012

Mono Android App Localization (part 2)

The process of app localization in any platform is exacting. Many programmers who don't have the discipline to do the job from the very beginning run into problems when the application has some strings localized and some in hard-coded characters that were put in hastily.

Android applications have a great localization scheme but some disadvantages. Here are some tips that I have learned while creating a multi-platform application. I am using MonoDroid and MonoTouch for my development

#1 Localization strings must be kept organized. Ensure that you organize the strings by activity and label the sections with <!-- XML style comments -->

#2 Do not rely on the [Activity(Label = "MyActivity")] attributes. Remove them all and explicitly set the label for the root layout element in the layout files using localized strings.


Sunday, September 09, 2012

Android Emulator battery charge indicator.

Dear Google,
I think there's a bug in the Android SDK Emulator battery charge indicator. When running the emulator on my Macbook Air, the emulator charge indicator shows charging all the time, even when the computer is running on battery power.

This presents several problems. Firstly, if the emulator takes even more power to charge itself when the computer is already running on battery power, the extra drain will reduce battery life even more. I suggest making the emulator run on its own virtual batteries when the main computer is running on its own batteries. Secondly, the process of virtualizing electrons for use in the virtual batteries obviously takes a lot of energy so this should only be done when power is applied. Lastly, and this is the really big problem. If I don't need an emulator any more and I delete it. the virtualized electrons will be erased along with the rest of the data. This will cause a net deficit in the fabric of the universe and my Macbook Air will implode. So far the unibody casting is holding up but it seems to be groaning a little and the R,T,Y,D,F,G,H,C,V and B keys seem to be bending in a bit. Please advise quickly...

Bright spot on Macbook Air screen.

Macbook Air computers have a problem. In certain conditions a bright spot, about an inch across, appears in the center of the screen. Is this due to a problem in the screen backlight controller? Is it a sign that your MacBook Air is malfunctioning? Is it a sign that your screen will soon be dead?

Apple already know about the problem and call it "Irreparable" so? How can you fix this otherwise irreparable problem for very little money? I know and I'll let you know the secret for free!

When you're sitting in the sunshine, with the sun streaming through the Apple logo on the back of the screen, Put a box of Corn Flakes in just the right place to make a shadow!

Thursday, September 06, 2012

IE 9 Dumped in favour of Chrome

For some time I've been suffering from an odd problem with my PC. The desktop provided by Explorer.exe often crashed becoming completely unresponsive to clicks. The computer would also slow to a crawl with web-pages being particularly badly affected when opened in any browser.

I did a little research online and found that Internet Explorer would sometime crash, leaving an instance of itself in the task-manager and never actually closing correctly. The consequence of all this being the aforementioned desktop freeze.

It seems that this problem has been around for a while and existed in Vista and IE8. I am running Windows 7 64 bit edition and IE9. In any case, the symptoms are identical.

I used the control panel's Add-Remove Windows features dialog to remove IE9 completely. Since then, yesterday, my desktop has remained in functioning condition and the low internet speed problems have gone away.

My default browser is now Google Chrome.

Wednesday, September 05, 2012

Should I sue Apple? Should everyone sue Apple?

I broke my iPhone. The glass on the back is utterly smashed because it fell, from a height of less than one meter, onto a tiled floor.

Actually, when you come to think about it, a mobile phone is one of the things in the world most likely to be dropped. It is taken from and replaced into pockets and bags maybe hundreds of times a day. I don't make a hundred phone calls but I do look at mail, send messages, check sites, use maps, scan QR codes etc. etc. all the time.

I had an iPhone 3G which I bought in 2008 and used until recently. My wife smashed her iPhone 4 by dropping it while sitting in an armchair, it fell less than a meter and I had to replace the screen and the back.

Apple, in my opinion, have not made sufficient effort to render their smartphone product robust enough to cope with normal every-day usage. If a car manufacturer built a car that screwed up during normal every day use they would be forced to recall and fix the defective product. I want my phone fixed!

Monday, September 03, 2012

Cathedral or bazaar?

Many years ago I took a position against open source software. Why? well, quite simply, as a pretty much full time freelance programmer since the mid 1980s I've come to have an appreciation of the value of the effort that I put into writing code. My attitude was at the time that open-source software eroded the value of the brainpower that it took to generate an elegant algorithm and do reduced the worth of my own brain as a money-making device.

Now, people say that its very possible to make money from open source. Well, this is true, however not because open-source code is a saleable item but because a lot of it is so poorly usable that consultants make a stack just by being able to troll through and understand poorly documented and esoteric code. If open-source is so fantastic, why then is Linux in all its various forms not viable competition for Windows? A few years ago, PC manufacturers began releasing PC's without an operating system or even with Linux pre-installed. That seems to have fizzled out and now Windows 8 running on ARM chips will absolutely be king of the hill for the next little while.

I will not deny that there is open source software that is great. Unfortunately, a lot of it has been produced by big rich companies specifically to piss-off someone else. There is for example no reason whatsoever for Open-Office except that Larry Ellison wanted to erode the sales of Microsoft Office as much as possible by providing a free alternative that does pretty much exactly the same thing. Later of course he tried to cash in by making Open Office a commercial product, thereby giving the lie to all his previous open-source rhetoric.

Code released on CodePlex is generally not created by altruistic chaps starving in garrets for their art, but as a by-product of the many tracks of development effort that Microsoft starts and deprecates but decides not to waste entirely. People piggy back onto that too.

My own code released on my site at http://www.bobpowell.net was, for a decade, not entirely an altruistic effort to share my knowledge, I do enjoy doing that but I was very conscious of the fact that my efforts in that regard netted me an MVP award that didn't injure my career one iota, nor did the free access to MSDN Ultimate which is a bit outside of my pocket-depth.

Spooling forward to today then, how has my attitude to open source changed? Well, I am very interested indeed by open-source hardware and resurgence of maker culture that was an important part of my early life. When I started in programming, unless one had a rich mummy and daddy, getting a computer like an Apple II or Commodore PET to program on was not easy. I built my first Z-80 based computer from scratch on hand-soldered boards and with TTL chips that I reclaimed from boards dumped by a nearby PLESSY factory in Cowes Isle of Wight. Today, Arduino and Raspberry PI and other systems are providing a cheap and accessible doorway into a world of electronics and programming that had become progressively more closed and software-commodity based as the years rolled on. Today, you can build your own electronic gizmo again with hardware designs that are easily understood and programmed. I see that as an important form of education in a world that has bred the ultimate dumbass consumer.

My belief is that the role of the professional programmer will diminish over the next ten years as software begins to write itself using genetic algorithms. The process of specifying what is actually required by the software will become declarative and the actual process of creating the code will go away. People will need to find interesting things to do apart from work and it is important not to allow the machine to become its own closed domain. Open source as a work practice may have failed in my eyes but open source as a way to interest people and steer them away from unquestioning consumerism might just be a success.