Consuming a JSON REST API in Android

JSON REST API

This week’s blog post was requested by one of our readers, Jasmine.

Jasmine asked if I could write a guide on “processing JSON data for android applications using NodeJS and Express and Android Studio”.

I haven’t done anything using Android Studio in a while – and I love writing guides that you all want and need – so I thought I would give it a shot.

There are two parts to processing JSON data in Android using NodeJS and Express:

  1. Writing an app capable of processing the JSON data.
  2. Writing a backend capable of producing the JSON data to be processed.

Because there are two parts to this, naturally I’ve broken the steps down into two blog posts.

In the first guide – i.e. this one – l’ll walk you through step #1 and teach you how to create an Android app using Android Studio, which allows you to process JSON data from a REST API.

The next post will show you how to make a REST API using NodeJS and Express. (Check back next week, or better yet, sign up to my newsletter).

Read more

Five reasons to write proper commit messages

We have all been there and probably done it ourselves.

An app randomly breaks or crashes, so you type “git log” to see what has changed recently.

And BOOM!

The history reads like:

  • 18:15: More updates.
  • 18:02: Updates.
  • 17:40: Updates.
  • 16:34: Fixed.
  • 12:22: Done.
  • 08:23: Complete.

And usually it’s not even punctuated correctly…

I can understand why. I have been guilty of this myself many times before.

When you’re rushing to get something done and you don’t commit frequently, it’s hard to even remember what you changed and why you changed it!

However, as usual, making shortcuts like this in the short term can be detrimental to the long game.

Here are five reasons to be disciplined by committing often and writing proper commit messages every time:

1) You understand better what you are doing.

Writing a proper git message helps re-enforce in your mind what you are working on.

I’ve had many epiphanies as a result of describing what I changed in my commit messages.

It helps you to be focused, as you are repeatedly bringing your mind back to the task at hand with every commit message you write.

2) It helps to break big tasks down into smaller ones.

In my last post I wrote about the benefits of breaking down tasks.

If you make too many changes in one commit then you will not be able to describe what you changed in a short, concise commit message.

Making frequent commits with detailed messages helps you to practice breaking big tasks down into smaller, more manageable chunks.

In the long term you’ll find that you get far more done as you break down the monster tasks into small chunks and chip away at it. Plus, if you ever have to go back and fix something – in the event of a crash or something breaking – you can troubleshoot so much faster.

3) Others can better understand what you changed.

Coding isn’t a single player game.

If you want to build amazing things you need to work well in teams.

A big part of working well in a team is communication.

Nothing helps developers communicate more than writing clear and concise commit messages in your code.

It means others can easily understand what you did at a glance and gives them less reason to distract you from what you are working on over questions about your code.

4) You can better understand what you changed.

Writing decent commit messages isn’t just about others understanding what you’re doing.

It’s also for you to understand what you’re doing.

How many times have you looked back at an application you worked on years ago and you can’t even remember working on that project at all?

Putting in decent commit messages will certainly help jog your memory and will help you to understand what you changed and why.

5) It is good practice for discipline.

The secret to being a great programmer is discipline.

Anyone can knock up a quick web app nowadays…

But few have the discipline to follow best practices to make it scalable and efficient.

Writing good commit messages is good practice to be disciplined in other areas of programming.

It also demonstrates to others that you have good discipline and you take pride in your work.

Thanks for reading. I’d love to hear your thoughts and experiences in the comments below.

Cheers,
Mark

How to handle a colossal project

Towards the end of 2016, I decided to start making videos to share on Facebook and YouTube.

I blocked out some time in my calendar to make 3 videos a week.

Since I do freelance work during the week, it meant that I would have to do them in the evenings between dinner and bed.

I estimated that (in theory) I could quickly knock out a 20 minute video in 30 minutes between 9 and 9.30pm and be in bed early enough to get my full 8 hours.

In reality, most nights I would spend 2 hours getting frustrated and making multiple re-takes until I just gave up!

I ended up just doing videos when I had time on the weekend… Then eventually I gave up completely.

In 2017, I committed to releasing 3 full video courses. The first one will cover Python, from zero experience to beginner.

I knew that if I wanted to deliver on this goal, I needed to improve my process so I don’t do what I did at the end of last year. Which was basically overstretch myself and give up entirely.

Brooke and I sat down and brainstormed how we can improve our video production process together. The answer we came up with was to break the task down into smaller, manageable chunks.

Instead of aiming to do a full 20-30 minute video, I would just break it down into multiple 3-5 minute videos.

And I committed to doing on average one of these short videos a day.

During the week I would still have to do these videos at night, but if I aim to produce something short and concise, and I give myself a realistic time-frame to achieve this (one hour as opposed to two), then I should be able to meet my goal, and still meet my basic needs like a full 8-hour sleep and enough time before bed to read and wind down.

I also realised that I was spending almost 50% of my time setting up my environment (lights, position of camera, putting green screen up, taking it down, etc.). So we re-configured my “studio” so it’s set up along the back wall of our office. It’s now out of the way of our working space and because of this I can leave it up and not have to worry about adjusting it every time I need to film.

London App Developer

I also bought a new webcam so I no longer have to use my laptop AND monitor to film (which takes up double the space and makes the filming experience a bit disjointed). Between these adjustments I’ve saved 50% of time and can now meet my target of one video a day a lot easier.

I’m only a few days in but I’m already seeing the results I set out to achieve.

For every new project I embark on, I find there’s always a honeymoon phase – when you’re really pumped and excited to be working on something. It’s the weeks and months that follow that become challenging. But I feel as though I figured out a routine and a set-up that is reasonable and easy to action.

I’m sharing this goal here with you so I can be held accountable for it. If you have a partner, friend, flatmate or family member that can help hold you to your goals, I strongly recommend reaching out to them and asking them for support.

So far I’m averaging 2 videos a night (100% more than I thought I would do). Compared to last years 1 or 2 a week!

And most importantly, I am now ENJOYING making videos!

This experience has got me thinking about how important this lesson is when it comes to programming.

Many times I’ve faced daunting technical challenges. Sometimes it’s a personal project I want to get done. Other times it’s a colossal freelance project that feels like the more I work on it the more work is created.

But now I take comfort in knowing that the key is just to break it down into small, manageable chunks. It also helps to assess where the biggest pain points are. For me, it was the environment set-up. For you, it might be an onerous manual task that can be automated to save time.

So, whatever your challenge, no matter how big: Break it down and chip away at it.

Take the time at the start of the project to break it down into smaller tasks and use JIRA, Trello or whatever works for you to track the progress.

Then just chip away at it day by day, and you will be amazed at what you can achieve!

Thanks for reading and I hope this was helpful.

Cheers,
Mark