Author Archives: austin

Arrays

Based on what we know, how do we represent a collection of things in a computer?

We must instantiate a variable for each thing we want to keep track of. For instance, this is a way that I could represent students in a classroom:

String student1 = "David";
String student2 = "Ethan";
String student3 = "T.V.";
String student4 = "James";
...

Another example is a collection of test scores from an exam:

int score1 = 70;
int score2 = 86;
int score3 = 94;
int score4 = 89;
…
int score25 = 32;

Now what if I wanted to average all of the test scores, what do I have to do?

double average = (score1 + score2 +score3 + score4 + … + score25) / 25; // this would be a super long line if completely filled out

Wouldn’t it be nice if we could manage collections of similar items in a more succinct way? Wouldn’t it be nice to reference the collection as a whole and grab more granular items when we want?

We can manage collections with arrays!

What is an array? It’s a data structure that has a fixed length and can hold 0 or more items of a specific type.

In Java arrays have the following syntax:

 
type[] variableName = new type[]; // the length of the array denotes the maximum number of elements you can store in the array.

Here’s an integer array that can hold 10 elements:

int[] myIntegerElements = new int[10]; // how many elements are inside of the array?

You can access elements inside of the array by indexing the array. Check out the two examples below. You’ll notice that you need to use brackets with the position number of the element you want to retrieve after the variable name. Keep in mind that arrays are zero based indexed so the first element is referenced by asking for the item indexed by zero.

int firstElem = myIntegerElements[0]; // what is the value stored in firstElem after this line executes?

What if I want the last element?

int lastElem = myIntegerElements[9]; // what is the value stored in lastElem after this line executes?

Also, arrays have instance variables that are pretty useful. For example, an array can tell you its length.

int arrayLength = someRandomArray.length; // assume someRandomArray is already declared and defined.

In what ways is an array’s length useful?

Say I wrote a function that accepts an integer array as an argument and it averages the numbers. What would that function look like?

public double AverageNumsInArray(int[] numArray){

	int sum = 0;
	for(int i = 0; i < numArray.length; i++){
		sum = sum + numArray[i];
	}
	return (sum/numArray.length);
}

What if I wanted a function that accepted an integer array and an integer called numToLookFor as arguments and it told me whether or not the integer numToLookFor existed inside of the array. What would that function look like?

public bool DoesIntegerExistInArray(int[] numArray, int numToLookFor){
    for(int i = 0; i < numArray.length; i++){
        if(numArray[i] == numToLookFor){
            return true;
        }
    }
    return false;
}

Introduction to Squared

I recently created Squared, a game that was submitted to the Windows Phone 8 store. It’s a pattern-matching game. You’re given 60 seconds to match the corners of a small square with the corners of a larger square, which resides in a grid of many squares. As you find solutions you earn points and time is added to the clock. If you’re fast the points you earn are multiplied and you have a better chance to earn a spot on the global leaderboard.

There are a handful of reasons I created this app:

  1. Since college, I’ve always wanted to create a novel game.
  2. Last summer I read Eric Ries’ book, “The Lean Startup” which discusses how to build a minimum viable product (MVP) that needs to be instrumented to understand how many and if users like a product. I’ve been meaning to build a product instrumented to measure user interest.
  3. I became one of the resident ‘big data’ analyzers in my professional job. I work on a service that logs every interaction between clients and the service. This allows the feature team and business to glean important business intelligence and service intelligence. Since I’ve been writing scripts to process swaths of data, I’ve been motivated to collect event-oriented data in the software I create in my spare time. I’ll discuss this more in another article.
  4. I was interested in learning more about the Windows Phone 8 SDK. I was an iOS developer for about 2 years and I spent 8 months working on Android.

Squared Business Model

I originally planned to give Squared away for free. It wouldn’t include ads and nor would it include in-app purchases. These are the reasons why:

  1. I only download free apps on my smartphone and I believe this is true for the majority of smartphone users. I’d like to get a high download count.
  2. I don’t like ads inside of apps. They’re useful for putting food on the table as an app developer but I think they look tacky. I’m fond of Squared so I’ll put ads in a different app.
  3. I’ve never used in-app purchases before. I’ve never purchased items within an app and I’ve never set up in-app purchases in my own apps.

In the middle of development decided to add in-app purchases to Squared for a couple of reasons:

  1. I believe I can provide a premium experience without users requiring users to pay me anything and I can enhance the experience for those that choose to buy in-app purchases.
  2. I spent a fair amount of time developing the app and as an experiment I’d like to see what sort of monetary ROI I can get. 🙂

Squared Telemetry

It’s crucial to instrument software with telemetry so a developer or business can understand how their software is used and how it behaves in the wild. Telemetry enables software shops to glean business intelligence and service intelligence. An example of business intelligence is the average amount of time users spend on any particular page, or in what order do users navigate to various pages. An example of service intelligence is the average load time of a page or how often unhandled exceptions are thrown.

The easiest way to approach telemetry instrumentation is to identify all of the unique events that can occur in software. In Squared users can press buttons, navigate between pages, find solutions in the game and purchase game packs. So, I log when buttons are pressed, when users navigate to new pages, etc… It’s important that software shops identify the questions they want to answer. Knowing what questions need to be answered provides insight on which events need to be logged.

Fortunately plenty of software already exists to collect telemetry. I use Google Analytics for Squared. Below is screenshot of data that I collected from Squared beta users, which shows how users navigated from page-to-page.

telemetryPageFlow