Thursday, December 12, 2013

How do you respond to "Who cares? It's going away soon anyway."

I am hearing this more and more "Who cares? It's going away soon, just hack in a solution!" Guess what? Nothing goes away soon. Unless the replacement is fully written and ready to ship and the users have no choice but to upgrade then it is going to be around.

What is your response when this dilemma is posed to you?

I try my best to avoid hacks. I want to use the best possible coding practices when possible. So, when are they not possible? Let's say one of your apps has been internationalized and localized. You are working on an second company app that has not been. It might drive you crazy to add yet another hard coded string to that app but doing it right and starting the whole internationalization / localization process is not going to pay off in this situation.

Maybe you are on an app that has styles mixed in to the HMTL instead of being in CSS files. Not hard to create a CSS file right? Nope but it might create large changes to the build / distribution process thus doing that towards the end of a release cycle might not be the best idea.

Maybe you end up in some Java code that only uses Vectors where is should be using List and ArrayList with generics. If the collections are localized then I would probably fix them.

I find it depressing when the development staff has given up and goes into hack mode because everything is about to be replaced with a new design. I know code outlives your every expectation.

I was working at a company three years ago that was converting from Java via WebStart in the browser to C# with WPF. For some reason the CEO hated Java even though it was half their income with the other half being the C++ version of the product. Java ran on Windows, Mac and Linux. I worked on the C# product too and left for other reasons than the switch. I don't mind C# although I did not feel it was the best solution here. They pretty much only wanted hack fixes to the Java stuff.

Three years later and guess what? Yep, the Java code is still running in the field. It is taking much longer to replace than originally thought. They have moved it to Java 7 to keep up with Oracle and bug fixes.

I have seen this happen way too often. With the web it is easier to kill something. If you replace all the JavaScript on your server the next time the user hits your web page they get the new code. They don't get the choice to continue to use the old stuff. Mobile is close. Most folks update their apps unless you toss in some new crazy permissions like read all my contacts when you are a simple game. Desktop is a bit harder. Using WebStart allowed us to force the upgrade. On the Mac you get update notifications which is nice. On the PC you pretty much get patch notifications from Microsoft and then it is up to the vendor to write their own. Adobe likes to patch stuff.

As a professional programmer I like to treat all my code the same, like it will live for a long time. I don't want to fall into the hack in in trap. Design it, write it, test it then check it in. I refactor things when method and variable names are getting confusing or no longer reflect what they do. I move things into new objects when the line count in current objects gets out of hand or where a new object or base class just makes sense.

Monday, December 9, 2013

Thought about dipping into Windows Phone dev but it requires Windows 8

I do Android and iOS programming already and I thought about dipping into Windows Phone just to test the waters. I have done C# WinForm and WPF development in the past so I know my way around Visual Studio and C#.

I did a little research and you must have Windows 8. I just am not in the mood to do that. I support my family and my extended family on all things technical. I use TeamViewer to remotely take over their machines to clean up toolbars - oh man do I hate toolbars - and other issues.

Every machine, as of last Saturday, that I support is runnings Windows 7. Finally they are all in sync. I don't want to move to Windows 8. It seems a big MS mistake attempting to combine touch screen and desktop into one platform. I have buddies who have used it and don't like it. It may be more end user friendly but it is less technical dude friendly.

Stinks, I probably could have had some fun playing around with Windows Phone development. Who knows, I might have converted on my apps to it and put it on the store. At this point I am saying NO to Microsoft. My hardware can easily handle Windows 8. I built the machine myself, which is what I have done for years.

If the upgrade was cheap I might consider running it in a VM. But MS charges quite a bit for an OS thus they are keeping me out of the experimentation phase. Real shame MS, you want more phone developers but things like this keep me away.

Oh, just in case you think "Well you bought a Mac for iOS!" Nope, I only do iOS stuff for work, not for my personal stuff, so I only do it on my work MacBook Pro. Heck I could probably Hackintosh my PC via a VM and get a Mac running cheaper than Windows 8.

Updating my first Android game. Taking on a different perspective

I wrote and published my first Android game in a week between jobs. Always good to take time off between positions so I took a week and learned Android and wrote a game. It made enough off ads to pay for entry fee into the Android market plus I learned the Android SDK and have been working mobile jobs since then.

The game had hard coded images thus it did not scale up on tablets or larger phones. I have been recoding the app over the past several months. First I redid all the graphics using Canvas drawing code. Consider them vector graphics instead of PNG files. I can pass in a size to the drawing routines and it will draw all the games pieces to fit. I have been testing on my Xoom, Nexus 7, Note II, Galaxy S3 and original Galaxy. Right now all the game pieces are drawing properly and the game code is in place. The family is playtesting the game.

I have some issues in the help screens that I need to clean up that I found late last night on the S3. Probably get that up and going this evening.

Next I want to add a multiplayer mode. This will not be playing on different devices and not be playing at same time on one device but one player attempting to solve the puzzle then handing it to the next player and the winner will be the one with the shortest time. I have a lot of ideas around this mode that I will work on once help is running smoothly.

Before I ship I need to integrate an ad network and test on all the devices again.

Great, that is all background but what about the perspective change? The first cut and release was all about speed. Getting the game working and out the door. Android tablets barely existed at the time. I tried to make stuff generic but was learning the SDK at the same time so things were hardcoded. Now I am weeding out all the hardcoding and really using the power of Android such as styles.xml, canvas drawing code, various simulators and more generic programming techniques.

At first it was really cool just to say "I have a game available from the Play Store!"Now I want to say "I have a game and it scales and plays on you device and you can play it with friends!"

The help system was confusing. People could not learn how to play. It is much better now as it uses the full game board to show you how to play instead of screen shots snippets in dialog boxes. Even doing that aided me in fixing other areas of the code.

I am taking my time. No need to rush, get it done correctly and test is out on a lot of devices. The game play is in place and the single player scoring system works. I am pretty happy with the graphics although I have been tweaking them a bit here and there. While the single player aspect is nice I feel the multiple player side of things is going to make a much bigger impact. People like to play together. A friendly competition is always a bit of fun. I hope this area keeps the game installed longer on devices and earning more ad dollars.

The more I play the game the more things I see to tweak. My son was playing last night and found an issue. Soon I hope to be playing against him. The more I play the more ideas I have for the multiplayer mode. My first thoughts are not the direction I am going to take. Some of it I figured out while doing the new help screens. It is amazing what you think up when you are forced to relook at the game.

I plan on splitting some of the code out into some other objects too. The main Activity is getting a bit large for my tastes. Most of the code is drawing things so I will be passing a Canvas into objects so they can do their part of the drawing but that is not a big deal. I won't hold on to it, just pass it in for the drawing to occur and be done.

So what is the game? Not going to say until it is ready for release. The current version in the play store, which is a few years old, does not run on a lot of newer devices.

Funny running it on my original Android phone, the first Samsung Galaxy that is now my son's primary device, and how small everything looks. It plays fine on that but once you play on the stunning display of the Nexus 7 everything else looks kind of crappy. Cool how everything scales up and looks fully detailed as I am not blowing up pixels but I am drawing to scale with all the pixels available.

A game makes you use parts of the SDK you never touch while doing business apps. I have not used sound or off screen images in a business apps. Most of those have multiple activities and fragments using standard Android view based controls. I have written custom Android controls that needed to scale but nothing with a ton of graphics. I have not need to access data from styles.xml programmatically in the past. The Android SDK has a lot of power and is very flexible when it comes to running on devices of various sizes.

If the app does well enough on the Android store maybe I will pick up a used Mac Mini and convert it to iOS. I think it would look nice on an iPad and I should be able to port over the drawing code pretty easily. I have done a lot of iOS business development so I already know my way around Xcode and Objective C.

Wednesday, December 4, 2013

Bought a Nexus 7 - my thoughts

NewEgg sent a coupon for 10% off tablets. It was time for me get a Nexus 7. I have a 3 year old Xoom that gets a ton of use around the house but I wanted something smaller, faster and with a better screen.

The Xoom was really starting to show its age. It was heavy and slow. Holding it took two hands. Sure, I would balance it with one hand but then a cat rubbing on my elbow or a kid knocking a knee into it and I would get bonked on the head or have it fall in my lap.

I was using the Nexus 7 (old style) my boss loaned me for some code testing at work. From that I knew it was the right size to be held in one hand. I also got to see how the multiple accounts worked. This is something else the Xoom does not have as they are no longer updating Android for it. I could root it and get something on there but I think I will leave it alone for now.

I had a number of goals for the Nexus 7. I want to read more and not just technical books but some biographies, non-fiction and sci-fi. I have read books on my phone and the Xoom. Again the Xoom is a bit big and heavy to hold for long periods of time plus the screen is just not that great. I grabbed some free books from Amazon via the Kindle app. There are a ton more free books than the last time I checked. It used to be the old classics but now they have a decent selection of newer books.

The screen of the Nexus 7 is impressive. I used the default Kindle font and sepia colors. The device holds in one hand as it just a bit bigger than a normal paperback book as far as height / width but obviously no where near as thick. You don't have to worry about losing your place and having the book close if your fingers slip or you drop it. I found reading on this device to be very enjoyable and plan to read a lot more books on it.

For gaming it is a really good size too. My younger son really likes it over the Xoom. Both devices get used nightly for looking up internet items, checking email, weather forecast, reading books and games. Setting them side by side really shows how much nicer the high resolution and brighter colors shine on the Nexus 7.

Being 3 year newer technology it is a lot faster than the Xoom. Bringing up Chrome on the Xoom and waiting before you can type in your search was painful. The internal browser was a bit easier but it did not share my bookmarks. On the Nexus Chrome starts up quickly and lets me get right to business.

Having multiple accounts is a boon and a bane. I like being logged in as me and only seeing my email and having my home screen look the way I want it. When I install an app it installs to my account. We are not sharing a game so my high score is mine. The levels I complete on games are mine. The bane? I have to install the app under each account if each account is admin based. I just want to pick from a list of installed apps and let them appear under certain users. Not a huge deal.

Battery life is good too. It gets used a ton and holds up well. KitKat installed a few days back. I have not noticed anything super spectacular about it. I did like the old color for the battery and time, not a big fan of white, but otherwise it has not caused any issues.

I enabled developer mode of course. Connected right up to my computer and I have been able to install APK files for the code I am developing.

So far I am very happy with the unit. It is the proper size and weight and the screen is really impressive. It is going to work for book reading, gaming and developing. 10% off was the icing on the cake.