The beauty of indexes

I think every decent developer know what indexes on databases are and what is the good and bad in using them. I wouldn’t discuss that now but I would give you some numbers that I’ve stumbled upon this morning:

On a 50 000 entries table, querying for an entry without the right index took, on average, 200ms. Adding the correct index (“correct” is for another discussion because bad indexes can screw up other parts of the app) the queries have gone down to: 10ms.

So if you are careful about the indexes you use (or should use but don’t), you can gain up to a 20x performance  boost.

Meet the trainers – Hangout

I think I’ve missed the opportunity to tell you that I am going to teach a dozen non-technical (but talented) persons Android and Software development. Oh no, I didn’t.

Well, as I said, I am going to be the trainer of the next Mobile development Bootcamp that Simplon Romania is organising in Cluj-Napoca. There are still 5 days left to register if you feel that you would like to do it. But think carefully as it is a paid bootcamp and it will be very very intensive.

There are many things I have to do as a trainer and one of them is to answer questions that come from the people that register. I would have replied to mails but got none. And I think it is better this way, so we can have a nice discussion via Hangouts and not repeat the same Q&As over and over again. So Friday at 19:00 (Romania) we are going to gather here and brainstorm the plans for the bootcamp, the things we are going to teach, the project we’ll create and anything else that comes up.

Please join me and help me make this experience better for everyone. Spoiler alert: I might be frighten by the realisation that this is happening.

Why am I not a Web Developer

The main reason why I run away from web development is that I cannot understand the HTML + CSS combination. And it’s not like I haven’t stumbled upon it several times but I always had a hell of an experience.

For example, today I’ve set up a very cool header image for the blog (an image of myself, of course). I’ve tried to make it look cool by adding some .avatar {} class in the CSS, that I’ve found on the web. It makes the image round and cool, just like it is all over the internet. I wanted to be trendy and look like Google Plus avatars.I wanted to put it on the same line as the title and subtitle of the blog. Could not care less if it is on the left or on the right…

But I could not manage to make the div that contains the title and subtitle center vertically. I’ve tried a million ways to do it, everything I’ve found on stack overflow and some of the most obscure blogs on the Internet. Nothing worked. So excuse me if I put it this way but f*ck CSS for now.

No picture for you! F*ck HTML and f*ck JavaScript in particular. I’ll take a course on it ASAP.


PS: This should be the header image…


… but rounded.


When tools get in your way

Jenkins was the first Continuous integration server software that I’ve used. We had it at the first company I’ve worked for and it was doing a decent job. The builds were delivered in time for software testers to test and releases were delivered almost flawless. At least that was my impression because I was not very involved in it because I had my bugs to squash.

Over time, Jenkins became very popular around (somehow we got stuck in Romania with it and refuse almost any other CI software/service) and I’ve worked a lot with the Moustache guy. It started to become a real pain in the ass when I started creating jobs for Android projects. Somehow Jenkins managed to screw it big time whenever something important happened.Jenkins CI

Release time? Let me just fuck up this build in particular!

New SDK? Let me just throw a random error and kill myself because fuck you and your pretty robot android.

And this kind of problems continued to occur and get even worse when it was time to run tests. Somehow, I’ve always managed to negotiate with Jenkins a way that was convenient for both of us. In the end, we were always friends.

But this time he did it! The project that he messed with is a little more complex than the others. It has sub-projects that need to be built in a particular order, different branches, files to move around and pack an installer in the end. I must say, that I can’t describe the confusion generated by this project as sub-projects need to be built in the same workspace, otherwise some DLLs get lost and the installer is inconsistent.

But we had a system. We’ve managed to set-up Jenkins so it would do the entire flow. Thursday, the Moustache got upset and nothing was working anymore. I’ve merged a branch that we’ve been working on for some time now and the build was screwed.

The fun part was that local builds were working. We could build “unofficially” on our computers but Jenkins couldn’t. It was not official enough for a release. We had to fix this and we did. But it took us 2 full days to fix the CI Server.

This is when it hit me: if I have to waste so much time, randomly (when I need it most), is it worth to continue with this tool? Shouldn’t I search for another tool that will do the job better? Any suggestions?

The next steps for me

As I’ve said in my last post, I’m going to learn some stuff this year. For this month I’m planning to finish the following courses, on Udacity:

UIKit Fundamentals

Intro to Computer Science

I know it says that is a beginner course to start with CS but it’s made with Python and it is really nice. I already know how to solve CS problems and those that are in the course are not that hard. This lets me focus on the Python syntax. It is a little bit confusing that in the tutorials it is used the version 2+ of Python and I’m using PyCharm with Python 3+ but the differences are not that big. I can manage it.

It is just like learning iOS with Swift: you always find StackOverflow questions that are answered in ObjC and you just have to deal with it.

Any recommendations for next month?

Learning Python in 2016

Last year I’ve started looking into the new language Apple coordinates and uses: Swift. I can’t say that I now know well it enough but I’ve seen it’s power and I appreciate the clever stuff. I know how to read Swift code and understand the good and the bad in that language (at least in the current version). I love that they’ve open-sourced it!

I’ve also seen and written some C# code, even though I don’t have any plans in that direction. Hell, I’ve even written a little JavaScript, just because it intersected with my Android project. A little bit of everything because I don’t mind getting my hands dirty.

Now, for 2016, I’m planning to improve my knowledge in all the languages I’ve mentioned but I also want to learn Python. I feel like I’m missing a lot of good stuff because I don’t know Python (and Ruby, for that matter). Everybody talks about it, there are meet-ups with Python developers, lots of jobs for them, StackOverflow is full of it, the world loves it. And even Tiobe marks it as a rising language, again. I can’t be out of it. I need to learn it.

Tiobe index January 2016

The problem is I cannot figure out why is it so popular. I never seen it used in production code. I think it is used in internal tools more than anything, more of devops stuff, but I’m in the dark when it comes to the real value of Python. I feel like there is something about it that I don’t know: some kind of secret use that I’ve missed.

But never mind that, because I’ve seen some really cool Machine Learning libraries that use Python and I’m really excited about using them. So I’ll learn Python even if I cannot use it in my everyday work, just to have a little AI fun.

Ruby and Python uses

One thing I can recommend to any developer is to never stop exploring new languages, libraries and frameworks. It might be that there is something out there that can make your life way easier,  you just have to find it. Don’t settle for what you know! HR and managers will tell you to specialise but don’t forget it is in their best interest to do it, not yours. Develop yourself continuously! In the end, you will bring a lot of value to your work but you need to learn like crazy. There’s now other way in this ever-changing industry. Just learning. Daily.

Starting an Open Source project

Starting a project that you don’t have to is harder than I thought. People always show enthusiasm for something new but when it comes to working for free the story rapidly changes. The project would solve some local community problems by connecting clients to contractors. Anyway, a great platform to be created.

I have a group of developers, I have a designer and the full management support. But how could I move things faster? People say they want to do it but they just don’t. The power of example doesn’t work either: I started working myself a little hoping that others will join but didn’t. Now I’m working on the visuals, trying to show them the platform project in wireframes so they’ll get more engaged.

Any other ideas? Do you want to join !? Mail me.

My first sell

There’s an elephant in the room when it comes to apps and the App Stores: nobody will buy your app! It’s like we are all ignoring this one little important thing: without marketing, the chances that you will ever sell anything are tiny tiny tiny. I actually tried it and I will do it some more.

I post small apps on both the stores with 1$ selling fee. It’s such a small fee that most of the population that owns a mobile phone can pay without feeling any remorse. Some of the users also know that they can get a refund if you don’t like the app in a certain timeframe (1h? Idk). So why not buy? Can the App be so bad? Maybe.

On the Android store, I’ve posted Color Discovery, the app that does nothing but generate random colors that you can save, share or use as wallpaper. It doesn’t do much but it does something so why not pay? Well, nobody did. Actually, now that the app is free and improved. it has 6 users and I think 3 installs are on my devices. So let me just think twice before publishing again.

On Apple’s Store, on the other hand, it took me a month to make my first sell. But I did! I sold my first copy of an App. It’s the Stock selling price calculator that did the sell and I can’t tell you how happy I am! My first 70c from App development. My first cents on my own because I earn my living doing the same stuff for someone else. And now I’m hyped and working on v2 of the App, hoping it will generate some more revenue. Isn’t that great!? The hundred dollar developer membership totally worth it. Not as an investment but the joy that it gave me! Thank you dear American that bought my App, you will receive a great update soon!


When AsyncTask is slower than running on the UI thread

I was working on a project that was loading different lists in a ViewPager when I’ve stumbled upon this fun fact: running a query on the database was faster on the UI thread than running it in an AsyncTask. Wait, what? Let’s debug this!

So in the initial version, the query was run on the UI thread (main) and it was kind of fast. But, as expected, the UI had to suffer and it was glitchy. I wanted to fix this and the first solution that came to my mind was to just embed the database work in an AsyncTask. Every list had its own AsyncTask to load the list. After I did that, the UI was running smooth but the data from the db was loading very slow. I had seconds of seeing an empty list in front of my eyes. I could scroll the ViewPager left and right with no problem but the data was loading so damn slow.

So I did an old-school profiling with System.currentTimeInMIllis(). The preExecute was almost 0, the postExecute was the same and the background work took some 300 ms. Not much for that kind of database query. But the loading took more than 2 seconds. Where is the time lost?!

I forgot one little thing about AsyncTask: the default executor for any AsyncTask is the SERIAL_EXECUTOR. This means that all the tasks were run serially on the same background thread. Randomly, the task that was loading the data for my foreground list was the last in a long queue of tasks that were preloading the other lists. So I ended up having to wait for invisible lists to load. The fix was quick and fun: I just set my AsyncTasks to run on the AsyncTask.THREAD_POOL_EXECUTOR and everything went smooth.


So, don’t forget that AsyncTask does NOT spawn a new thread for each execution. Be aware that if you need it to start fast, you need to specify an executor to do it. You can use the thread pool already implemented or use a custom executor for your task.

That could have saved me some time, hope it does for you.

Teaching people Android

Once upon a time there was TEDex Eroilor in Cluj Napoca and I have met there Simplon Romania’s CEO, Roxana Rugina. We’ve been talking since about creating a bootcamp on Android Development. We actually had a date in mind that is coming really fast towards me. Since I will be the trainer, I have to create lesson plans, think about homework and lots of other technical stuff. But I have stumbled upon a problem here.

I know a lot about Android and I can’t think of anything that would get me in trouble there (except the fact that Android sucks usually). I can teach other programmers how the Android ecosystem works. I can help others learn new skills in Java, work with Android Studio and Google APIs… but this time is different. This training will have two particularities:

  1. I’ll teach less technical people
  2. It has to be structured

The two come hand in hand. It’s not that those who will participate will be absolutely non-technical persons but they will be rather new to Android and programming in general. It’s a bootcamp for the ones that need a second chance in their career. They need to learn a lot in a short time so that they could get a job in IT. It’s a thing here in Romania: having a job in IT has proven to be beneficial.

So because they have to learn a lot and they are new, the training has to be really well structured. It’s not like you could skip steps and hope people will adapt. They can’t adapt because they are real beginners. So now I’m trying to go into as much detail as I can with my lessons but it’s so hard. I cannot get things right. I always find something that should have been taught earlier. It’s like I would need to teach everything in lesson 1.

I really got stuck at week 10 out of 12. I’ve planned everything by then and can’t find anything new for those 3 weeks. Should I maybe let them for practice and project refinement?