Thursday, June 20, 2013

Android static code analysis tools

If you think you know Java well, you are probably wrong. And even if you are a true pro, you certainly still make mistakes - yes even those silly ones. To make it more daunting, Android is not just plain old Java. It enforces the use of mechanisms that are not easy to understand at all: multithreading, generic types, memory management, and various design patterns. Do you still think you're good enough on your own? Watch the videos below (or at least skim them).



The guy in gray hair is Joshua Bloch - the former Chief Java Architect at Google (he quit in 2012 after 8 years there) and the author of  Java Collections framework. As you can probably guess, he's a pretty smart guy. He also has a good sense of humor, which isn't very common in the IT world. If you'd like to rake your brains some more, check out his book: Java Puzzlers: Traps, Pitfalls, and Corner Cases.

But back to the point. Knowing the syntax of a programming language is not the same as being a good programmer. I remember reading Effective Java (again by Joshua Bloch) and getting surprised every chapter at how little I knew about high quality code. I worship this book for showing me that I had (and most certainly still have) a lot to learn and that Java is much more complex than it appears to be at the first glance. After reading it three times back to back and getting a couple years of experience I feel much more comfortable now in the world of classes, variables, and methods. However, the conclusion you should be getting from this rant is that no matter how skilled or smart you are, you will always be creating bugs.

So, is there anything we, programmers, can do to prevent at least some of the mistakes we make? The answer is yes and we can achieve it using static code analysis.

For all those who are not familiar with this term, do you remember when Eclipse suggested that you get rid of a variable because you were not using it anywhere or when you used the assignment operator for comparison when you actually meant to write ==? That's, more or less, it, but there are much more powerful tools that can take it to the next level. Let's see what they are.

Lint

This tool is already there for you without the need to install anything. It has been introduced in ADT 16 and has been a part of your Eclipse ever since. What can it do? It works with Android specific functionality, checking such things as:
  • missing translations, e.g. when you have a text resource in one language but not in another
  • layout performance problems, e.g. when you nest views unnecessarily
  • unused resources, e.g. when you have images in your res folder that you never refer to
  • accessibility and internationalization problems, e.g. when you hardcode strings
  • icon problems, e.g. when you failed to provide icons for all screen densities or they have wrong sizes
  • manifest errors
Lint is always there for you, running in the background. However, it does not scan the whole project unless you tell it to by pressing the checkbox icon in the toolbar. Make sure you do it from time to time and don't just ignore the messages that appear in the Lint Warnings view. Each of them provides a lengthy explanation of what's wrong with your code and even if you still don't get it - ask Google.


It's one of my favourite tools. You can easily install an Eclipse plugin by going to the Eclipse Marketplace (Help/Eclipse Marketplace...). Then right click your project and choose Find Bugs/Find Bugs...

I guarantee that you'll be surprised at what you find. They scanned the latest Java JDK itself and discovered quite a lot of things that should have been done differently. If the Oracle's employees have been so sloppy, I wonder how your projects do...

Here's what bug patterns FindBugs looks for:
  • difficult language features
  • misunderstood API methods
  • misunderstood invariants when code is modified during maintenance
  • garden variety mistakes: typos, use of the wrong boolean operator
P.S. They use FindBugs regularly at Google to keep their code quality high.


Google CodePro Analytix

You can again get it from the Eclipse Marketplace. It provides similar functionality as FindBugs, but also:
  • finds duplicated code
  • generates JUnit test for you
  • computes code metrics
  • computes test code coverage
  • draws dependency analysis diagrams
I discovered CodePro quite recently and I must say it's very powerful and helps me a lot.


It used to be a tool checking if the code meets the specified coding standards. It has evolved since then and has become a very powerful ally in the battle with bugs. You must certainly get to know it, because it has been the industry constant for a good couple of years. Extremely easy to install through Eclipse Marketplace.


Yet another code analyzer. Very powerful, one of the best known by programmers and downloadable as an Eclipse plugin.






Other tools

If, for some reason, the tools mentioned above are not enough for you or you just want to experiment with more of them, make sure to take a look at the list of tools for static analysis at Wikipedia. It contains useful utilities for languages other that Java as well.


Use it!

I hope I don't have to repeat myself and tell you one more time that using static code analysis is a must. You don't have to install all of the tools mentioned, but choose at least one that you like and run it whenever you add some new functionality. Don't ignore the warnings! There will be false positives from time to time, but treat them with caution and look for a detailed description online whenever you don't quite understand what's wrong. I guarantee, that you'll find bugs you haven't event thought of and that you'll learn a lot by correcting them.


If you feel like sharing your experience, let me know what tools you like the most and what unexpected errors you were able to find. Don't be ashamed of your code. Remember that even smart people make dumb mistakes.



Sunday, June 9, 2013

Unity free for mobile indie developers

If you want to start making Android games, the guys from Unity just got you a huge present. They released their cross-platform engine for free. Well, at least if you're making less than $100,000 a year with your apps, which I suppose you do. Watch the announcement yourself or read it on the official blog.


If you haven't heard about Unity yet, you should check out the Wikipedia article about it and see some games created with this tool: Bad Piggies, Temple Run 2, Slender: The Arrival. Also, here's their official YouTube channel (go to the Made With Unity section for some amazing stuff) and Facebook profile with news, announcements, and deals.

Mike Kasprzak, an indie game developer whose blog I follow, wrote a nice article some time ago about modern middlewares, featuring Unity as one of the most interesting tools. After that, he continued his reasearch and described his experiences in another post. Apart from that, Mike is a really cool guy. I suggest checking out his game Smiles which got plenty of awards. I used to watch the indieconversation YouTube channel where he talks with other developers about... well basically all aspects of indie game development. It doesn't focus on Android, but it's fun to watch and gives you some insight into the lives of a bunch of geeky individuals.

For all those who want to learn Unity, here's a great forum thread which mentions probably all possible resources there are. Let me know if you create something cool... or even if you fail miserably. If you've already made a game with Unity and want to show off to others, feel free to comment and post a link to it.

Saturday, May 25, 2013

Five surprising facts about myself

In my hello world post I said that I was just another Android hobby programmer out there. Well, that may not be entirely true. Perhaps I'm still far from being a genious coder, but there are definitely things that make me unique, as there certainly are for you. Sometimes I feel like there are so many people smarter and better than me that my success seems extremely unlikely. That's why I decided to make the following list and perhaps make you realize what makes you one of a kind as well.

Fact 1

I don't own an Android device. It's not a spelling mistake. I've actually created all my apps using only the emulator, my brother's tablet which he would lend me for testing purposes and later also my girlfriend's phone. I'm not very proud of it. In fact I recommend you test what you write on as many different physical devices as you can. What I'm trying to say is that you don't need much to start your Android adventure and make your first app. Perhaps your excuse for not trying out a good idea is quite different, but keep in mind that most obstacles can usually be overcome this way or another and it's all in your head whether you take action or keep dreaming.

Fact 2

My apps got me a full time job as an Android developer. It wasn't and still isn't my main goal, but it definitely boosted my self esteem. In fact, I must have beaten some people during the interview process and my apps must have proved good enough to actually get me hired. The job itself might not be perfect, but I'm definitely learning a lot this way. I virtually doubled my Android knowledge during those two months and there's still much studying ahead of me. Also, did I mention that I work from home and that my salary doubled compared to my previous job? Pretty nice, isn't it? I'm intentionally omitting some not so positive stuff here, like the amount of time that I had to work at first or my boss's not so friendly character. Nonetheless, I'm happy to be able to have this experience and to show you that being a hobby Android developer may have other advantages than just earning money on apps.

Fact 3

I'm Polish, but I've been living in Milan (Italy) since January. It's been quite a change for me to move to another country, learn the language, and deal with everyday situations. I can't say I feel at home now, but it definitely gets easier after some time when you learn your way around and get to know a couple of people. Anyway, after staying for four months in a friend's apartment (she left for Peru to finish up her thesis), I finally have my own place. Although it's not very big, it's quite cosy and I have to say that I quite like it. Now I'm waiting for my first paycheck to buy some crucial stuff and make it less shabby. Hopefully, it will come soon. As to my future plans, I'm not sure if I'm going to stay here long. The city is extremely expensive to live in and there isn't much it can give back in return. I might go back to Poland after some time, but there's still so much world to see, that I'm tempted to take another detour. Where do you think I should go?

Fact 4

Recently I stopped to think about all the various stuff that I had a chance to do in my life and I was amazed at how diverse it was. Let's start from the beginning. During my university I was and intern making Java SE and Symbian GPS navigation software. Then I got a full time job as a C++ programmer, writing stuff for large retail stores, so that they didn't get lost in what they sold, to whom and for how much. Occasionally, I had a chance to use Python for internal scripts and even ASP.NET for an online store prototype. After that I switched to Java EE, JSF and some web centered technologies. Suddenly HTML, CSS, JavaScript and related things became my everyday life. In the meantime, I did a couple of small projects in Python for a friend's company, not to get too rusty. I also started learning Android because my work seemed more and more boring. Eventually, I decided to quit and try some freelancing. I was hoping I could make my Android apps get me at least a minimum amount of money to be able to survive. A friend asked me to help him with an online store in PHP and I thought it was a good idea. Well, neither of my hopes really worked out. I did some short term PHP projects, I built a website for my friend who is an architect, I learned some more Android and released a couple new apps, until I ended up where I am now. Pretty crazy, isn't it?

Fact 5

I have a ton of random skills and I've done a handful unusual things. I can juggle pretty well, and I'm not just saying that I can do the basic shower - I can do the inverse one as well as Mills mess, Rubenstein's revenge and some other not so basic tricks. I slackline, although I'm not one of those guys who do backflips and handstands while they are on the line. I'm not a bad swimmer. In fact, I used to work as a swimming instructor at a camp in New York. I also did some lifeguarding. I know the basics of POI and I hope that I can learn to be better at it when I find a bit of free time. I enjoy sailing and windsurfing whenever I have a chance to do it. I'm a huge frisbee fan and I was a member of the local ultimate team for some time. I love photography and I take my camera with me whenever I travel or something interesting happens. At some point in my life I had a job in gokarts, gardening, giving private lessons (mostly math and physics), being a camp counsellor, a construction site worker, and a computer technician. I honestly hope that I can at least double this list in the next ten years. What I hate is routine and doing the same things over and over again.


Surprised? I hope at least a little. Have you done anything interesting lately?

Friday, May 3, 2013

5 reasons why you should sign up for Coursera


Coursera is an education company that partners with the top universities and organizations in the world to offer courses online for anyone to take, for free. I did 5 of them in the past (Artificial Intelligence, Model Thinking, Game Theory, Algorithms and Cryptography) and I'm doing another two right now (Gamification and Interactive Programming in Python). If you don't know it yet, go give it a try. I promise you will love it. And here's why:

1. It's free

It's crazy, but you really don't have to pay for it. You can sign up and follow any course you want. They do have a paid "Signature Track", but it's totally optional. It gives you an official certificate when you finish a course, if you're interested.

2. 300+ courses to choose

There's no way you don't find anything interesting there. There's over 20 categories ranging from computer science, through mathematics, statistics, economy and finance, to more humanistic subjects such as art, social sciences, or education.

3. Top universities and professors

Have you ever dreamed of studying at Stanford, Princeton, Rice or Duke? Now it's possible. All the greatest minds and teaching talents are there for you. Now you have no excuses that the classes are boring. They are far from it.

4. Great content quality

The courses use video lectures, online quizzes, peer reviewed written assignments and other online tools created for the sole purpose of teaching you particular skills. Believe me, the overall quality is great. You have deadlines concerning watching the lessons and completing online excercises, but otherwise you're free to choose your own study place and time.

5. 3.2 million users can't be wrong

It's not a spelling mistake. More people have signed up for Coursera classes so far then the whole population of Rome. Do you think they had a reason for this? Of course they did! It's a great oportunity to get additional knowledge in subjects that have always interested you - no matter what they are. Even if you don't speak English very well, there are subtitles in Spanish, French, Italian, and Chinese. The courses don't usually require much prior knowledge, so you can begin with a basic acquaintance with the subject. If you are still unwilling to spend your free time on spontaneous education, remember that you can get a certificate and brag about it in your CV (that's what I did and it really interested most of my interviewers).


To get a closer look at Coursera, you can watch this short video:


If you still need convincing, listen to Daphne Koller, one of the founders, as she expains the idea in more detail:




Ready to sign up? Go to Coursera and let me know if I was right.


P.S. I'm not a Coursera affiliate nor have any business connection with it. I honestly think it's a great education platform and if I sounded a little overexcited it's only because I believe everyone can benefit a great deal from it.

Saturday, April 27, 2013

LeadBolt Experiment


Inspired by an article about various ad types offered by LeadBolt, I decided to give it a shot myself. Although I like AdMob - its ease of use and reliability, it definitely doesn't give you much choice over advertising methods. Displaying a small static banner nowadays is like having a commercial on TV showing an image along with some promotional pitch. Would you get interested by it? Probably not. Why limit yourself to just banners then when there's a whole world of possibilities out there? What are they - you may ask. Well, keep reading and you'll find out.

Interstitials

They are full screen overlays appearing on top of your app. They come in various themes (the one on the left is called Music), so you can make them blend in with your content much better and provide a seamless experience for the user.

Banners

You probably know them best. They come in various sizes, so if someone is using a tablet or another device with a large screen, you can make use of it. Your opitions are: 320x50, 468x60, 300x250, 640x100, 728x90. If you only want to improve your AdMob functionality without changing too much - that's something for you.

Alerts

You can see and example one on the left. They usually ask if you want to download a free app. It's much more tempting than just a banner in the bottom. Especially because it takes your attention and requires an action to close it. Anyway, why wouldn't you try a free game if you're probably playing something similar right now?

Audio Adds

"You just found a secret passage. Shake your phone to unlock your prize." Wouldn't you shake your phone after hearing this, even if it was just out of mere curiosity?

App Walls

Give you an opportunity to download games and apps. They come in two versions: dark and light. Again, very engaging and definitely appealing to the user.

Notifications

Do you want the user to be notified about new opportunities and promotions repeatedly at intervals controlled by you? It works even if your app is not open.

Icons

Install an icon on the device's main screen, opening an app wall which offers free games and programs. The user doesn't have to open your app.

Other overlays

There's much more LeadBolt has to offer: entry and exit overlays, rich media, text ads and other types of ads. If the only network you're using is AdMob then you should definitely check it out as an alternative. I think you know why now.








Ad Showcase


If you're interested in seeing all kinds of ads in action, you can download my free app Ad Showcase. It lets you see what you can achieve with LeadBolt. I wrote it because I wanted to learn how to use the API, but later I decided to release it on Google Play to let others experiment with it as well and perhaps decide what advertising techniques they want to use themselves. I hope you'll enjoy it.


Reviews and opinions

If you're interested in more reading about LeadBolt, its advantages and drawbacks, I recommend the following sites:

Try it yourself

If you now feel like LeadBolt is worth checking out, you can use my reference link to sign up for free or just click the image on the left. I will definitely try to use some of the ad types described above in my existing apps, because I believe there's a great potential in them and they might work much better than simple AdMob banners. If you already have some experience with LeadBolt, please share it with me and other readers, so we avoid common mistakes and make the best out of it. I promise to describe my results as soon as they appear, so you can learn from them as well.

Take care, create great apps and have fun in the process. Until next time.

Monday, April 15, 2013

FC Barcelona Live Wallpaper shutting down because of copyrights

About a week ago I got an interesting email that you can read below. What it said can be basically put in short like that: dear Sir/Madam, blah, blah, we represent FC Barcelona football club, blah, blah, you're using our logo and colors, blah, blah, they are registered as trade marks, blah, blah, we're kindly asking you to unpublish your app, blah, blah, unless you want us to be more persuasive.

Asking them nicely for permission didn't help. Apparently there was an FCB Apps Program a while ago that let developers introduce their app proposals to be accepted. Unfortunately it's over now and there's no information regarding the next edition. That's why I'm going to get the app out of Google Play really soon. If you were considering whether to buy it or not, you'd better hurry up.

The whole story definitely taught me a lesson. At the time of writing the app I didn't even think of copyrights and trade marks. Anyway I would have never expected that a live wallpaper with 12 installs could get me in touch with a football club that I really like. I'm not sure what I'm going to do with it yet. I might even make the source code public, so you can learn from it if you like. Let me know if you're interested.

Here's the full email that I got, if you have problems sleeping:

Dear Sir/Madam,
We are contacting you on behalf of our client FUTBOL CLUB BARCELONA.

FUTBOL CLUB BARCELONA is the exclusive and legitimate owner of the well-known trademarks “Futbol Club Barcelona”, “FCB”, “FCBarcelona” and “Barça” (among others), registered as international trademarks, such as FCBARCELONA (Id. Number: 1051714), FCBARCELONA (Id. Number: 864540), FCBARCELONA, (Id. Number: 907675), FUTBOL CLUB BARCELONA (Id. Number: 516357) FUTBOL CLUB BARCELONA (Id. Number: 731062) BARÇA (Id. Number: 1081332) BARÇA (Id. Number: 516357), F.C.B (Id. Number: 633377), F.C.B (Id. Number: 717965), FCB (Id. Number: 864541), FCB (Id. Number: 907670).

These trademarks also protect FUTBOL CLUB BARCELONA’S shield, as a logotype, and the Football Team’s official colours.

We have been aware that you are the developer of the following Application:

Código de Contenido: 022-002-00146
Url del Contenido: https://play.google.com/store/apps/details?id=pl.bartoszwesolowski.fcbarcelonalogolwp&feature=search_result
Vulneraciones: Copyright and trademark FC Barcelona
Número de vulneraciones: 1
Detalles vulneraciones
- app: FC Barcelona Logo LWP
Dominio Base: htttp://www.redpoints.es
Administrador del Site: ---
Persona Jurídica: ---
Hosting: --


This Application infringes our client’s exclusive rights, in particular, its copyrights, trademarks, logotypes and image rights.

The Application is using signs which are identical or similar to F.C. Barcelona’s trademarks, taking unfair advantage of the Club’s reputation. This constitutes an infringement of our client’s trademark rights.

Additionally, the distribution of an application entirely based on F.C. Barcelona, without the Club’s authorization, constitutes an act of unfair competition.

Therefore, we kindly ask you, upon reception of this notice, to immediately:
  1. Withdraw the abovementioned Application from the distribution platform where it is being offered to the public.
  2. Delete from your systems the Application and any and all materials violating our client’s copyrights, trademarks and image rights.
  3. Stop and refrain in the future from using and/or reproducing materials (images, trademarks, videos, logotypes, etc.) that infringe FUTBOL CLUB BARCELONA’S exclusive rights.

We believe in good faith that the abovementioned Application has not been authorized by our client, its agent or the law.

We declare under penalty of perjury that all the information contained in this notice is accurate, and that we are authorized to act on the behalf of FUTBOL CLUB BARCELONA.

We remain at your disposal in case you would like to contact FUTBOL CLUB BARCELONA for an official license for your product.

Sincerely,
Josep Coll
RED POINTS SOLUTIONS TEAM

Sunday, April 7, 2013

Lifestyle design

Recently, I've become extremely interested in the subject of lifestyle design. It basically means taking conscious decisions about your life instead of letting the society influence it and forcing you into paths you do not want to take. It gives you more awareness and control over the things you do and lets you choose the ones that you value more in favour of those less necessary or perhaps totally inessential.

It always strikes me how many people are unhappy with the things they do, but are unable to get out of the situation, even if it requires only one simple action. They complain about their jobs, lack of time, being overweight, having no friends, feeling tired, but they never actually ask themselves what they can do to improve it and so never even take the first step. Sometimes it's very difficult to look at your life from the outside and judge it objectively as if it was someone else, not us, and we were trying to give that someone a piece of advice. That's why it's extremely helpful to see how other people overcome their weeknesses and alter their lifestyles according to their own design.

No one can tell you what you should or shouldn't do, but they can help you find the right questions to ask yourself and give you some tips on how to follow the right priorities. If you hate your job, maybe you should quit? If you still need money for your everyday life, then you could earn it in a different way or cut the expenses drastically? Do you really need a car, a big house or a TV set? Do you feel like you should take care of your health more? Why not get out right now and go for a jog? You can never find the right motivation? Ask someone to run with you, make a training plan and give yourself some rewards. You can't find the time for a hobby or something you love to do? Perhaps you spend too much of it doing other things that are not so important at the moment - watching TV, checking facebook, watching youtube videos or going out with your friends a few times a week. I know this is an oversimplification, but are you sure your choices are really your own and not something that simply has to be done or something that most people do?

Here's a video by Scott Dinsmore from Live Your Legend giving a speech at a TED conference. I found it really inspiring and I hope you will too.



If you want to read some more about lifestyle design, you should also check out the following:

What is Lifestyle Desing? on ThinkTraffic.net - describing in more detail what lifestyle desing is; you can check out the site itself, if you're interested in creating and marketing websites, podcasts and ebooks

The Blog of Tim Ferris - the author of "The 4-hour Workweek" bestseller, entrepreneur, speaker of 5 languages, Chinese kickboxing champion and a horseback archer giving out advice on how to be successful in life

The Art of Non-Conformity by Chris Guillebeau - a medical volunteer in Africa, traveller (more than 150 countries) and entrepreneur being self employed for his whole life writing about "unconventional people doing remarkable things"

zenhabits.net - a guide to being happy be owning less and living in accordance with the Zen philosophy

The Minimalist - once more about getting rid of unncessary things in life, because "stuff ties us down"

The Smart Passive Income Blog - where Pat Flynn tells his story from a full time architect to an extremely successful online entrepreneur earnign about $50,000 a month on affiliate programs, ebooks, iPhone applications and websites; just listen to his podcasts and you will fall in love with them and the author himself