Category: Software Engineering

Coding, Python, web development, architecture, and deployment

  • A Better In App Purchase Model

    A couple years ago I gave my girlfriend one of the best christmas gifts she’d ever gotten. It was a pair of tickets for a full day at the spa. The catch was that she had to gift the other ticket to one of her girlfriends.. the second spa pass wasn’t for me. I gave her the gift of being able to give something to her friends. She felt good that she could give her friend a great day at the spa, and her friend felt special that she got to go for free.

    My purchase was a win, win, win for all three people. I looked like a stud to both her and her girlfriends, my girlfriend got a great day at the spa and gratitude from her friend for the free pass, and her friend got a free day at the spa and the special feeling of being chosen as the one to go.

    I think there’s a nugget of an idea here for the evolution of a better IAP model in games. The idea that the status of the person buying an IAP purchase can affect their social standing in the game community though gifting to other players is huge for two very profound reasons:

    1. The gifting is public and therefore provides social proof that someone is spending money in the game. Proof that other players are spending money is a huge motivator
    2. The social status gained by being the one who is gifting to other players is real. Even in a virtual community complex social interactions happen, friendships develop and status within the community is important.

    If a game can provide these sorts of social benefits to their IAPs in addition to the in game benefits then the stage is set to motivate a huge number of buyers.

    I have not yet seen this in practice in a game which makes me curious if there’s a way I could quickly test this idea out in a game I could develop. If only I had time.

  • The Web Sucks

    I’ve been bouncing around between working on native Applications and web apps for the last few years. Having experience with the state of the art in both areas of software development. One thing I have found is that web development is not nearly in a state that programming a complex application is sensible.

    A modern web application is probably leveraging client side MVC with a framework like Backbone.js or Angular.js. These are great frameworks that allow us developers to finally create web applications that behave in a usable fashion on the internet. These are definitely a step in the right direction. However, these frameworks bump into a hairy mess as soon as you start to work on the Javascript code needed.

    Javascript simply wasn’t designed to power these sorts of complex web applications and as such the language lacks a lot of the higher level syntax for organizing massive code bases. Without these language constructs it’s difficult to avoid having the code evolve into spaghetti.

    The separation of structure and style (HTML vs CSS) seems great in theory but in practice it’s hard, and limited. Between fundamental limits of styling, and the bugs/differences between browsers, targeting a pixel perfect design is an exercise in frustration. In fact attempting any non-standard layout of a web page is frustrating beyond reasonable. Add to this the new design requirements that websites should be responsive and scale down or up to all screen sizes and orientations and now you’ve probably tripled the amount of work to do.

    These hurdles result in much longer development times and more bugs to fix along the way.

    Native Applications on the other hand provide two key advantages to developers. First is that designers are generally not requesting uniquely laid out, graphically intense applications, so standard widgets are usually ok. Second is that for different types of applications there are better layout techniques available to use. Simple desktop applications can be designed in an interface builder tool while something like a video game can be flexibly done in code.

    Both the web and native sides of app development are still evolving so it’s not simply a case of the web catching up. Native is a moving target which is itself getting better all the time as well. However with the web your technology is much more restrictive, you can’t simply opt out of HTML/CSS and write client side web applications in C++. Where as if someone writes an amazing predictive layout system in Go, you could feasibly write UIs in it tomorrow.

  • Code Reviews: Good or Waste of Time?

    I’ve been working with a team in Pakistan for the last couple weeks on a project which is starting to reveal itself to me.  It is an iOS game that’s nearing completion and should be ready to submit next week.

    Perhaps it’s just that as a professional software developer it’s hard to accept sub-par quality code and ship it as my own product. In this case I’m doing a code review and finding so many things that were done that wouldn’t take more than a minute to fix but were not done.

    My question is: is it worth the effort to try and push best practices on the team I’m working with?  Should I take the time to re-factor and debug their code so that it lives up to my standards? Should I integrate myself into a team leader position to coach my developers to get better?

    Just for some idea of the quality of code. Some of this code makes me a bit stomach sick… like not using #define for numbered constants. resulting in code thats like:

    if (tag == 2){ 
      check=999;
    }
    

    Other bits of code obviously taken from other projects hasn’t been refactored to change variable names. Code styles are all over the place. Best practices are thrown out the window.

    My biggest takeaway from this is to absolutely enforce access to a git repository during development. As soon as I started looking at the code I had to fix it, and now it’s in a state where it’s difficult to merge in fixes that the team does. Start working on the code early on to fix and refactor things.

  • High Performance Static Websites on Amazon S3

    I’ve been seeing more frameworks lately for generating static websites. The reason for these becoming more popular recently is the result of several developments.

    1. Cheap shared hosting is notoriously unreliable, slow servers overloaded with too many websites and hacked servers being able to infect and hack many other sites at once.
    2. The development of 3rd party services such as Disqus to power the dynamic parts of a website with embedded javascript. (removing the requirement of server side logic)
    3. The scalability, performance, uptime and low cost provided by Amazon S3 and their CloudFront CDN service.

    The difference in cost between a scalable dynamic site and a scalable static website can be staggering.  So if there is a way you can convert a website over to be static (perhaps with a daily or hourly upload of new content) it may be worth your while.

    A website with 1 million page views per month on Amazon S3 with CloudFront would cost roughly $6/month depending on the size of the assets.  Building up a simple server configuration with 1 database server and a webserver with small EC2 instances would bring the costs up around $150/month.

    One of the nice things about developing a static website is that you can script things however you want to.  Concatenate strings in bash or PowerShell or go all the way to having a complex database backed CMS system and template engine.  It also means massively less complex server infrastructure.   No more nginx reverse-proxied gunicorn server paired with a database server and a host to tools to monitor uptime and send alerts should things break.

    It’s for these reasons that I am working on my next project to have a static website backend instead of a dynamic django app.

    Using a template engine like Jinja2 it is trivial to convert content over to static files ready to be uploaded.

    Some tricks may be needed to handle things in a more complex static site.  Perhaps a small light server to refresh the static content every hour, or to run scheduled tasks, or to do other various asynchronous jobs.  Still the costs can be brought way down if your servers don’t have to handle the web requests.

     

     

  • Cockiness of Programmers

    There’s no doubt that programmers are lazy people.  Anything that can be automated is, copy/paste code – you got it!

    There is another trait of programmers that they assume because they can program in one language well, and have touched a few other languages over the years they can quickly learn a new language on the job.

    Programmers are arrogant about their own skills.

    The article What If Cars Were Rented Like We Hire Programmers? exemplifies the problem though their analogy is not accurate.  A programmers job is more like the mechanic or factory worker building the car.  If you had built or fixed only Subaru Imprezas for 10 years then you are not amazingly qualified to fix Fords.  If Ford is looking to hire, they know that there are 1000’s of mechanics more experienced on their cars in the pool.

    I say this because after several years of writing Javascript, learning on the job, I finally decided to pick up a book.  The first thing I learned was just how much I didn’t know.

    More programmers need to read books to master the skills they need on the job instead of relying on Stack Overflow and Google to solve all their problems when they arrise.

    The thing to watch out for is the situation where you read someone else’s code and say to yourself “I have no idea how this works, or what it does”.  As a programmer that should be a red flag – you don’t completely grasp the language syntax.

    If you don’t have a complete handle on the syntax of a language chances are you also don’t know how to write idiomatic code.  Without those two things mastered the code you do write will be poorly organized and buggy. The next programmer to come along to work on your code will hate you.  You will be that guy who everyone bitches about for writing bad code.

    Bite the bullet, read a book from time to time.  Always be Learning.

     

  • Bitcoin

    Bitcoin has been in the news a lot lately and I’ve finally got into the game with a small investment to play with.

    Bitcoin is a new form of currency  which is technically quite ingenius but from an economic standpoint is quite unstable.  It’s basically a digital, anonymous, peer supported replacement of cash.  Each transaction is confirmed by others participating in the bitcoin network so that fraudulent coins are not spent, and money isn’t spent twice.

    The value of each bitcoin has soared over the last 2 months from $30 to over $200 per bitcoin.

    The way new bitcoins are created is through an algorithm called ‘mining’.  It’s designed to grow the number of coins linearly regardless of how much computer power is mining or how many are being used.

    This is ultimately the biggest problem with the currency.  Lack of control over the supply means that the price of it is dependant on demand on currency exchanges.  The price of a bitcoin is skyrocketing because recent news coverage has created an exponential increase in people wanting to buy some while the supply of new coins can’t meet that demand.

    Markets are fickle things, especially when untrained non-sophisticated traders are working the markets.  Quick emotional reactions will at some point result in a crash.

    If you were using bitcoins right now to do business you’d be having massive deflation effects.  The value of the bitcoins you have would be going up and therefore anything with a fixed price is becoming more expensive in hard currency.  If you were paying your employees in bitcoin then over the last 2 months your business expenses would have increased by 7x.

    In Canada the Bank of Canada’s main job is to manage inflation.  Steady inflation is what allows us take loans and expect to be able to pay them off, to hire workers at a set wage, to set product prices and have them maintain the same price day to day.  The controls over inflation don’t exist in bitcoin so the risk is quite high.

    I’m not sure where it will go in the future.  Will bitcoins hit $1000 each?  it’s possible. $10,000? maybe.  It will for sure be a bumpy road though.

  • Andromeda’s Savior v1.1

    Icon-72A late night of coding produced the first update to Andromeda’s Savior submitted to iTunes.

    This new version brings a health bar, a bunch of new enemies to shoot, and much improved Game Center integration.  It also includes a check to prevent people from cracking the game and getting free upgrades.  To date there are almost $5000 worth of purchases that have been given without payment.

    I’m particularly interested in seeing how the game center stuff works to improve the replay-ability of the game.  It will now show you, as you play, a picture of your friend who has a higher score than you as an encouragement to challenge your friends.  It adds focus to the players playing the game and should at least for some people egg them on to play more and for longer.

    The new update should be in the store next week.

     

  • How to SOA an existing project

    SOA or service oriented architecture is a way of building a complex project so that each individual unit can stand alone with a documented API.  There are many benefits to taking an SOA approach to designing a complex software system.

    To those familiar with programming, SOA provides the same sorts of benefits as OOP but at a higher level of abstraction and with a network interface rather than a code interface.  The benefits of providing encapsulated logical units that can hide the complexities is well understood by most experienced programmers.

    For a business taking a SOA approach to building a complex project makes a lot of sense.  It allows teams to be divided into smaller groups to reduce the communication load and help limit the scope of the problems that any one developer has to concern themselves with.

    So how do you take a monolithic piece of existing software and change it to SOA?

    The first and perhaps most critical decision to make is where to cut your application into pieces which can become isolated services.  The most obvious first approach might be to cut between the GUI and the business logic.  That is usually NOT the best thing to do for any real complex project.  Deep coupling of the UI usually makes this division much to big for an initial undertaking.

    Likewise starting with something too small can lead to an abandoned project.  A simplistic project that can be ‘finished’ such that no developer ever has to be familiar with how it was built can lead to problems down the road when it breaks and no one knows how to fix it.

    So an SOA unit should be logical,  it should be not too big that it is destined to fail, and not too small that it can be forgotten.

    A further guide to finding an aspect of the code to pull into a service is whether it will have more than 1 customer or could have more than 1 if it was a service.  By customer I mean anything that might want to call into it’s API.  For a HR system the customers might be the GUI used by HR department, tools used by managers, excel spreadsheets used by the CFO and a business intelligence dashboard for the CEO.  With that many potential customers of an API there is a strong benefit to having an SOA approach compared to asking HR for quarterly reports or sending them emails to update an employees phone number.

    One further option to consider is to wrap your entire application in an API so that it can be leveraged somewhere new.

    On one project I worked on we had a complex requirement for managing encryption keys. We needed a way to expire old keys, provide redundancy against server failures, and have a nuclear missile style 2 person/2 password login process.  It made sense to develop this as a stand alone service.   It paid off with a project that gives us confidence that some newbie programmer can’t easily create a critical security hole in an application that uses it.

    Amazon is perhaps the best case study for a successful SOA deployment.  Their SOA approach has spawned entirely new billion dollar businesses (AWS).  One of the benefits they’ve seen is that because of their highly used SOA APIs the requirement for testing is greatly reduced.  Incremental updates get slowly rolled out providing time to listen for errors.  On these highly exercised APIs regressions can found quickly before any harm is done.  The actual use of the service provides a much more complete test of it than any test suite could possibly perform.

    Perhaps the best place to start on an SOA conversion project is to see if there is already some natural divisions in the developers knowledge and experience within the existing code base.  Creating SOA services based on these natural lines will ensure that the new teams will already have an expertise in their service and reduce the learning/ramp up time.  Domain knowledge is the biggest hurdle for any programmer (ie it take a lot more time to switch from enterprise software to video games than it does to switch from Javascript to C#).

    So you’ve got an idea for where to start.  The next thing to decide is what the API should look like.  I prefer RESTful interfaces because of the lower barrier required over something like SOAP for clients.  SOAP would make things like a bash shell script difficult to do.  I also prefer JSON over XML for similar reasons but also because XML allows for some style inconsistencies between developers such as should something be an attribute or child.  Should authentication be done with simple username/password or are there requirements for something like OAuth?

    Your team should probably develop a couple of libraries in some key target languages for their API.  This hides things like URLs and encodings behind a more obvious code API.

    Documentation is also very important.  An undocumented API will probably never be used by anyone.  Both the raw API and any libraries should be documented with examples.  If it’s a public API, put your libraries up on github.com so that other developers can easily find them and keep up to date.

    Work in some analytics if you can for the new API.  Tracking usage and performance of your service is fascinating and can provide some key insights into where improvements could be made.

    Lastly, a new SOA project will include some new infrastructure and deployment requirements.  You’ll need to decide on server requirements, uptime and redundancy for this new service.  As well as write any new deployment scripts for it.

    So an SOA conversion is not a trivial task.  It does come with some overhead which is usually made up for by growth of the service as it finds new customers and new use cases.  Reducing the scope of a large project into separate services provides less easily measurable benefits such as reducing communication costs, reducing the scope of future changes and making the project easier to understand.

  • Finding a good A/V receiver

    My 12 year old A/V receiver bit the dust last week.  It seems to have overheated and burned out some components judging by the smell.

    So now I’m looking for a replacement.  The first thing I learned is that the Canadian stores all price the products at about 2x what they go for on eBay in the US.  In fact, price shopping for a receiver opened my eyes to just how ripped off we are up here.

    When the Canadian dollar reaches parity with the US dollar there is generally the occasional news story about how the price of books is not getting adjusted.  Books are singled out because they’re one of the few products that put both the Canadian and US price on the label.  Most other products have the good sense to hide that information from us.  However that price disparity is there on everything, and it is often even bigger on those other items.

    The biggest problem with buying something like a receiver is that they all kind of suck in my opinion.  It’s very nearly impossible to know what is good or bad, or what sound/video quality differences are even noticeable let alone worth the price.  Setting up these machines is usually the issue.  Bad interfaces make it difficult to know if things are plugged into the right spot or whether your inputs are in the correct formats.  It is difficult to put good information into a one line text display to help understand what might be happening on any of the 50+ inputs/outputs on the back.  Massive knots of cables are a nightmare to look at and figure out.

    What I’d like is a HDMI only for inputs, and a decent amp to power 7.1 surround sound speakers.  Not much else and no legacy support for outdated standards – drop s-video, composite video inputs, and no CD player inputs or phono.  With such a simplified receiver the interface would be as simple as select input and control volume.  As far as I can tell that doesn’t exist.

     

  • Next Gen Websites

    the web 1.0 was defined by static html pages and simple cgi scripts.  Web 2.0 was marked by improvements in CSS and HTML capabilities, as well as growing influence of Javascript especially with AJAX to make things a bit more interactive.

    The next significant shift in the development of websites is moving a lot more of the page layout and generation to the client side and implemented in javascript.  The web server won’t be generating full pages anymore, only snippets and raw JSON for CRUD operations.

    Web 3.0 is enabled through several MVC frameworks such as Backbone.js which encourage application logic to be moved client side to the browser and the server serves up the raw data and persists anything required to the cloud.  These next gen websites give the developer a more clear line between UI code vs server side persistance.

    It makes sense to move control of the HTML layout and rendering over to Javascript because that’s what it was designed to do.  Adding a template language and renderer on the server side only to further manipulate the DOM client side is a bit of a duplication of responsibility.

    The learning curve for this change is a bit steep.  Check out ToDoMVC for a review of the javacript libraries/frameworks available.