Programming has been on my to-learn list for a long time, amongst a million other things, so when ‘Introduction to Object Oriented Programming’ was down as one of the first modules on my Masters, I was pretty glad to be doing it.

For anyone who’s never done any programming before (like myself), object oriented programming basically refers to any programming language that creates ‘objects’ to refer to real-world things. For example, you might be building a football game and there might be players, a ball, a referee and so on. All of these things can be described in ‘classes’, where we define what they are and what they do. But a class in itself is really just a cookie cutter — it is the instructions for an object. Once we’ve created these instructions, we can then start creating instances of that class, the objects themselves. And all of these objects can interact with each other; the limits of this are only defined by what you can learn.

When you first start with programming, it’s daunting. There are a lot of websites and books out there that promise you’ll learn programming in a few hours, or even in a couple of weeks, but I can assure you they’re not going to work. Learning a programming language is like learning any other language; it takes years of practice before you’re fluent. I’ve been practising Java since September and so far I feel like I’ve got the basics of it. It’s like I could have a very simple conversation with a Java native* but there’s still so much to learn. That will only come with further practice. But if I could have a conversation with myself from 5 months ago, I’m sure the old me would be really impressed with what I’d learned.

For the main assignment on our module, we were asked to build a simple adventure game based on The World of Zuul — a classic learning exercise which I think might even date back to the 70s! It’s similar to many of the very early computer games; type in the commands to move around the map, collect items, interact with other characters and so on.

I decided to build a scenario in which the player is helping some space traveller collect parts to repair their ship.

The game in action

I had plans to build in characters and other actions, but as usual I was planning way beyond my own abilities. Instead the game simply revolved around collecting the right parts and returning to the ship. This still took some learning, but I was happy with what I managed to create.

From here we then developed the game further by adding a graphical user interface (GUI) using Java’s Swing library (a collection of pre-built classes that you can install into your application to expand it’s functionality). By this point I was still making very simple mistakes (particularly in the order of the code I wrote) but I had the general idea of what I was doing. I was thinking like a programmer.

The game now with the added GUI

The final product was very simple, not exactly beautiful, but it works. It’s not the best example of programming, but it made me aware of how much I’ve learned in what may seem like a long time, but is actually very short. Regardless of the module outcome, I’m happy with what I’ve achieved over 5 months. I have a hell of a lot more to learn, but I’ve managed to get a good start.

For anyone wanting to learn programming, I’d probably make these points:

  • Don’t get hung up on what language you choose. Java is good, JavaScript is good (but in no way related), Python is good, Swing is good, they’re all good. Maybe do some research into what you want to build and what different languages are used for. Ultimately though, if you’ve never learned programming before, it doesn’t matter.
  • That’s because your main focus should be understanding how programming languages work, not the specific syntax (grammar and spelling) of a language. Once you’ve got that, you’ll find it easy to switch from one language to another, should you need to. Learning the fundamentals of programming means learning best practices; high cohesion, low coupling, documentation, and concepts like classes, visibility, collections and iteration. Most of these concepts are relevant to any object oriented language.
  • Learn to think like a programmer. When you start to understand the basic principals of programming, you’ll start to think of problems with a programmer’s mind. What classes do I need to solve this problem? What methods will those classes need? What type of data am I dealing with? There are 2 types of errors in code; syntax (grammar and spelling) and logic (how the program works). The software you’re using to write code will usually alert you to syntax errors, but not logic errors. Only being able to think like a programmer can help with that.
  • Be patient. You won’t learn it overnight or in a few hours. You won’t even get the basics in that time. Codecademy and similar options are nice, but they really don’t teach you anything useful. Give it a year. Expect mistakes. Expect to spend an entire day screaming at your screen because your application doesn’t work, only to realise you’d put 2 lines of code in the wrong order. It will be a challenge, but you will feel rewarded when it starts to come together.
  • Pick a project. Pick a set of projects. Have something to work on. You can’t just learn to code, you need a way to apply it and practice. Create something simple like a game and have a clear idea of what you want to achieve. At the same time, don’t plan to build the next Google or Facebook. Aim low, achievable. Break it down into stages that you can manage in small blocks of time, otherwise you’ll end up overwhelmed and you’ll give up.
  • Find good resources. Throughout this module I’ve been learning from Objects First with Java by Barnes and Kolling. I cannot recommend this book enough for learning Java; it comes with exercises and breaks everything down into manageable chunks. But also remember there are limitless resources online, including Oracle’s own Java documentation.
  • Find good people. If you live in a reasonably large town or city, there will be coding groups and co-working spaces which can be great for meeting other programmers who can help you learn.

If you’ve been thinking of learning programming, then do it! It’s hard work and it’s tiring, but you’ll be surprised how quickly it comes together. There’s a reason programming jobs are so in demand!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.