Thursday, January 21, 2016

About good practices and mistakes

As I'm not new to software development in general, I have certain personal preferences already. For example, I think it's very important to follow what are known as good practices in whichever language I'm writing on. And that is kind of hard to know at first, when you are learning, and it just intensifies if you're learning alone as I'm doing now with Android.

This is because one of the most important (and often underrated) uses of code review, in my opinion, is the transmission of best practices knowledge. With experience, you learn to write better and cleaner code. You learn to tackle common problems with tried and true strategies, but that takes time, coding, failing and corrections.


What did I try to alleviate this issue?


First, I asked around. I reached out to my good friend +Santiago Alvarez who is a professional Android Developer to ask him to take a quick look at my code and poor styling. He gave me a few suggestions and recommended me some good reads. What a great guy.

Second, I used Google, of course!


What to search for?


That's almost always the question. Google knows a lot and will tell you about it, if you ask the right questions.

Do you know what do mistakes and solutions have alike? Chances are you're not the first one to find out about them.

I searched for mistakes most beginners do. This allows me to learn about them, and avoid repetition, possibly annoying a more experienced developer who happens to come across my code in the future (that could even be my future self!).


I was glad I found some "Top 5~10 mistakes" lists. Some entries were similar through the lists, some of them were unique. I think I've learned around 11 or 12 common mistakes. Some of them a bit obvious (write clean, modular code, etc.), some others I did not even have a clue they were problems yet! (don't grab the UI thread, be careful with the weight attribute in a LinearLayout that has to be calculated all the time, even when overwritten, be careful with the LinearLayout nesting instead of using GridLayout when making big grids, etc.). That felt really good, because it felt as if I've "saved time" or "made progress" already. Hope that's rewarded in the future.

And what about good practices?


Well, that's another thing I asked my friend Santi about when I saw that my first pieces of code in the Android world were crappy, to say the least. Everything welded together, little to no modular things, etc. The answer was what I expected it to be: it depends. It depends on who you're working for, who teaches you, who reviews your code. There are almost as many standards as there are developers, but that's not an Android exclusive, so I already knew that.

He recommended me to check out the MVP approach on Android, at least to start somewhere. From there I can continue my way and see where I find myself more comfortable.

I'm still very new at this and have a lot to learn. I'm now focusing on Java core details that I vaguely remembered (or didn't even know), and how to make a UI that does not suck a lot, given that I'm no designer (actually, I'm far from it). I found out that the official Material Design guidelines are quite complete (a very long read), but I think it's better to invest that time now than having to redo entire applications.

No comments:

Post a Comment