Memory management in mobile apps

Throughout it’s lifetime, an application is allowed to make use of the internal memory, as object instances obtain parts of it for temporary use and then return it. When an objects doesn’t use the memory anymore but refuses to let it go, a memory leak is created.

Common causes of memory leaks

Soon a leak can turn into a flood, as the memory occupation is small, but constant and the gradual loss of memory will make the application unresponsive.

There are a few common causes for which memory leaks happen. Continue reading

Unit testing caveats

There is much controversy regarding test driven development. People do not seem to settle on the time trade-off, the London vs. State school, TDD vs BDD and the list could go on. But before diving into all of these, my first reports from the tranches of unit testing are as follows.

Behavior depending on date and time conditions

Tests should be runnable at any hour. Even if we leave the office at 6PM and everything seems to work properly, having loose DateTime variables in the tests could mean that they will fail during the automatic build that is run every night.

For example, we might want to ensure that our newsletter goes out only on Mondays. In this case, using an ICommand would make sense, because we can verify that our condition has been met before executing the action. A Command accepts a CanExecute Action that could like this one:

Func<Email, bool> canSendEmail = (email) =>
{
    if (email.DateToBeSent.DayOfWeek == DayOfWeek.Monday)
        return true;
    return false;
};

Continue reading

Zen Monday: Case sensitivity

iOS Case Sensitivity

Working with WebViews in Xamarin.Android

Showing a webpage inside a Xamarin.Android app can be done using a WebView. Here are some tips.

Using Directives

Pop science says that more choices don’t bring more happiness. Well, yeah. Turns out you have two options for creating an URL. This was half of my problem.

Screenshot 2014-01-23 00.02.11

Continue reading

An easier way of writing conditional code

I love attending code retreats. It’s an extremely efficient way to learn new things, though the people you pair with and the exercises you practice. And since keeping up with the newest thing is essential to a programmer, what better way to expand your knowledge is there than to let your creativity loose writing code in a different manner than the one you do every day?

What is a code kata?

A code kata is an exercise in programming which helps hone your skills through practice and repetition. Usually at code retreats, you pair with a different partner for each kata and you try to solve them by applying different pair programming techniques. Definitely my favorite kata so far is “Use no conditional blocks in your code”.

Continue reading

Setting the active configuration in Xamarin Studio

Building cross-platform applications in Xamarin Studio, you often need to be working on one single platform at a given moment.

Since Xamarin Studio allows having both iOS and Android projects under the same solution, when building or deploying, they all get compiled. This is not very efficient, since you only want to deploy one platform at a time, either iOS or Android.

The solution configuration specifies how projects in that solution are to be built and deployed. A solution can have multiple configuration mappings specified (build configuration, release configuration etc), each containing a combination of a configuration and a platform.

Continue reading