Category Archives for Programming

15 Killer JavaScript Methods You Should Know thumbnail

15 KILLER JavaScript Methods You Should Know!

Shares

JavaScript has some great built-in methods that can make your life 10 times easier! So let’s take a moment to explore my TOP 15 KILLER JavaScript methods. Let’s start this list with my favorite 3 array methods, .filter(), .map() and .reduce()…

1) .filter()

.filter() takes an array, loops through it and returns a new “filtered” array from all the elements that passed a true or false test specified in a function.

How does it work?

You start by calling .filter() on your array and passing a function as an argument. This is the functions that will run a true or false test.

The function you pass has access to 3 arguments provided by .filter(). They are the element, index an array. The only one you actually need is element.

For .filter to work you NEED to provide a variable name in the parameters of your function to represent the element.

The other arguments are optional.

Next, your function takes the element passed and performs a true or false test. If the test returns true, the element is added to a new array, if not, it’s filtered out.

Make sure you return the result of your true or false test, because again, if you don’t .filter() won’t work!

It is worth noting that .filter() does NOT change the original array, instead, it returns a NEW array.

So where can it be used?

Obviously, anywhere you need the ability to filter data, this method is a no-brainer! But it’s also great for adding some searching functionality to your projects.

Example:

2) .map()

.map() works in a similar way to .filter(). It takes an array, loops through, and evokes a function on each element, then return the result in a new array.

How does it work?

First, throw .map() on the end of an array, then pass a function into its parameters.

Like.filter(), the function you pass has access to the same 3 arguments, element, index, array. But again, you only need element! So make sure you add a variable representing the element in the parameters of your function.

Now you have access to the element in your function you can do cool stuff!

If you want, you could take that element and transform it in some way.

For example, concatenating something else onto each element, perform a calculation, or grab the property values from the elements and return that in a new array.

So where can it be used?

It all comes down to the function you define, but it has a ton of use cases.

If you have an array of objects, you could tell the function to extract the values of a particular property i.e. person.age. That would give you a list of ages. Or you could change all the text in an array to uppercase.

Personally, I find the method really useful when working with React. It enables me to take data from an array, pass it into a component, then return an array of components with the updated data. Lifesaver!

In case my explanation wasn’t quite up to scratch, I recommend checking out this post, written by a buddy of mine, Tom Rasmussen (aka @tallestthomas over on Instagram).  

Example:

3) .reduce()

.reduce(), like .map() and .filter() loops over an array. But instead of return a new array, it takes a function in order to reduce the array to a single value.

How does it work?

The setup is similar to .map() and .filter(), but for one added bonus.

.reduce() takes a function as an argument, and that function has access to the 4 arguments. Not 3 like .map() and .filter().

Those arguments are (accumulator, element, index, array). But only the element” and accumulator are required to make this puppy work.

The accumulator represents the accumulated total or result returned from the function you pass in. The element represents the current element.

Your function should take the accumulator and element, perform an operation, and return a single value. That value will now be stored as the accumulator. You will see an example below.

In addition to the function argument, you can also pass a second argument to represent the initial value at which your callback function should start totaling from.

So where can it be used?

Well, one thing you could do is total up an array of numbers. This is often quite common. If you have an array of products and need to total up the price, using .reduce just makes sense!

But you could also use it to find an average by dividing the total (accumulator) by the length of the array.

Example:

4) .forEach()

.forEach() is a simpler and more readable way to write your standard for loop. It works by taking a function and calling it on each item in an array.

I know what your thinking. This sounds awfully familiar to .map(). Yes, it does, except for one big difference…

.forEach() mutates (changes) the original array it’s call on, whereas .map() returns a new array.

This makes them both better for different things, which I’ll cover in a seconds.

How does it work?

.forEach() takes a function, and that function requires you to provide one main argument…the element.

In your function, you can grab the element passed and do something to it. Whether that’s updating the element or changing it.

.forEach() will now loop over your array and apply that function to each element. The same way a normal for loop would! However, in a cleaner more readable way!

So where can it be used?

I mentioned that .forEach() and .map() seem very similar. So how do you know which one to use?

Whenever you need to change or interact with the original data in someway, .forEach() is what you need. But, if you want to keep the original data intact, use .map().

For example, .forEach() would be ideal if you needed to update the properties of an array of objects. However, if you need to pass data from an array, or create a slightly mutated copy, that’s when you would reach for .map().

But really, other than that, you can use .forEach() in the same way you would use a traditional for loop.

Example:

5) .indexOf()

.indexOf() can actually come in two forms String.prototype.indexOf() and Array.prototype.indexOf().

Both basically do the same thing but on different data types. But I wanted to mention both so there is no confusion when you come to search for this method in future.

It’s a simple method, which returns the index of an element in a structure. Whether that’s a String or an Array.

How does that work for each?

.indexOf() called on an array will take an argument like a number, and return the index where that number first appears in the array.

.indexOf() called on a string will take an argument like a character, and return the index where that character first appears in the string.

Fairly straightforward right?!

You should also know that .indexOf() also gives you the option to start searching from a particular point. By passing a number as the second argument you can effectively say “start searching from this index”.

Side note! .indexOf() has a twin method, .lastIndexOf(). This one does very much the same, except it returns the index of the last occurrence.

So where can it be used?

.indexOf() is a pretty handy method whenever you need to quickly find the position of an item. But it can also be used to return all occurrences of an item.

Example:

6 & 7) .some() and .every()

I’ve paired these two together because they are almost identical.

Both of them are array methods that return a Boolean. Both expect a function that runs a true or false test. However…both DON’T return the same thing!

.every() will only return true if ALL test’s on its elements pass, whereas .some() will return true if just ONE test passes.

So how does it work?

In both cases you pass in a function, that function takes the array element as an argument. In that function, you write a true or false test to be performed on each element.

The methods will then loop over your array an run that test on each element. The result you get back will vary depending on whether you are using .some() or .every().

So where can it be used?

Both of these methods are really good for doing some quick validation. For example, checking if data in an array matches the minimum criteria. Or checking if the data is valid i.e. doesn’t contain any undefined or nil values.

Example:

8, 9, 10) Object.keys(), Object.values(), Object.entries()

These three are pretty interesting object methods. They all allow you to reach into an object and pull out sets of data and return it in an array.

Each one will return a different data set so it will depend on your need as to which one you use.

So how do they work?

Object.keys() will return the keys from an object.

Object.values() will return the values assigned to those keys.

Object.entries() will return an array of arrays for each key value pair.

And to use them all you do is type “Object.keys()”, then pass the object into the parameters. Simple.

So where can it be used?

These methods really shine when working with data. Sometimes you may have the need to translate data in an object to an array. It may be that the data is better suited to an array, or you want to take advantage of some of the cool array methods above!

Example:

11) Object.freeze()

You can probably guess what Object.freeze() does simply by the name. But just to clarify Object.freeze() freezes an object, essentially making the object and its properties immutable (unable to be changed).

How does it work?

It’s easy enough, just write “Object.freeze()”, passing in the object you want to freeze. Then the method does its magic and returns the frozen object.

To access your new frozen object you will need to save it into a variable.

Now if you try to modify the frozen object an error should be thrown and the object won’t be changed.

Object.freeze() can also be used to freeze and array for instances when you want your array to be immutable.

So where can it be used?

The method is built for those instances when you don’t want the integrity of your data to be compromised.

For example, if your application is going to be accessible to third parties, and any change to the data may cause unwanted behavior.

Example:

12) .includes()

.includes() is a quick an easy method you can use on a string or array to find out if it contains a certain bit of data.

So how does it work?

There’s really not a lot to it. You simply call .includes() on your array or string, pass in the thing your looking for, then BOOM! Either true or false is returned.

So where can it be used?

Like .some() and .every(), this method is a quick and dirty way of validating some data. If you need to quickly check an element .includes() provides a quick a simple solution.

Example:

13) Array.from()

Array.from() has some petty cool tricks up its sleeve!

It has the ability to take anything “array-like”, which has a length, or is iterable, then creates a new array from it.

So how does it work?

To use it just call Array.from(), then pass in the thing you want to creates an array from, and you’re done.

Besides the “array-like” thing you are passing in, Array.from() can take a second argument, which is a map function.

Now, I already covered the map function earlier so I’ll just briefly summarize. The map function iterates over the array, grabbing the element, doing something with it, then returning it in a new array.

So where can it be used?

Here’s a little trick you can do with Array.from(). You can pass it a single object with a length property. Whatever value you set the length property, that will be the length/size of the array. Then you can use the map function as the second argument to populate that array.

Another cool thing you can do with Array.from() is to convert a collection of HTML tags, like a list of div’s or li’s, to an array. Now those div’s are in an array you can do all those awesome array things you like to do!

Example:

This second example produces the same result as above. HOWEVER, I have passed an object with a length property to designate the size/length of the array. Then uses the map function as a second argument to populate that array with numbers 1 – 5.

14) The Spread Operator

This isn’t actually a method but it does some really neat things so I’m just going to include it anyway.

The Spread Operator allows the contents of an array or object to be expanded out in places where multiple variables are expected.

Does that sound a bit complex? Don’t worry, I’ll explain and show you some examples.

So how does it work?

The Spread Operator is actually just 3 dots “…” followed by an iterable variable name, such as an array or object. So in actual fact, it would look something like this “…myArray”.

What that simple line is doing is taking all the elements from “myArray” and throwing them out in the open.

Have you ever tried to concatenate two arrays by doing something like “[1, 2, 3, arrayNumbers]”? What happens? Well, it just ends up putting an array within another array, which isn’t what you want (I’m assuming).

However, with the Spread Operator, you can concatenate two arrays simply by typing “[1, 2, 3, …arrayNumbers]”. The contents of “arrayNumbers” will now be “spread” into the rest of the array.

The same can be done for key-value pairs in an object.

So where can it be used?

As I mentioned, the Spread Operator is great for combining objects or arrays. You can also use it as a quick and easy way to destructure an object.  If you don’t know what destructuring is, check out this great article from Wes Bos.

For those learning or working with Redux, the Spread Operator is great when writing your reducers to update your applications state. Check out the Redux documentation to see how that works.

Example:

15) Rest Parameters

Rest Parameters looks very similar to the Spread Operator, but they are both very different!

With Rest Parameters, you can essentially represent an infinite amount of function arguments.

So how does it work?

Again, like Spread, you use the 3 dots followed by a variable name i.e. “…myArguments”.

When you actually come to write a function you simply state any arguments you know you need, followed by “…myArguments”. Then “…myArguments” will take the rest of the arguments, gobble them up, and collapses them into an array.

The key thing to note here is now “myArguments” is an array and so should be treated like an array in the function you write.

It’s easy to get confused between Spread and Rest because they look the same. The defining difference is Rest takes an undefined amount and collapses it into an array. Whereas Spread takes a structure like an array and does the reverse by expanding it out.

So where can it be used?

Rest is very handy when you want to create a variadic function.

A variadic function is a function that accepts any number of arguments. For example, you may want to join or concatenate an undefined amount strings, characters or numbers.

In this case, using Rest to create a variadic function is perfect!

Example:

I hope you enjoyed learning about these awesome methods and they help you in your future JavaScript endeavours!

Feature image designed by Freepik

6 great projects for beginners TEXT

6 Great Project Ideas for Beginners Learning Code

Shares

So you’ve got some programming skills, now it’s time to put them to the test by building some projects. However, the big question on your mind is…”WHAT THE HELL DO I BUILD?”.

To get you up and running ASAP, I’ve pulled together a handful of project ideas, which should help you get the ball rolling. I hope these projects will be fun, interesting, and simple enough so that beginners are not overwhelmed, but challenging enough to push you to grow as a programmer.

These are general ideas, which you should be able to implement into your language of choice. And where possible I have tried to add resources or examples for added guidance. But remember, Google is your friend!

Before you start, here are a few suggestions to get to most out of this experience

  1. Use tutorials and resources, but try to resist the temptation to copy and paste entire source code. The more you can do yourself the better.
  2. Make sure you can read and understand the code at each step, and Google what you don’t understand. Googling is an essential programming skill.
  3. Once you finish, try recreating the project again, but without any references. The key word there is “try”. Don’t worry if you can’t on the second attempt.
  4. Finally, take your time, remain calm and remember we all get stuck. It’s just part of the journey.

Side note: The great thing about these projects is they can be as simple or as complex as you like.

If you want you can keep them fairly bare, and just leave them as static text-based programs, without any UI. Or, you can go nuts and try and make them as flashy as possible.

Personally, I’d recommend keeping it simple at the start and focusing on the core functionality. You can always build them out later.

Now, onto the projects!

I have structured the ordering of these projects so that they start off easy, but get progressively harder as you move through the list.

1/ Magic 8-Ball

All hail the wise and magical 8-ball!

Hopefully, you know what a Magic 8-ball is, otherwise that previous statement will sound a bit weird. It probably sounded weird anyway. Never mind.

In case you don’t know, a Magic 8-ball is a fortune telling toy you shake to give you the answers life’s pressing questions. Simply ask a question, e.g. “What is Blockchain?”, then the 8-ball comes back with a wise answer, e.g. “How the hell should I know!”.

This is a fairly simple warm-up project. At its core, it’s just a series of random answers, which get spit out every time you shake the ball. So hopefully you won’t have any trouble with this one.

I don’t think you will, but should you need a reference, here are a few, written in Python.

2/ Shopping Cart

This project isn’t anything too fancy but it has a bit more to it than the previous Magic 8-ball project.

As you can imagine, it’s merely a simple shopping cart, in which you can add, removed, and eventually checked-out items.

I guess you could think of it as the next step up from a To-do list because on the surface it has the same functionally. However, instead of working with string variablesthe shopping basket will deal with objects. Need some help understanding object oriented programming? Here’s a Noobs Guide!

Each item in the shopping basket will be an object, this object will need, at the very least, a name and price as variables. However, you can add more, such as the amount of stock but in the interest of simplicity, you may want to stick to these two for now.

How you choose to implement all of this is up to you, although if you need some guidance you can check out this great example written in Java. Even if Java is not your lanaguage, this example should still give you an idea of the structure and flow of the application.

3/ Text Adventure Game

You’ve probably seen something like this before. It’s the simplest form of an adventure game, where the whole story play’s out via text. The world is described in TEXT, and likewise, you interact with the world in TEXT. That means no game physics or graphics to worry about. Phew!

I realize that was probably an awful explanation! So how about I just show you instead. Here’s a good example.

Now it doesn’t have to be as extensive as the above example, with buttons and timed responded etc…It can just be as simple as moving back and forth through a series of rooms.

Text-based adventures make a great beginner project because, one, making games are fun, and two, you don’t have to worry about polished GUI’s and game physics.

I hope you have fun with this project!

4/ Calculator App

Now I know I just said, “text-based adventure games make great beginner projects because you don’t have to worry about GUI’s”…But let’s face it, you need to start working with GUI’s at some point, and personally, I think a calculator app is an ideal place to start.

Why? Well, it’s a fairly simple UI (basically a field, and a ton of buttons), but still, it will test you when it comes to the layout and spacing of elements. Plus, you’ll get some good practice with Event Listeners.

As you can imagine, the app will look and function just like any calculator you have ever used. However, if you need some inspiration or resources there are literally hundreds of examples on the interwebs. Codecademy even has a nice little tutorial for those learn web development.

5/ Snake Game

A classic! I loved playing Snake as a kid, it was simple and addictive.

If you are not familiar with the game it’s pretty straightforward. You control an ever moving snake, and it your job to guide it to the apple which generates in a random location each time the snake eats it. And it just so happens that each time the snake eats the apple it gets bigger.

But be careful, as the snake grows it will start to fill up the screen with pure snakeyness, and should the snake runs into itself that’s it, game over. Sounds cool? Have a play if you like, but don’t get sucked in, remember you came here to build it!

Hopefully, now you have an idea of what you’re making it’s time to get started.

By the way, if you’ve been learning Python this might be a good opportunity to explore the Pygame library. In fact, here’s a tutorial which uses the Pygame library.

6/ Music Player

This is defiantly the most challenging project on this list, but don’t worry! Remember earlier I said these projects can be as simple or complex as you like? Well, that certainly applies here.

If you want, you could build a hypothetical music player, all text-based, which could work in a similar way to the shopping cart project.

In this instance, you could simply create a series of song objects, which can be added and removed from a playlist. Then provide additional functionality to sort, traverse (move through), and repeat songs.

Although, if that seems too tame you can work towards building it out into a full application, with a database, user interface, and everything else.

I guess I kinda envisioned this as a longer-term project that grows with you.

Side note: This project is a great opportunity to learn about Linked Lists and get some hands-on practice. You could, for example, create a playlist that functions as a Linked List, where each song points to the next song in the list, then set up methods to traverse the list.

If you haven’t come across Linked Lists before, and all that was just nonsense! I recommend checking out this post. There a great section that explains what a Linked List is, and a guide to help you build one.

MORE PROJECT IDEAS!

There are endless projects you can make and these are just a few. Ones which I hope provided a bit of range and will help cement those core programming principals you’ve been learning.

However, if none of these take your fancy dont worry, there are a load more on GitHub!

Feature image designed by Freepik

WHAT KIND OF DEVELOPER SHOULD I BE?!

Shares

Have you struggled with this question? ME TOO! There are so many different options and it’s hard to know which one is right? Should you be a Mobile Developer or Web Developer? What about Back-End vs Front-End, or Full Stack? The questions just keep coming! So how do you decide?

First, things first…

Before we start, are you a complete beginner? i.e. no programming experience what so ever! Because if so, I’d suggest putting this question on hold, just for the time being.

Right now you probably have a ton of questions about your future as a programmer, but don’t worry, you don’t have to have it all figured out now.

For the moment, I’d recommend keeping it simple and just focusing on picking your first language, then learning the basics. *By the way, if you need help picking your first language, check out this post.

Questions like this can often be distracting at the start, and you may end up wasting time. Believe me, you can easily spend hours, days, even weeks! Trawling the internet for answers…ironically, like this one (sorry).

Wasting time

Why is this a waste of time??

Okay, think of it like this…How often does your first love become the love of your life? Sure it can happen, but it’s rare. Sorry again to all you romantics!

The same logic applies here. The chances of you picking one specific thing at the start, and crafting a whole career out of it (ONE THAT YOU LOVE), is again, rare.

In reality, as a newbie programmer, you’re going to be trying out a few different things and experimenting as you go. So theirs a good chance that you’ll change your mind anyway.

So as the scenario goes, you may start off with the intention to be X but now you want to be Y. That means the time you spent researching could have been better-spent coding. Ergo, time wasted.

That said if you do have a rough idea already, great! Go with that and get started. A rough idea is enough at this stage. The whole point of my spiel here is that you don’t need to know the specific’s, you just need to get started.

You don’t need to know whether you’re going to be a Back-End Web Developer, who specializes in node.js, and does x, y, z…blah blah blah. Knowing you want to be a Web Developer is enough.

But what if I pick the wrong language??

A very common question. Well, here’s the cool thing…once you learn one, you’ll have a core understanding of how most programming languages work. This makes learning you’re second a whole lot easier!

Honestly, the hard part isn’t learning the language itself, it’s learning core programming fundamentals, and how to “think like a programmer”.

I often feel that too much time is wasted researching and trying to find the answers up front. And I can’t judge, I’m horrible for this!

I’m the type of person who wants to know the outcome before it’s even happened.

Back to the MAIN QUESTION

Sorry if none of that was relevant to you, but I had to get it out of the way for anyone just starting out. Hopefully, you can learn from my mistakes!

Anyway, back to the BIG QUESTION…how do you know what kind of developer you should be?

There are a few ways you can go about it, and it depends what matters to you the most.

If it’s money? Then look for the highest paid roles. If it’s a job, any job? then see what’s in demand around you.

Me personally, I want to be in a role that I love and I’m passionate about. And that’s how I am going to address this question.

I love my job

So…How do you find you’re PASSION? 

You’re not going to find it on the internet, or in books, or from a friend of a friend. It’s simply going to come from experimenting with different things to see what you like. Never be afraid to experiment! 

I myself regret not experimenting sooner. From the outset, I had a fix idea that I wanted to learn Java and focus solely on Android Development. So much so that I didn’t learn anything else because “it wasn’t part of the plan”.

Looking back I realize this approach closed me off to so many things. Cool things. Things that I now really love. Things like React and JavaScript.

It was only after I fell into a rut that I decided to switch things up and learn some Web Development and JavaScript. Then it hit me. I can’t decide what kind of developer I want to be straight out the gate. I need to experiment.

For the record, I don’t regret learning Java or pursuing Android Development because…

  1. Despite the rut thing, I still enjoy it.
  2. It gave me a focus, structure and somewhere to start.
  3. And most importantly…it taught me how to program!

However, I just wish I hadn’t been so ridged earlier on, and actually opened myself up to trying out other things. *There’s a moral here somewhere…

When you’re finding your feet as a programmer you need to give yourself the freedom to experiment. It’s the only way you’re going to find your passion, and discover what genuinely excites you. 

In these early days, it makes sense to try a few things out, figure out what you like, don’t like, and what best fits you.

You should really learn a few languages anyway. And that’s not just coming from me!

Gayle Laakmann, the author of Cracking The Coding Interview, mentions that only knowing one or two languages indicates that you haven’t experienced varied problems, or that you have trouble learning new technologies.

As a general rule, I believe it never hurts to learn something new, and that applies whether you are a newbie or an expert.

Where am I now??

In case you’re wondering where I am now, let me just set the scene.

Currently, I’d say I’m still in the experimentation phase. I’m enjoying React and Web Development, and plan to continue down that road with a view to secure a job in Web Development creating Web Applications.

However, I do plan to learn a couple more languages this year. At the moment it’s a toss-up between Ruby and Python, and I’m slightly leaning more toward Ruby because of Ruby on Rails. But let me know what you think. I’m always interested to hear other peoples opinions.

You may have noticed I said “phase”, well I like to think of the Programmers Journey in terms of 3 main phases.

The 3 Main Phases of the Programmers Journey

Here is what I consider to be the 3 main phases in the Programmers Journey.

Phase 1 – Introduction:
The start of your journey as a programmer, where you learn all the importation fundamentals.

Phase 2 – Experimentation:
Where you try a few things out, learn a new language, and discover what you like and don’t like. 

Phase 3 – Specialization:
Picking a focus area and working to become an expert in that area.

It’s worth mentioning that your journey doesn’t have to stop with “Specialization” phase. The door is always open to experiment with something new.

Summary

If you have no programming knowledge, don’t worry about what kind of developer you should be. Instead, focus your time and energy on learning the fundamentals of programming.

Next, experiment! Find out what you like and don’t like. That will give you a good idea where to head next.

Finally, specialize, but remember, it never hurts to learn something new.

Feature image designed by Freepik

The ULTIMATE BOOK LIST for BEGINNERS learning to code

The ULTIMATE BOOK LIST for BEGINNERS learning to code

Shares

If you want to learn how to program then it pays to have some good books by your side. That is why I have put together a collection of top books designed to help you learn to code and develop yourself as a programmer. I want to help you become the best developer you can be. So let’s get into it.

General Programming Books

In this section, I have put together a broad list of books, which I consider to be more general, rather than language specific. I have included language specific books further down, but these are the books that will give you the necessary foundations to become a skilled professional programmer.

Head First Learn to Code by Eric Freeman

Head First books don’t look like your traditional programming textbooks. Rather they are quirky, visual and strives to entertain.

The whole thing is design to teach you the key concepts of programming in a fun, practical and easy to understand way. It uses Python, which is a notable popular yet easy to read language, ideal for a beginner.

It doesn’t over complicate, it doesn’t overwhelm, and it doesn’t bore you to death. This book is perfect for a complete newbie looking to dip their toe into programming.

And if you like this book you will be pleased to know it’s one of a series. Head First has a number of books on different topics and programming languages. Such as Head First Design Patterns, Head First Python, Head First Java, Head First Android, and the list goes on.

Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin

As a beginner, what you might not know is how important it is to write clean code! In fact, it’s one of 9 mistakes beginners make when learning code. That’s why Clean Code is a very important book.

Clean Code will teach you the difference between good code and bad code, why it’s vital to write good clean code, and the best practices to make you’re code squeaky clean.

Good programmers care about the code they write. They are craftsman, who write beautiful code. Yes, that’s right, well-crafted code can be a beautiful thing.

Code: The Hidden Language of Computer Hardware and Software by Charles Petzold 

Anyone remotely interested in computers and technology will find Code, by Charles Petzold, an interesting read.

This book cuts to the core of how computers actually work! But explains everything in a very accessible way so virtually anybody can pick up and read this.

As a beginner or self-taught programmer, we don’t tend to have that deeper knowledge of how computers work. And while it’s not a prerequisite to be able to write code, have this knowledge does give you an edge.

Having the marriage of hardware and software embeds a greater fundamental understanding and allows you to see the bigger picture.

You can walk away from this book finally knowing how your code really works and what’s going on behind the scenes.

The Pragmatic Programmer by Andrew Hunt, David Thomas

This is an ideal book for anyone new to software development. It’s an easy read, filled with great analogies, and tons of wisdom that new programmers need to hear.

The Pragmatic Programmer talks more about the philosophies of Software Development. This allows you to understand the core process, which will make you a better programmer.

There are a lot of lessons that programmers learn over time, and this book is a culmination of those lessons. So you could probably save yourself some time by reading this book and digesting those lesson now.

Code Complete: A Practical Handbook of Software Construction by Steve McConnell 

Pre-warning, there is a lot to this book, it like 900 pages! But to summarize, think of this book as a definitive guide to software construction.

The book gives a beginner a great insight into the professional methodologies and general approach to building software. But really goes into the nitty-gritty, hence the length of the book.

I know as a beginner we don’t tend to think in this way. Instead, we are more concern with getting the code to actually work! Which sometimes results in poorly constructed hacky code.

Code Complete will helps shape the way you think about building software.

Needless to say that it’s a very comprehensive book. I myself, as of writing the blog post, am still working my way through it. But I can see why it comes highly recommended for beginners.

Sure, it has been around for a few good years so some stuff may be slightly outdated. However, the core still holds up!

Coders at Work: Reflections on the Craft of Programming by Peter Seibel

If you want to be the best, learn from the best.

Coders at Work is a collection of 16 interviews with some of the programming worlds best and brightest.

It’s an interesting an insightful read for any programmer. But the wisdom shared in this books can be very helpful for beginners. I particularly like something that Jamie Zawinski, Lisp hacker, and Netscape Developer, said…

“If you don’t understand how something works, ask someone who does. A lot of people are skittish about that. And that doesn’t help anybody. Not knowing something doesn’t mean you’re dumb–it just means you don’t know it yet.” 

Personally, I found this very comforting when I first started out.

Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein

Algorithms can be a scary topic for beginners, but luckily we have this book. I’d say it’s probably one of the best algorithm books for beginners currently out there.

This book has been designed to be both comprehensive and accessible to programmers of all levels. So while this book is branded as an introduction, it still covers everything you would need to know in detail!

Examples are written in plain English and pseudocode, which mean you don’t have to worry about programming language specifics. I am sure if you’re a beginner, that’s music to your ears!

Simply, this is the ideal book for your first foray into data structures and algorithms.

Programming Pearls by Jon Bentley

Programming Pearls is somewhat of a golden oldie and regularly cited as a programming classic that has stood the test of time.

It’s packed full of pearls of wisdom (see what I did there) that have come from years of programming experience. You are shown programming problems that others have faced, and how these problems have been address. This aids your ability to tackle programming problems, helping you to become a better problem solver.

While this is a classic, you will also be happy to know that the second edition has been updated. So it includes modern programming methods and environments. Plus new examples.

Just a little disclaimer here though. This book does it’s best to be accessible, but there maybe some technical stuff unfamiliar to complete beginners. Well, that’s what I personally found anyway.

But despite that, I still feel this is a great book for new programmers for the sheer fact that it will help you become a better problem solver. And as you may have guessed, solving problems is a big part of programming!

Cracking the Coding Interview by Gayle Laakmann McDowell

This is the book you are going to want to have to hand when you seriously start thinking about venturing into the job market.

First and foremost, it’s a career orientated book. However, it does also provide some great information on data structures, algorithms and other technical stuff. But it’s all in relation to securing that job offer.

If you want to land a job at a big tech company, then this is the book you need. This book is very practical and tells you everything you need to know and what to expect.

It also prepares you extensively with 189 real-world practical examples of coding interview questions. Giving you ample opportunity to practice and master these types of questions.

Language Specific Programming Books

Below is a section of books, which I consider to be ideal for any beginner looking to learn one of these languages. I have tried to cater for those who want a gentle introduction and those who want something more comprehensive. Hopefully, you will find something here for you.

Java

Head First Java by Kathy Sierra & Bert Bates

Head First Java is your simple, easy and fun guide to learning Java. The Head First series take a more novelty approach to learning, which helps make the information more engaging and easier to grasp for beginners.

Java: A Beginner’s Guide by Herbert Schildt

Herbert Schildt provides a very good introduction to Java in this book. It does help to have some basic programming knowledge, but that’s what you have the “Head First” series for. However, as the title suggests, this book is aimed at beginners and will serve aspiring Java programmers well as a starting point.

Python

Python Crash Course by Eric Matthes

I think an absolute beginner itching to get started will love this book. It’s fast-paced but provides enough hand-holding for beginners. You start by delving into the basics, then you quickly move onto building projects in the second half.

Learn Python 3 The Hard Way by Zed Shaw

Those who want a bit more of a challenge should pick up this book. Despite the “Hard Way” label, it is aimed at beginners. However, the book has you relying less on IDE’s to do all the work. And instead, get you using your own initiative and look things up (a common practice among developers). Zed Shaw has a series “Hard Way” books in other languages, including Ruby and C. You can also get the material for FREE from his website.

Ruby

Beginning Ruby by Peter Cooper

Here’s a great book to begin your exploration into the world of RUBY. It starts of teaching all the fundamentals of the language, and by the end will have you creating real Ruby applications. This book also demonstrates the breadth of things you can do with Ruby as it’s such a versatile language. Having that wider field of view helps a beginner to understand the possibilities.

Intro To Ruby Programming by John Elder

This may be a somewhat lighter introduction, but it’s a great place to start for someone with no programming knowledge whatsoever. You’ll also be able to wiz through it in a couple of days. And while you won’t emerge an expert, you will still pick up the basics.

C

C Programming Absolute Beginner’s Guide by Greg Perry & Dean Miller

This book does what it says on the tin, it’s an absolute beginner guide i.e. very noob friendly. In 350 pages, you can go from complete noob to having a competent understanding of programming and the C lanaguage.

C Primer Plus by Stephen Prata

C Primer Plus is a brilliant book that provides a welcome introduction to C. Yet it continues on with some intermediate level material, which provides a good transition. It’s a comprehensive (large) book which will teach you what you need to know to create practical applications with C.

C++

C++ Primer by Stanley Lippman, Josée Lajoie, and Barbara E. Moo

This is a very popular C++ book which provides a very thorough introduction to C++. It covers just about everything in the language but makes it SIMPLE.

Programming: Principles and Practice Using C++ by Bjarne Stroustrup

Learn C++ straight from the creator of the language, Bjarne Stroustrup. It’s a notable introduction to C++ and programming in general, which assumes no previous programming experience.

C#

The C# Player’s Guide by RB Whitaker

Whether you’re a complete beginner or have some experience, this book is designed to be the ultimate guide for someone delving into C#. In addition to covering everything you’d expect from the language, it also covers the very popular .NET framework.

C# Programming in Easy Steps by Mike McGrath

If you want an introductory book that isn’t so meaty then check out this one. It’s a quick read at only at 192 pages, yet it still gives you a good understanding of the language. And of course, it’s very beginner friendly.

JavaScript

Eloquent JavaScript by Marijn Haverbeke

Eloquent JavaScript comes highly recommended as a general programming book. It does teach JavaScript but focuses on the art of programming to get you writing great eloquent code. This book provides all the necessary introductions for beginners but challenges you at the same time so you REALLY learn. And for an added bonus, the book is available online for FREE.

A Smarter Way to Learn JavaScript by Mark Myers

What’s the smart way to learn? By doing! This is a projected based approach to learning, with plenty of consideration for beginners. It keeps things basic and easy to understand so you won’t scared off.

HTML/CSS

HTML and CSS: Design and Build Websites by Jon Duckett

Jon Duckett’s books are normally the go-to books for aspiring web developers and it’s easy to see why. The information is not only extremely valuable but displayed in a concise and simple manner. The design, layout, and graphics of the book make it visually appealing and importantly, EASY TO DIGEST. If you like this book you should also check out his JavaScript and JQuery edition. You’ll need that if you want to make some bad ass websites.

Learning Web Design by Jennifer Nieder Robbins

This book has been created as a no-nonsense guide to creating professional websites. However, the next edition is set to come out in May 2018. So you may want to hold off and wait for the latest edition to get the most up to date stuff.

PHP

The Joy of PHP: A Beginner’s Guide to Programming Interactive Web Applications with PHP and MySQL by Alan Forbes

The Joy of PHP makes no initial assumptions. Even if you don’t know HTML the book provides a quick intro to get you up to speed. You then dive-in to learn PHP through a series of fun exercises, to get your feet wet.

PHP and MySQL Web Development by Luke Welling, Laura Thomson

For a very thorough a complete book on PHP for beginners, consider picking this one up. However, it may be a slight strain as this book is a brick, coming in at 1000 pages. I understand that maybe a bit scary for a beginner. However, it is in an easy to read format accessible for all!

Have I missed any books?

Obviously, I can’t include every book and there will be some that I have missed. But I intend for this to be a growing list. So if you have any suggestions for books which you think will be perfect for a beginner then let me know in the comments. Many thanks!

Feature image designed by Freepik

8 Misconceptions about LEARNING TO CODE

Shares

There are a lot of myths and misconceptions when it comes to learning code. Some of these can even prevent a person from deciding to learning code in the first place. So I feel it’s worth taking the time to dispel some of these common misconceptions.

1/ You need to…be a MATH GENIUS

Many people have this image that ALL programmers are math wizards with an IQ to match Einstein. Well, I am sorry to ruin the illusion, but…THAT’S SIMPLY NOT TRUE. Sorry guys.

Sure, there are defiantly some really smart cookies out there, but it’s not a prerequisite to be a programmer. You don’t have to be a genius simply to be a programmer.

When it comes to maths specifically, the level of required knowledge and proficiency varies depending on what you are doing.

Some area’s of programming surprisingly doesn’t involve a whole load of maths.

For example, if you’re taking data and storing it somewhere i.e. a database. Or possibly you’re working with some of the graphical user interface elements of an app. In which case, you may be using built-in or external libraries (pre-written code by someone else).

In these kinds of situations, maths doesn’t play such a big role. However, across all walks of programming, the ability to think LOGICALLY is necessary. But you don’t have to be a genius to do that.

Obviously, there are some area’s that are more math heavy.

If you are looking to get into Artificial Intelligence, then it’s probably worth picking up some textbooks.

Or suppose you’re interested in developing games, then you will probably be using math to calculate the physic of the game.

But even then, the Unity game platform has built-in physics engines provide components that handle the physical simulation for you.

So, yeah, don’t worry so much about not being a “genius”. You can still be a programmer.

2/ You need to…have a LOT OF TIME

WRONG. You just need CONSISTENCY. 

You may think the only way to learn programming is by studying 24/7. But you don’t.

Sure it would be ideal. However, luckily for those who can’t afford to give up their day job, we can still learn with the time we have.

All you need is a couple of hours an evening…and some DEDICATION. If you can have the willpower to sit down at your computer every night and code, I can guarantee it will eventually sink in.

As long as you’re actually studying that is! If you’re just watching Epic Fail videos on YouTube, it’s not going to work obviously.

You need to be actively learning, actively coding, and of course, referencing good resources!

Speaking of resources, if you need help finding a quality course, check out this blog post: LEARN CODE from these 12 BRILLIANT Udemy Instructors.

3/ You need to…go to UNIVERSITY

If you want a career as a software developer you need a degree, right?….NOPE!

You may be surprised to hear that most software developers are actually self-taught. In fact, according to a 2016 survey on Stack Overflow, roughly two-thirds are self-taught, with fewer than half having formal degrees in computer science.

For some industries, a degree is a MUST, which is understandable in some cases. Would you want a self-taught doctor to perform major heart surgery on you? Didn’t think so.

But for all those, unable to go to university, with dreams of becoming a developer, well, you will be happy to know that your dreams can still come true!

Evidently, from the stats, you can still forge a career, regardless of whether you’re self-taught or not. You just have to be driven, learn what you need, and demonstrate what you know. A portfolio is a good way to do this.

There will still be companies that slap “degree required” on their job ads. But it’s not a requirement of ALL developer roles. And to be honest, there’s still nothing stopping you from apply, despite not having a degree. You never know what can happen.

4/ You need to…spend LOADS OF MONEY

Have you seen the price of university? How’s a guy supporting his family meant to afford that? Oh yeah, misconception no.3…you don’t have to go university.

Okay, well…still, those coding bootcamps are expensive! What are they? like a few thousand? My pockets aren’t that deep.

Don’t worry, in this modern age, you can learn just about anything thanks to the power of the internet. And best of all, much of it is FREE. I even took the time to compile a list of free resources to help you learn code. You’re welcome.

And I know what your thinking, the quality’s probably crap if it’s free. But they’re not. In fact, they are pretty damn good, especially Free Code Camp.

But if that doesn’t persuade you, then you can always check out websites like Devslopes, Team Tree House, Code School, Plurasight, or Udemy, which are all pretty reasonably priced.

You can pick up a course on Udemy for the “price of lunch” as they so often say. And it’s full of brilliant instructors as I have previously mentioned.

5/ You need to…get a POWERFUL COMPUTER

When you look at professional programmers they all seem to be rocking Macbooks, Ultrabooks and fancy PC setups. So naturally, you may think a decent computer is vital.

But really…IT’S NOT.

To learn code all you need is a computer, any computer. You don’t need a high spec one with all the bells and whistles just to learn.

Just think, if you are learning to drive are really you going to buy a Porsche? Or stick to a little runaround car?

When I started out I was learning on an old, pretty basic laptop. It was fine for everyday use but quite slow when it came to crunching code. However, that didn’t matter, as long as it worked, and it did the job. That was all I needed.

You don’t need much more than that just to get you started.

6/ You need to…know how COMPUTERS WORKS

Don’t worry if you have no clue how that magical box, turns 1’s and 0’s into the beautiful user interfaces we’re used to. You’re not alone.

Most programmers don’t actually need to know the fine details of how a computer works under the hood.

Of course, there are exceptions, and it can be an asset to have that inner knowledge.

However…it’s not something you NEED to know in order to learn code.

When you’re learning code you just need to focus on what the code is doing. You don’t need to concern yourself with how the computer is interpreting that code and crunching the numbers behind the scenes.

You can put that to one side.

Although, if it is something that you are interested in, then Crash Course’s YouTube Channel has a great Computer Science series which explain the inner workings of a computer.

7/ You need to…be YOUNG

You may think coding is only for techie wiz kids but you don’t have to be a spring chicken to start learning.

I myself started learning at 27, and while I thought I was unusual, it turns out I’m actually pretty average. According to a survey of 20,000 people done by FreeCodeCamp, the average age of learners is 28. Surprising I know!

Even that is young compared to other stories of people learning to code in their 60s, 70s, and 80s.

Age is just a number at the end of the day, and you shouldn’t let that stop you. If you have a passion for something, pursue it! No matter what your age.

8/ You need to…be A GUY

Tech is often seen as a “guy thing”, and is quite a male-dominated field when you look at the stats. According to the National Center for Women & Information Technology, 26% of the computing workforce was female in 2016.

And in 2015, approximately 18% of computer science and information sciences bachelor’s degree recipients were women.

But code isn’t just for guys! It’s for ALL!

In fact, if you look back at the history books, some of the pioneering programmers were women. Just to throw some names out there, you have:

  • Ada Lovelace – Credited as the worlds first programmer.
  • Grace Hopper – Developer of the first compiler, creator of the COBOL programming language, AND (here’s a FUN FACT), she also coined the term “computer bug”, after finding a moth in her computer.
  • Adele Goldstine – Creator of the world’s first electronic digital computer.

There are plenty more examples, but these ones hopefully show you that it’s not a “guy thing”. And actually, women have already played a key role in Computer Science history.

Remember, there is NO STEREOTYPICAL PROGRAMMER. Programmers come in all shapes, sizes, colors, creeds and of course…genders!

Feature image designed by Freepik

13 RESOURCES to learn DATA STRUCTURES and ALGORITHMS

Shares

In my last post, The BEST way to learn Data Structures and Algorithms, I provided some practical advice, guidance and, RESOURCES to help you learn this challenging topic. Well, I am back to expand on those resources. I want to ensure that you have awesome resources at your figure tips to really help you get your head around this topic.

These resources are in no particular order. However, I have divided them into 3 categories; “websites”, “books”, and “courses”. The idea is to help you find what you’re looking for.

I have also tried to include resources aimed at various skill levels. So whether you’re just starting out and want to understand the basic concepts, or you’re diving deeper and need detailed implementations, there should be something for you.

Before we start, this topic DOES assume a basic knowledge of at least one programming language. You don’t need to be an expert by all means! You just need the programming basics. If you have never written code before you may want to bookmark this page and return to it later.

Courses 

1/ Udacity’s Intro to Algorithms 

I thought I’d start with this course as it provides as a great introduction and comes with the added bonus of being FREE!

As an introduction, this course will most likely be your first destination when learning this topic.

The course is written in Python, but don’t worry if you’re unfamiliar with Python. Luckily, the course takes a gradual approach, and it helps to know that Python is a very readable programming language.

To help cement your learning there are quizzes along the way to test your knowledge. After the course, you should have a practical understanding of algorithms and be ready to dive deeper.

2/ Algorithms and Data Structures by edX

Here is another brilliant FREE resource if you are looking to grasp the fundamentals of algorithms and data structures.

This course is brought to you by the good people at Microsoft, and again, it serves as an ideal introduction to the topic.

After the course, you will walk away with a sound understanding of popular algorithms and data structures.

BUT, you will also understand HOW and WHEN to use them.

Learning is great, but unless you can apply what you’ve learned, it’s not very useful. With that in mind, it’s worth mentioning that this course also sees you create an app for your final project!

Upon completion, there is an option to purchase a verified certification, but the choice is yours. If you just want the knowledge then there’s no obligation to spend any money.

3/ Data Structures and Algorithms on Udemy

If you have some basic knowledge of data structure and algorithm but want MORE! Check out this course…And if you’re a Java head, then DEFINITELY check out this course!

While it’s uses Java, it’s not a prerequisite of the course. As long as you know at least one object-oriented programming language you should be fine. So don’t be put off by the fact it mentions Java specifically.

This is a paid course on Udemy. However, if you are familiar with Udemy then you will know that they regularly have sales where courses can be discounted up to 95%! I regularly buy courses on Udemy for as little as £10.

The course covers a lot of the important stuff, such as Arrays, Linked Lists, Trees, Hash tables, Stacks, Queues, Heaps, Sort algorithms and Search algorithms. It goes through the theory but also the practical so you know how things actually work.

If you’re interested, feel free to watch the free sample videos. Of course, this is not the only data structures and algorithms course on Udemy. However, for me, this was a stand-out course.

4/ Coursera’s Data Structures and Algorithms Specialization

This course it’s arguably the meatiest on this list! It’s not just ONE COURSE, it’s, in fact, a SERIES OF COURSES!

However, before I go any further, you should know that this is another paid course. One which is a bit more expensive than the previous Udemy option.

If you’re interested it £36 a month (or equivalent). But as I say, this is a meaty course.

At present, the whole thing is actually made up of 6 courses, which cover various topics that go from introductory to advanced stuff. And it’s not all theory, there are problems to solve and projects to make. Cool projects at that. Just take a look for yourself.

Opinions will vary, and you may think this is quite a pricey course, but I am sure you will agree that the course looks very comprehensive. Plus, you also get a certification as well, which you can add to your CV and LinkedIn.

If you are considering this course they have a 7-day free trial where you can test the water. But if money is an issue there are other resources on this list.

Websites 

5/ Tutsplus.com

EnvatoTuts+ has a number of “How to Tutorials” on different programming topics. Including this series of posts titled ‘Data Structures Succinctly’.

Just as the title suggests, these posts aim to explain the basic concepts of data structures and algorithms, SUCCINCTLY.

While these posts won’t make you an expert, they do serve as a very useful introduction to things like Linked Lists, Binary Search Trees, and Sorting Algorithms.

Examples are in Java, but the simplicity of the posts do still make the information easy to grasp, and serve the purpose of a succinct overview.

6/ Geeksforgeeks.org

Geeks for geeks is another one to bookmark if you’re just starting out with data structures.

I really like it, and personally, I think it’s a great reference site. It does very well at explaining a number data structures and algorithms in a readable way (what I call noob proof).

There’s nothing worse than a confusing website which makes everything so complex!

The website has a series of tutorials on various data structure and algorithm topics, and you can either go through them one by one or use the navigation menu to pick your topics of interest.

Luckily, this website is full of diagrams, videos, and heavily commented examples so you can really understand what’s being taught. And the great thing with these examples are they’re available in Python, Java and C/C++.

On a final note, there are also quizzes to test your knowledge. Plus a section to help you prepare for an interview.

7/ VisuAlgo.net 

If you like visuals, then you ‘ll love VisuAlgo.

This website is full of amazing interactive animations to help you understand how these structures are formed, and how various algorithms work.

Data structures are quite abstract in nature, which means they can be very hard to grasp without visual representation.

Without this visual element, you may find yourself doing mental gymnastics in an attempt to understand what’s going on!

You can fully interact with the animations, see the code that is playing out, and if need be, pause and rewind the animation to see the finer details. I’d recommend playing around with this website to really experience how it works.

Then when you feel comfortable you can move on to there quiz sections.

8/ Tutorialspoint.com

Tutorialspoint has a great introductory tutorial on data structures and algorithms for the budding young C programmer. Complete with code examples and interactive terminals to try out the code.

While this tutorial is clearly aimed at those who know C, it doesn’t mean its useless for everyone else.

I found the explanations are simple enough to be universally understood. Even if you don’t know C, you should be able to walk away knowing the fundamental concepts of a Binary Search.

You may even have some fun trying to convert the code to your language of choice. After all, that is the best way to learn.

Books

9/ Introduction to Algorithms by Thomas H. Cormen , Charles E. Leiserson, Ronald L. Rivest, Clifford Stein

Everyone has to start somewhere, and it helps to have a good introduction. Having a solid foundation is very important after all, which is why “Introductions to Algorithms” is a valuable book for any beginner.

This book has been designed to be both comprehensive and accessible to programmers of all levels. So while this book is branded as an introduction, it still covers everything you would need to know in detail.

Examples are written in plain English and pseudocode, which mean you don’t have to worry about programming language specifics. I am sure if you’re a beginner, that’s music to your ears!

Simply, this is the ideal book for your first foray into data structures and algorithms.

10/ The Algorithm Design Manual by Steven S Skiena

Sometimes it would be nice to have a manual for life. But at least we have a manual for designing algorithms!

If this is a subject you struggle with then this book is a recommended read thanks to its beginner-friendly approach.

The book is broken down into two parts, with the first providing practical advice and instruction when it comes to designing and analyzing algorithms. And the second part is filled with resources and reference catalog of common algorithms.

There is also a series of self-titled “war stories” that depict practical experiences of real-world applications. Having these practical examples are a nice touch, which help you see how this knowledge applies to the real world.

11/ Programming Pearls by Jon Bentley

Programming Pearls is somewhat of a golden oldie and regularly cited as a programming classic that has stood the test of time. So it felt only right to include it on this list.

It’s packed full of problems to work through and solve, which will aid the development of your problem-solving skills.

While this is a classic, you will also be happy to know that the second edition has been updated. So it includes modern programming methods and environments. Plus new examples.

This is an ideal book for new programmers, and it’s charm lies in helping you become a better problem solver. It educates it’s readers in fundamental algorithm design principles and practical programming techniques.

12/ Algorithms by Robert Sedgewick, Kevin Wayne

Here is another acclaimed classic book which is mentioned a lot in the academic community.

Java programmers will find themselves at home with the latest edition as it’s example are written in Java. Understandably for those unfamiliar with Java, there is a slight learning curve.

Along with the book, there is an accompanying website, which includes exercises, further learning materials and even links to Roberts Sedgewick’s course on Coursera.

So, all in all, there is a wealth of information available to the reader.

While this is a great book I get the impression it’s aimed more at the intermediate level programmer, rather than complete beginner. But it would defiantly be one to come back to.

13/ Cracking the Coding Interview by Gayle Laakmann McDowell

I will admit that this choice is a bit of a wild card, as the aim of this book is to help you “crack the coding interview”, rather than teach you all the in’s an out’s of data structures and algorithms.

It does cover this topic but in the context of a coding interview question, which is actually why I included it on this list.

One reason you may be learning this stuff is to land your dream job at a big tech company. If that’s the case why not make it as practical as possible.

The latest edition if full of 189 real-world practical examples of coding interview questions. Giving you ample opportunity to practice and master these types of questions.

This book also provides great advice, great insight, and lets you know what to expect from the whole ordeal.

Feature image designed by Freepik

The BEST way to LEARN DATA STRUCTURES AND ALGORITHMS  

The BEST way to learn Data Structures and Algorithms  

Shares

For anyone learning code, the subjects of data structures and algorithms are straight up daunting! Even if you have been coding a while, these can still be difficult subjects. But this post aims to help you conquer these challenging concepts with resources, guides, and practical advice.

When it came to learning code, this topic had me thoroughly confused. I can remember going back and forth, trying to understand the in’s and out’s of data structures. What are they? How do they work? And how are they used? Questions that I need answering!

If I’m honest, I still have a lot of learning to do. But I now have a system in place which helps me get my head around this intimating subject.

However, before we get into that, I feel a quick intro is necessary to explain the basics of what data structures and algorithms actually are, AND, why they seem to come as a pair.

WHAT is a data structure? WHAT is an algorithm? And WHY are they together?cartoon of a businessman with a question mark

On the surface, they are not that confusing to understand. A data structure is just a collection of data organized in a particular way so that we can perform computational operations on its data effectively.

Think of a bookshelf full of books. You can consider the bookshelf as the data structure, and the books as the data. Not so scary now right?…But where do algorithms come in?

Suppose you wanted to find a certain book on the bookshelf, or sort the books in a certain order. Well, that’s where we use an algorithm.

An algorithm is simply a set of logical instructions for carrying out a predefined task, like finding a particular book for example.

In this case, you would scan through the books on the shelf, attempting to match the book on the self to the book you are looking for. When you have a match, you know you’ve found the your book!

By the way, algorithms are not just reserved for data structures, but they are normally associated because we use algorithms to interact and perform operations on the data structure.

Whenever you are creating a set of instructions to achieve a task, you are creating an algorithm.

And that it in a nutshell. Of course, there is a hell of a lot more to it than that. Just for a start, you have different types of data structure such as Lists, Trees, Stacks, Queue’s, plus more!

But I just wanted to provide a simple overview for now.

Next, I have another question. One you may be asking yourself, and one I DEFINITELY asked myself!

Do you REALLY need to know the ins and outs of data structures and algorithms? 

So here’s the question. Do you NEED to know the background details of how data structures work? Including how to build one and implement commonly used algorithms like merge sort, binary search, bubble sort?

For a new programmer, the question becomes more understandable when you consider that most languages have inbuilt libraries to do the heavy lifting for you. Take Java for example. You can simply write:

And BOOM! There’s your data structure, and you can now use inbuilt methods to add, remove, sort and search data as you please.

So the question remains…Do you? The short answer is YES!

3 BIG reasons why you NEED to learn data structures and algorithmsleader standing on big winner golden cup  

1/ It will IMPROVE your SKILLS and make you a better PROGRAMMER

In my eyes, programmers are problem solvers. It’s a fine skill, I would even say an art. However, this skill doesn’t appear out of thin air. It comes with practice, practice, practice!

By their very nature, data structures provide the perfect playground to practice. They give you a canvas to work with, in the form of interestingly arranged data. Data which you can manipulate till your heart’s content.

Practicing your problem-solving skills is the only way to improve. 

Even just creating your own data structure helps you to think more abstractly. In the end, It all helps you THINK more like a programmer. Which in my opinion is the hardest think about learning to code.

In addition to helping you think a certain way, it’s another skill you can add to your programmers’ toolbox. And the more tools you have in your toolbox the more complex problems you can solve.

2/ NOT EVERY LANGUAGE is the SAME

Although near enough all programming languages encompass the same concepts, they do still differ. Each language will have its own set of API’s and inbuilt methods, separate from the rest.

While you may notice similarities, it’s NOT a case of one to rule them all I am afraid. Learning the API’s and libraries of one language does not necessarily grant you the understanding for the rest. Being totally dependent on the inbuilt functionalities of a language may somewhat constrain you to that language when using data structures.

Whereas having a fundamental understanding of how data structures work and are built, would give you greater versatility.

For the record, I am not saying it’s a bad thing to know or use language API’s when it comes to data structures. Only to be aware that things won’t be EXACTLY the same for every language.

3/ CODING INTERVIEWS…need I say more?

If you’re looking to land a job as a developer, knowing this stuff may be essential!

I have recently been reading Cracking The Coding Interview by Gayle Laakmann McDowell. And after just a few pages it becomes clear that knowing this stuff is kind of important when it comes to getting a job.

You can bet your bottom dollar that some of the top tech companies such as Google, Facebook, Amazon, Microsoft, and Apple will expect you to know your data structures and algorithms. But not just know them, be able to code them by hand.

If you haven’t already heard of whiteboard interviews let me just fill you in. You are presented with a problem, and you have to code up the solution on a whiteboard. And all to often that problem will require data structure and algorithm knowledge.

Sounds scary right? And it’s not just the tech giants who employee these types of interviews. Other, smaller companies follow suit.

This is NOT to say that all software related interviews operate the same way; something even Gayle points out in her book. That said, it’s always better to be prepared!

Did that persuade you?

If not, ask yourself, do you want to MASTER programming? If your answer is yes? Then you know what you need to do. Learn this stuff. You will be better for it.

Data structures and algorithms are fundamental to programming, and fundamentals are very important. Fundamentals build the foundations and allow us to have a full understanding of a subject.

The BEST way to learn??? BUILD, TEAR DOWN, RE-BUILD, REPEAT!learning concept

When it comes to learning how to code the universal rule is to BUILD. That is not to say this is the ONLY way to learn.

You CAN learn by reading textbook after textbook, watching video after video; soaking up all the raw information you can. However, I find it really helpful to see the implementation in action, AND attempt to replicate it myself.

Personally, my advice is to make the whole process of learning to code an ACTIVE one. This means asking questions, research answers and most importantly figure things out. More than anything, I believe this will help the information stick.

Why? Because your brain is engaged, and you offer up 100% of your concentration in order to solve a problem.

This compared to something passive like watching a video. I don’t know about you, but sometimes I have a tenancy to drift off halfway through a video. I don’t feel 100% engaged as I do when I am actively coding and problem-solving.

So, if you’re looking to really understand this stuff I recommend building your own data structure and coding up some algorithms.

Building your own will force you to understand what is going on under the hood. By default, you will learn all you need to know about data structure.

But don’t just follow a tutorial, build it once, then move on. Instead, tear it down and repeat the process until you feel comfortable. I guarantee, each time you do this, things will start to make a little more sense. Till eventually it clicks!

Side note: It personally helps my understanding if I talk out loud through the process. So don’t be afraid to try this as well.

GUIDE to BUILDING a LINKED LIST 

Okay, so I said “build your own data structure”…but where do you even start? Which data structure should you build first?!

Well assuming you are still fairly new to the whole data structure thing, I would recommend a Linked List.

In my personal onion, a Linked List is a fairly beginner friendly data structures to implement. However, rather than just telling you to go away and build one. I wanted to provide some further guidance to help you get started.

Below is a quick guide, written in Java, showing you how to create your own Linked List. Again, with the consideration of a beginner, I chose to go with the simplicity of a Singly Linked List.

Although it’s written in Java, hopefully, it’s simplicity will make it easy to replicate in your preferred language.

But first, WHAT is a LINKED LIST?

Node diagram

A Linked List is known as a linear data structure, which basically means it’s a sequence!

It’s created using a series of  “objects”, which are linked together. Each object can be thought of as a “link”, and each link points to the next one in the list. Hence the name, Linked List.

Side note: If you don’t know about “objects” or object-oriented programming, check out this post: The ULTIMATE NOOB GUIDE to understanding Object Oriented Programming.

These link objects are often referred to as “nodes”, and the “LinkedList” object itself will hold the starting node, referred to as the “head”. The head kicks off the list by pointing to the next node, which will point to the next node, and so on and so forth.

To implement a Linked List we only need two classes, the “Node” class and the “LinkedList” class. But to avoid confusion with the inbuilt Java “LinkedList” class I recommend name it something slightly different. You will see I called mine “MyLinkedList”, not very original I know!

So…What’s a NODE?

A node isn’t too complicated, it simply an “object” with instance variables to hold a “value” and the “next” node (refer to the above diagram). The next node acts as the pointer to the next link in the list.

Because this is a Singly Linked List we only have the next node in order to move forward. If it were a Doubly Linked List we would also have a “previous” node. The previous node in a Doubly Linked List just allows the list to move backwards as well as forwards.

Creating the Node

Before I explained the code, I just want to say that I have used public instance variables rather than “getters” and “setters” to get and set instance values. This is NOT the ideal way to code as it doesn’t provide any protection to the integrity of the object. But if I’m honest, I’m cutting corners to keep things simple!

Just know that you SHOULD be using getters and setters.

Anyway, to the code. As you can see below, we just create a new class called “Node”, and add two instance variables, an integer called “value” and a Node called “nextLink”. It does not have to be an integer it can be any data type, it just has to sort a value. Be that a number, word or object.

Then we set the node object to “null”. By the way, I didn’t have to assign a value to the node, by default an empty variable is null. But it’s just to illustrate that the value should be set to null.

Finally, we create the constructor so when the object is initialized we can pass in the value we want to assign and store. Then the object is good to go!

 

Creating the List

Now, for the final class, the Linked List class itself.

Just create a new class and add an instance variable to hold the “head” node. Then initialize the head as “null” in the constructor.

As I said before the “head” node will be our reference to the head of the list, and point to the next item in the list, which will point to the next, and so on.

After that, we can start adding some methods to the Linked List class, which will enable us to add items, delete items, traverse (move) through the list, and find a particular value. You can see these methods below.

 

Adding to the List

First, we create a new node from the value we want to add.

Then we do a null test to see if the “head” of the list contains anything. If it doesn’t, then we are at the start of the list, and we simply assign the new node to the head of the list.

Otherwise, we add in the new node behind the current head node, then change the new node to the head of the list.

We achieve this by adding the current head into the new node’s next field, at which point we can reassign the head to equal the new node. So now the new node is the head of the list.

The thing to remember when you’re adding nodes this way is that you are not adding it on to the end of the list, but rather the start. This pushes all the other items along, making every new node the head of the list.

Here’s what that looks like…

 

Removing an item from the List

Lets start by create some holders for a current and previous position. The current node will be set as the head, and the previous node will be set as null.

Why do we need a current and previous node? Because later we are going to have to reassign the nodes in order to overwrite (delete) the specified node, while making sure the sequence of links are maintained.

Once the set up is done, we test the current value to see if it matches the value passed. If it does, all we need to do is reassign the head to the next node in the list. This overwrites the node with the next item, thus deleting it from the list.

Of course, if that statement returns false we are going to be looping through the nodes in the list to find the one we ARE looking for. This we do with a simple While loop; testing the current value to see if it matches the value passed.

If the current value does not match, it may be because it’s in the next node, which means we need to continue looping…OR it’s because we are at the end of the list, meaning the value does not EXIST!

So let see if it exist’s first, then we will continue looping if necessary.

To do this we test if the next node in the list is null. If it is, we are at the end of the list, meaning the item doesn’t exist! In which case, we print a statement and jump out of the method with a “return”.

Otherwise, we need to continue moving through the list and testing the next node in the sequence. To move through the list we simply reassign the previous to the current and the current to the next. Then, test all over again!

Once the While loop finishes we can be sure we have found the node to be deleted. So it’s another case of swapping values in order to delete the node.

Here’s what that looks like…

 
 
Traversing the List

This is a fairly straightforward method. We begin by creating a temporary node to work with and passing the value of the head node in.

Next, we test to see if the node i.e. head is null, which would indicate that the list is empty. If that’s true, we just want to print a statement to say “List is empty”.

If the test comes back false, we While loop through the nodes in the list, testing if they are NOT empty. As long as they are NOT, we can print out the value, then move to the next by reassigning the temporary node to the next node.

Simple! Here’s what that looks like…

 

Finding an item in the List

Again, let’s start by creating a temporary node to hold the head.

Next, we test! The first test we do is to see if the node, aka the head, is null. If it is, then there is nothing in the list and we jump down to the end and print a statement to say “List is empty”.

The next test is a While loop. We loop through and test the value passed against the value in the node. As long as they DON’T match, we continue looping.

Within this loop we do yet another test to see if the next node is null. This would indicate we are at the end of the list and didn’t find the item. In which event, we print out a statement, then jump out of the method with a “return” as we have done before.

As long as there is still another valid item we continue moving through the list the same way we have done in previous methods (by reassigning the node to the next node in the list).

Finally, when the condition of the loop is meet, we can safely assume the values match, meaning we found the item. So if you want you can print a statement and shout it from the rooftops!

Here’s what that looks like…

Other learning resources 

I created the above guide to serve as a beginners introduction. However, I have compiled a few further resources below, should you wish to learn more. As we speak I am compiling a larger list to put into a separate blog post. So stay tuned!

 Feature image Designed by Freepik

LEARN CODE from these 12 BRILLIANT Udemy Instructors

Shares

I am a big fan of the Udemy platform, it’s what opened the door for me to learn code. It’s such an accessible platform where you can pick up an amazing course for as little as £10. The only trouble is there’s TOO MUCH CHOICE! There are some brilliant Udemy instructors, and equally some not so brilliant. And while the financial loss isn’t that great the lose in time is! So to save you time and the hassle of weeding through instructors I have compiled a handy list.

I have been using Udemy for over a year now, and I have become familiar with a number of top instructors. Many of whom I personally have used. So, if your looking to take advantage of the Udemy platform to learn code here is my recommended list of top instructors to check out, in no particular order.

 

Tim Buchalka

Subjects: Java, Python, App Development
Specialties: Java & Android App Development

 

Tim brands himself as the Aussie Android Dev Guy and it shows. His Java and Android courses are brilliant! This I can personally attest to after completing his Java Masterclass course. There are tons of detailed explanations and hours upon hours of content. With more always being added and updated. His courses also teach you best practices to help you write clean code.

Tim is a greatly experienced Java, Python, and Android programmer, with 30+ years under his belt. He’s greatly skilled at explaining complex topics in a way that a beginner can understand. And if you are a fan of projects and coding challenges like I am, Tim has got you covered.

Should you happen to get stuck along the way you will be happy to know that Tim is always there with a speedy response.

 As a side note, Tim has recently launched his Learn Programming Academy on Udemy. This academy has pulled together some expert instructors to bring you courses on a wider range of topics such as Game Development, Ruby, Xamarin, Ethical Hacking, Data Structure and Algorithms and more.

Student Review:

“Really well put together course. Coming from Java masterclass I am already a fan of Tim’s courses. Really excited about the learning academy set up and looking forward to taking more courses by Tim. He’s a great instructor, replies to questions within a days time and keeps his content updated.” – Abubakar Khan

4.6 Average Rating
43712 Reviews
215633 Students
5 Courses

 

Brad Hussey

Subjects: Web Design & Development, WordPress Theme & Plugin development, Sass, PHP
Specialty: Web Design & Development

 

Brad is a freelance Web Designer, Developer, Blogger, and Entrepreneur. Plus, he’s also a really refreshing and engaging Udemy instructor.

Many of his students have praised his style. Brad tries to keep things light and entertaining while teaching you complex concepts in a simple manner.

His courses are a bit different from some of the other Web Developers on this list as he also teaches you design. Brad’s Web Designer & Developer course will teach you HTML, CSS, JavaScript and other development technologies. But you will also learn Photoshop so you can create the designs for your very own website.

Brad also aim to support your career development by imparting his wisdom gained as a freelancer to help you become a professional. And as the same with all these instructors, Brad is ready and raring to support you in the Q&A section.

Student Review:

“I have taken a few courses on coding, but in my opinion this has been the best.

Brad is a very engaging teacher, he gets to the important points about each topic and has cleared up lots of issues that I have had since learning to code.

He is obviously a dedicated teacher and I can tell from the contents of the course that he has made an extensive effort to include as much as he can on aspects of coding.

Since starting this course my coding skills have developed immensely. I have gone from creating my own basic web page to designing and coding fully functioning websites.

I will continue to keep an eye out for other courses by Brad to further develop my web coding skills.” – Sarah Anne Buttery

4.5 Average Rating
25233 Reviews
281315 Students
10 Courses

 

Maximilian Schwarzmüller

Subjects: Web Development Frameworks & Technologies
Specialties: React, Vue.js, Angular

 

Max is a great instructor and self-taught professional programmer so understands the difficulties for his students and is always there to help. Also like many other great instructors on this list, he has a real focus on learning by doing. So you don’t passively sit back and watch!

Most of his courses do have a prerequisite of some basic Web Development knowledge such as HTML, CSS, and JavaScript. However, that is to be expected when you want to learn JavaScript frameworks.

If you do already have some knowledge of Web Development and want to learn the latest technologies and frameworks like React, Vue.js, Angular, then check out his courses.

I personally was very interested to see that he had a course on Progressive Web Apps as it’s a subject I would love to learn. But it also goes to shows that he’s here to bring you some of the latest and trending topics.

Student Review:

“The best way of learning is through learning from examples, and this course has lots of examples to demonstrate how a method works and it doesn’t work. Would want to recommend to people who are interested in Angular to try it out. I have benefited so much from Max and have started with his another course, Angular Styling & Animations. BIG thanks to Max.” – Simon Low

4.7 Average Rating
65202 Reviews
195337 Students
18 Courses

 

Mark Price & Devslopes

Subjects: Web Development, Game Development, Mobile App Development, Design, React, Angular, API Development
Specialties: Apple software, iOS App Development and UX/UI

 

Mark is a great instructor for varying reasons. For one, his courses are fun and interesting! No chance of falling asleep or being bored stiff. But in addition to being engaging, they teach you the essentials of each topic.

I have personally used his courses and have found them really helpful, with a great approach for beginners. He focuses on what you need to know, and keeps you engaged by building interesting apps that also look good! The concepts are simply explained, which makes them very accessible.

His approach is greatly career orientated, aiming to equipt you with real-world professional developer skills. You get a good idea of how the pro’s approach development. Plus you learn best practices of the trade to prepare you for a career.

As an added bonus, Mark’s courses come with access to a large community of developers, where you can receive support and network.

Mark and the Devslopes team have a great selection of courses on varying subjects. But if you’re particularly interested in developing software for Apple products then I highly recommend Mark and Devslopes.

They have a number of dedicated courses on iOS Development, plus courses on macOS and tvOS. Also, if you head over to their website, Devslopes.com, you will find a whole lot more, including watchOS, iOS Face ID and how to integrate Siri into your apps. Devslopes aim is to give you the skills you need to work as a professional developer or launch your own business.

Student Review:

“I’ve done Mark’s courses before, so I knew he was an excellent teacher, but this course so far surpasses even his own excellent past courses – it seems much more focused, goal oriented and clearly structured besides being easily understandable with actual working apps being built even while learning programming concepts. I learned a lot previously, but this time it looks like I have a clear path of progression through the course.

Having completed half of the course material, I’m very excited about putting to good use all the things I have learned. The additional teachers in this course, JonnyB and Caleb, are also excellent, and the course material is very up-to-date. I especially like how they add new content frequently to ensure that everything is consistent with the latest coding practice. ” – Minni K. Ang

 4.5 Average Rating
32252 Reviews
239857 Students
20 Courses

 

Jose Portilla

Subjects: Python, Scala, SQL, Big Data, Machine Learning, Deep Learning, Web Development
Specialty: Python

 

I am just going to dive in and say that if you are interested in Python, and all the different things you can do with it, then Jose may be your guy!

Jose is a Data Scientist, who has a great number of courses built around the Python language. His most popular is designed to take you from zero to Python hero. In addition, he has a ton of other courses built around Python and what you can do with it.

To name a few, he has courses on Python for Web Development, Big Data, Machine Learning, Financial Analysis and Algorithmic Trading, and more!

As for his approach, Jose is another great instructor who provides an interactive experience. Complete with quizzes, tests, and homework assignments and projects. And he is always available to provide support should you get stuck at any point.

He is also another one who is great at keeping his courses up to date.

If you’re interested in Python or already know some Python but want to expand your skills then Jose is one to remember. Many students highly recommend his courses.

Student Review:

“Jose Portilla is a really experienced, pedagogue and articulate teacher, his materials are more than enough to give you the basics of the course. He is also aware that maybe some of the students are familiar with Python, no worries, he manages to include them as well in the course, he offers direction of research to widen your knowledge.

I can’t thank him enough and I recommend him without hesitation.” –  Azeddine Rachih

4.5 Average Rating
78966 Reviews
366606 Students
13 Courses

 

Jonas Schmedtmann

Subjects: HTML, CSS, Javascript, Sass
Specialties: Front-End Web Development, JavaScript, CSS and Sass

 

Jonas is a Web Developer, popular Udemy instructor, and a brilliant choice if you want to learn how to make beautiful websites or become an advanced JavaScript programmer.

In addition to building real-world projects, his courses utilize challenges and exams to keep you engaged and test your knowledge.

Jonas prides himself on providing “fast and friendly support” so you don’t feel like you are left in the dark.

Many people really praise his Advanced CSS & Saas course, along with his Complete JavaScript course. So, if your passionate about learning JavaScript or building beautiful websites with advance topics then Jonas may be the Udemy instructor for you.

Student Review:

“Amazing course! It’s great teacher and teach step by step from very beginning. At the end I was completely able to fully understand JavaScript. I have no words to say how thanks I’m for such nice explanations.” – Airton Esmerio

4.6 Average Rating
29879 Reviews
240453 Students
4 Courses

 

Rob Percival

Subjects: Web Development, Mobile App Development
Specialty: Web Development

 

You may already be aware of Rob as he is probably one of the most well know programming instructors on Udemy with a massive user base already. Certainly the highest on this list.

Although a large number of students does not necessarily guarantee quality, I can personally assure you that Rob’s is a great instructor.

Rob comes from a teaching background and has a real knack for easing beginners into the world of programming. His courses are hugely interactive, which is something I always look for. I’ve enjoyed his quizzes, challenges and a range of projects.

Rob has a hugely popular Web Development course, which will teach you everything you need to know to create amazing websites but also HTML based mobile apps, which I thought was unique.

In addition to his Web Development course, he has courses for both Android and iOS App Development, which he is very good at keeping up to date. In fact, he recently updated his iOS course and has re-released his Android course to include Android Oreo.

I personally enrolled on his Android Developer course and have really enjoyed the content as well as the hands-on support from Rob in the Q&A section. I got stuck a lot! So thanks Rob!

Student Review:

“Excellent! When I took this course, I knew next to nothing about Web Developing. In less than three weeks, I had quite a good understanding of basic and not-so-basic concepts on how to make a website. Rob is an excellent teacher, I liked the rhythm of the course, and especially the challenges: not too easy, not too hard, but you are required to do certain things on your own to complete them (and if you can’t, you just go ahead let Rob tell you how). I strongly advise this course to everyone who wants to become a Web Developer from scratch.” – Nicolas Porreca

4.6 Average Rating
94442 Reviews
470984 Students
22 Courses

 

Angela Yu

Subjects: Swift, iOS App Development
Specialty: iOS App Development

 

At the time of writing this post, Angela may not have as may students, reviews or courses, compared to the some of the other instructors on this list. However, saying that, she still has a great number of students and reviews. But the point I am trying to make is stats aren’t everything.

I have included Angela because of high quality and hugely popular iOS 11 & Swift 4 bootcamp course. Here is another instructor perfect for someone interested in iOS App Development.

She has received great praise for her explanations and ability to teach the topic. Angela has hands-on experience as a bootcamp teacher for the London App Brewery. So by taking her courses, you can feel like you are receiving the bootcamp treatment.

You will get a full experience with Angela, filled with projects and great community support.

Student Review:

“This is a truly fantastic course; it vastly exceeded my expectations in every way. I have done a lot of self-study and guided study over the years, and I can say without hesitation that this has got to be the best approach available for quickly learning iOS development. The content is current, relevant, and well developed.

Angela does a beautiful job of explaining and demonstrating all of the concepts, complete with sample code, brilliant challenges, and animated slides for visual aid. She has also somehow managed to update the material and sample project code at pace with the rapidly changing new releases of Xcode, iOS and macOS. Every time I got stuck there was already an answer in the Q&A section. This course is an incredible value, and I highly recommend it for anyone interested in mobile app development, regardless of experience level.” – Mike Thompson

4.8 Average Rating
7686 Reviews
43049 Students
3 Courses

 

Ben Tristem

Subjects: C++, C#, Game Development, Unity, Unreal
Specialty: Game Development

 

For those with dreams about becoming a Games Developer, you may be interested to know about Ben Tristem. All of his courses are centered around Game Development with his focus on “teaching code the fun way. By making games”.

Brilliant, more courses where you actually make stuff. And that’s not sarcasm by the way.

His courses teach you how to make mobile games with Unity and C#, or more powerful games with the Unreal engine and C++.

While you learn about Game Development you will also learn about languages such as C# and C++ as they are covered in the course (so beginners, don’t need to worry about zero experience!). Plus, once you are done you can transfer your knowledge of these languages to other areas should you wish.

The subjects taught can sometimes be difficult to grasp but Ben’s courses are very beginner friendly. Plus he is always available to respond to questions if you get stuck. So if you want someone to ease you into the complex, Ben is a great choice.

Student Review:

“Amazing course. I recommend it highly. I learned c# and made some cool games. Already bought his newer course on this and will happily sit through another 50+ hours learning from this dude. Thanks for taking this seriously and helping everyone reach their goals/ giving everyone a place to start.

The community is very helpful as well (in their discussion boards).” – Christopher Ortega

4.7 Average Rating
52544 Reviews
283768 Students
5 Courses

 

Colt Steele

Subjects: Web Development, SQL & Databases
Specialty: Full Stack Web Development

 

Colt is here to bring the bootcamp experience for aspiring Full Stack Web Developers.

As a bootcamp instructor, Colt is trying to bring his classroom lessons to the online community. His courses bundle a variety of key technologies and languages together so you get a complete experience.

For those interested in becoming a Web Developer, or ever a better Web Developer, Colt needs to be on your radar! He has 3 very successful courses, which he has put a lot of care and attention into. Quality vs Quantity all the way!

So many people have personally recommended him to anyone looking to break into Full Stack Web Development. In fact, I’ve even bought his Web Developer Bootcamp course, and although I am still working through it, I feel more than happy to personally recommend him as well.

Simply, the content is great and his support is great.

Student Review:

“Colt is an amazing teacher. It is very rare to come across a person who has incredible knowledge of the subject and yet has the exceptional skill to communicate it effectively. The greatness of a teacher is one who makes even complex concepts look simple. Colt possesses all these traits and this is what makes him stand apart.

The course is very lucid, easy to follow and the real world app is created from scratch as Colt leads students by the hand. It has been an incredible learning journey and I thank Colt and his assistants Ian and Zarko for all their help. If you are a newbie or even an intermediate level programmer, get this course PERIOD. You will not regret it one bit. Thanks all!” – Ravi

4.7 Average Rating
52432 Reviews
225155 Students
3 Courses

 

Stephen Grider

Subjects: GOLang, JavaScript, React, Redux, MongoDB and other Web Technologies
Specialty: React

 

Stephen is another notable instructor for those with some existing programming experience. Many people really enjoying his courses, which he has created to share his Web Development knowledge with other Software Engineers and Programmers.

Many of his courses focus on the trending technologies such as React with Redux, plus a great selection of others.

If you’re a beginner looking to learn code you may want to come back to Stephen’s courses later as many require previous knowledge. However, you don’t need to be an expert, just some basic knowledge of HMTL, CSS, and JavaScript and you should be fine.

So if you’re looking to level up your skills with the latest and greatest tech then he is a great choice.

Student Review:

“Probably one of the best online courses to learn ReactJs. Stephen is a very good teacher, his explanations are simple and clear and the curve of difficulty of the course is coherent for effective knowledge.” – Michaël Louis-Jean

4.7 Average Rating
60772 Reviews
143524 Students
15 Courses

 

Mosh Hamedani

Subjects: C#, Xamarin, ASP.NET, MVC 5, Angular and Redux
Specialties: C# and .NET

 

Mosh has a selection of courses targeting both beginners as well as those with experience.

A complete beginner can hop in and start learning the basics of C# and programming. Then soon progress through to his more intermediate and advanced C# courses.

Equally, those with some experience, interested in ASP.NET, Xamarin or Angular, and Redux, will find value in his courses.

Mosh has received a great deal of positive feedback from his students who feel his courses are very well structured, well explained and well delivered.

Aside from producing courses on Udemy, Mosh is also the author of a #1 raking course on Pluralsight (Become a Full-stack .NET Developer).

Student Review:

“The content is explained in a very simple way. Ideal speed and presentation for a beginner. I highly recommend this course to beginners in c sharp programming.The best part is the Exercises and quizzes.The exercises help you analyze and validate the knowledge gained.This beginner course has given me confidence and motivation to move onto the Intermediate course . Hoping that would be fun to learn as well.” – Harshad Pandit

 4.6 Average Rating
57771 Reviews
162400 Students
18 Courses

 

Conclusion

These are just a FEW great programming instructors on Udemy. There are undoubtedly many more who may deserve to be on this list.

However, I have tried to be selective so I don’t overwhelm the list. This also allows me to narrow down your choices with specialist instructors for certain topics. The idea is this will hopefully make the choice of instructor easier for those who already know want they want to learn.

Whenever you are to pick a course on Udemy there are a few factors you need to consider before your purchase. Here’s a little checklist to help.

5 things to consider about an instructor when buying a course on Udemy 

  • Are they responsive to comments?
  • Do they regularly update their courses?
  • Have they received a high rate of positive feedback from a reasonable number of reviews?
  • What do the reviews say?
  • Are their courses interactive i.e. project based, quizes, challenges etc?

I recommend factoring in these questions whenever you’re picking a course on Udemy. And just so you know, all the above instructors ticked every box!

The next problem is figuring out what to learn! But I’ve also got a post to help with that as well. So are you struggling to choose your first programming language?

 

Feature image Designed by Freepik

Professional programmer engineer writing code - Designed by Freepik

9 MISTAKES beginners make when learning code

Shares

We are all human and we all make mistakes, including me. I personally know just how easy it is to fall into traps when learning code. To avoid others making some of the same mistakes I did I decided to compile a list of some of the top mistakes commonly made while attempting to teach yourself code.

Let’s begin with an example of what NOT to do when learning code, demonstrated by my good self. And just to note, these are in no particular order.

1/ Trying to learning everything at once  

Web development illustration - Designed by Freepik

Software development is a vast sea of information. There are tons of programming languages, frameworks, libraries, and API’s already out there. Plus new stuff is always being added to the mix. Personally I think it’s impossible to know absolutely “everything”. But we try anyway!

There will always be more to learn so as an aspiring programmer, you need to be comfortable with the idea of being a lifelong learner. You will have your whole career to try and master many different langues so don’t worry about trying to do it now.

Instead focus on one area of development and attempt to master all the skills necessary for that.

Besides it being a nigh on impossible to become the fountain of all knowledge, I believe trying to learn everything at once is detrimental for 3 main reasons.

3 reasons why trying to learn everything is bad for beginners

  1. Causes confusion – At the start, you are going to be confused enough without adding extra layers. To minimize the initial confusion it just makes sense to try and keep things as simple as possible. So that means sticking to one area or language at the start of your journey.
  2. Disrupts your learning –  Learning multiple things at once mean you have to switch between subjects. This means putting one subject on hold while you are learning another. Depending on the gap between your switch in subjects, you may find yourself forgetting what was covered in your last lesson.
  3. Slows you down – It doesn’t take a genius to realize that if your getting stuck and your learning is being disturbed, it may slow the whole process down!

Hopefully, now you can see why trying to learn everything at once isn’t very practical. And to be honest, you don’t need to know “everything”.

For example, you don’t need to know every back-end language when one can achieve the same outcome as the other.

Even when you look at the job market there is no generic role that requires a broad base knowledge of everything. A job normally focuses on a handful of languages and frameworks. And these are centered around a particular role or even language. E.g. Web Developer, .Net Developer, Android App Developer, Java Developer, so on a so forth.

I am not saying this to stunt your thirst for knowledge, but elevate any anxieties you have due to the notion that you need to know everything!

2/ Not coding along 

It’s really important that you code along with video tutorials every chance you get. Even if the instructor is just coding up a simple example to illustrate a concept.

You may think sitting back and watching is enough to absorb the information. But you will gain so much more from physically writing the code yourself. As strange as it sounds you need to build muscle memory!

The truth is at the start, writing code DOES NOT feel natural, it feels slow and clunky. It’s like riding a bike, you can’t quite get your balance.

But like riding a bike, once you’ve been pedaling around for while you start to get the hang of it. Then in no time, it feels as natural as walking.

The same applies to learning code. That’s why it’s so important that you don’t cheat yourself by passively watching tutorials. Any chance you get to code, even copying tutorials will help build your muscle memory.

3/ Waiting to become an expert before diving in

Leader standing on big winner golden cup - Designed by FreepikDo you ever find yourself thinking, “I can’t wait till I finish this course so I can start making cool apps”. This was defiantly me!

This is an easy mistake to make, and in my mind, it’s the result of two things. One, the misconception that you need to be a genius to be a programmer. And two, beginners don’t have a lot of coding confidence.

If you doubt your intelligence like I did, then, of course, your going to have low confidence. When your confidence is low you end up shifting your goals further away. You convince yourself that you need to improve a whole lot more before you can ever hope to make your first app. But that’s not the case.

When can I start building my first project?

The short answer. NOW. By diving in as soon as possible you will learn more and gain confidence quickly.

I mentioned beginners don’t have a lot of confidence. Well, what’s a good way to build confidence? BY DOING! And what’s the best way to learn something? BY DOING! So, what do you need to do? START DOING.

Personally, I think one of the best things you can do when learning code is to build your own projects. You will be surprised how quickly you can start doing this.

You don’t have to be big complex projects. They can be small ones, designed merely to demonstrate what you have learnt. But the point is to start diving in as soon as you can.

Sure, use books and courses to learn the basic’s but don’t be afraid to get stuck in, even if you think you’re not ready. Otherwise you may get stuck in a loop of learning but never doing.

When I first started I didn’t have a lot of coding confidence so I waited before dipping my toe in. And I really wish I hadn’t!

Looking back now I realize I was more than ready and could have started way sooner. Luckily I realized the error of my ways and began “doing”. As soon as I did I saw the benefits.

Building stuff and taking a practical approach is so valuable because it not only builds confidence but helps cement what you have been taught.

You will soon build yourself into a cycle of elevating your ambitions with each step in your knowledge and confidence. Yeah sure, it’s going to be hard and you’re going to stumble. However, if you persist you will find the answers, and it will benefit you immensely in the long run!

4/ Giving up just before it “clicks”

This is a fatal and obvious mistake and is the main reason your programming dreams constantly slip through your figures. But again, I am here to say your not alone.

You may already know that I had a few failed attempts at learning code in the past. I always bombed out before things really started to “click”. Little did I know each time I was on the cusp of things at last making sense. Had I pushed on a little more I would have broken through the wall, and into a world where I finally “got it”.

I can pretty much say with 99.9999% certainty, that every beginner will or has faced a brick wall. A point where throwing your laptop out the window seems like a completely rational solution.

If your lucky enough never to have had this, then I applaud you. However, it’s more than likely that your day has yet come. And when it does, remember, don’t give up!

I think in order to learn programming you need to have a lot of patience. Because it is challenging and you will get a lot of errors and bugs in your code. It’s just part and parcel of becoming a programmer.

I am sure even experienced programmers will tell you that they still get errors and bugs. So know your not alone when you run into your first wall.

When you conquered your first wall, then you know you’re a real programmer because programmers are problem solvers.

5/ Leaving gaps in your learning

One factor that was crucial to me learn code was my mantra of “code every day”. As a beginner, you are in danger of falling off the wagon the moment you start leaving gaps in your learning. This was one of the reasons my first few attempts crashed and burned.

Let us say you are in the middle of a Java course, learning about Object Oriented Programming, and you decide to take a few days off. What happens?

Well, more than likely you come back to your lessons on Encapsulation to realize you can’t quite remember what Encapsulation is! So what do you do? You repeat the previous lessons.

As a result, you end up moving backward rather than forwards and it’s just frustrating.

Of course, this is just an example. However, I use it to illustrate the point that you’re in danger of what I call “short-term amnesia”. For things to really cement in the brain they have to be implemented.

The mentality of coding every day also helps turn the act of coding into a habit.

When something is a habit it becomes natural. We can carry it out on autopilot because it’s built into the routine of our lives. And this is something I have talked about at length in my post How to create the PERFECT ROUTINE to learn CODE.

6/ Attempting to memorize code

Educational infographic - Designed by Freepik

During my early days, I adopted this strategy. However, experience has taught me that this was a mistake. You would have thought by memorizing everything bit of code you would become the ultimate programmer. But no.

The problem with this approach is you end up with a lack of fundamental understanding.

To paint a picture, it’s like memorizing the words of a foreign language, without knowing what the words mean. Since you have no understanding of their meaning you can’t properly hold a conversation. Every time the other person responds your only hope is to smile, nod, and pray that they don’t notice the vacant expression on your face.

You will also find this path is very time to consuming. In fact, it’s futile because there is simply no way to memorize hundreds of lines of code.

Luckily we live in a world of Google and platforms like Stack Overflow, which can act as the ultimate quick reference guide. Although, you may ask yourself, “isn’t that cheating?”.

Well….no. Searching the internet for answers is not cheating, it’s just part and parcel of the job nowadays. In fact, one of my instructors once told me that programmers are expert Google’s.

Although, I would advise AGAINST blindly copying and pasting code without understanding it, or taking the time to understand it. In this scenario, you are only cheating yourself. You’re missing a perfect opportunity to learn and grown.

It’s fine to use code form the internet, but read it, work with it, and test it, until you understand it. At the end of this process, you will have learned something new. And that will be more valuable to you than just copying pasting code.

7/ Ignoring the importance of clean readable code

For a beginner, the emphasis tends to be on getting your code to actually work. Therefore it’s kind of understandable that the importance of clean code is missed.

I have to be honest when I first started I would write patched up code with no real thought for readability. I didn’t care as long as it was working. Rookie mistake! It’s so important to write clean readable code.

There are a few of very good reason, both personal and professional. However, it all boils down making your code user-friendly.

You may think it doesn’t matter so much when it’s your own code. But let me ask you a very important question, how good is your memory?

There have been a number of times in the past where I have looked back nostalgically over my first lines of code. Only to ask myself, “what the hell is this!”. I would genuinely struggle to read and understand what I had written.

You have to consider that if you’re struggling to read your own code after a few months, others may find it impossible. As a result, you probably won’t win any popularity contests among your co-worker. Think how much time could be wasted and aggro caused because no one can understand what you wrote.

Be considerate of yourself and other and KEEP YOUR CODE CLEAN.

If you need some guidance on writing clean code, Robert C. Martin wrote a brilliant book called “Clean Code: A Handbook of Agile Software Craftsmanship”. That will teach you everything you need to know.

8/ Not testing your code as you go 

background of icons and list of elements in flat design - Designed by Freepik

This is more of a tip than a fatal mistake, but I wanted to share it with you to save you a few headaches.

At the start, I had a stupid assumption that my code would just work as intended. Of course, that is never the case! I was also ignorant of the fact that more code means more places for bugs to hide.

If you deiced to wait until the very last moment to run your code you may be met with a ton of pesky bugs. Then you have the lovely job of trying to deciphering what’s gone wrong, and more importantly WHERE.

Granted, it may not be all that stress-inducing when you have a few lines of code. But with increasing complexity, I am sure you will begin to regret your decision.

Do yourself a favor, and test your code as you go. It will save you time, stress and a whole lot of headaches. It’s a good habit to get into anyway so you might as well start now.

9/ Sweeping bugs under the carpet

In the beginning, it’s very tempting to ignore errors and move onto your next lesson, especially when you’ve been stuck on the same problem for days.

But remember, bugs will always come back to bit you in the butt! 

What do I mean by this? Well, if you are blind to your mistakes, then you’re doomed to repeat them. Because you don’t know where you have gone wrong, you can’t hope to avoid making the same mistake in the future.

Ignorance is bliss they say, but not in the case of errors and bugs. The problems won’t go anywhere unless you fix them. And you need to fix them in order to improve and become the best programmer you can be.

You can’t run forever so you might as well deal with the problems there and then.

Debugging is also an important skill as a programmer and the only way you will get better is by crushing bugs!

At the end of the day, the aim is to release bug-free software. Nobody wants an app filled with errors and bugs that crashes every 5 seconds. And nobody wants to hire the programmer who makes such apps.

Summary

I am sure there are plenty of other mistakes that beginners make, including myself. But these are just some of the main ones I wanted you to be aware of.

If you have suggestions for other mistakes you feel beginners would really benefit from, then please feel free to let me know so I can add it to this article. Beginners are stronger together. And as always, thank you for reading.

Feature image designed by Freepik

Designed by Graphiqastock

The ULTIMATE NOOB GUIDE to understanding Object Oriented Programming

Shares

I started my programming journey learning the wonderful language of JAVA, which is known as an Object Oriented programming language, sometimes seen as OOP. Object Orientated programming is everywhere! Tons of other languages are Object Oriented, like Python, JavaScript, C++, C#, Ruby, the list goes on. So WHAT exactly is it? And HOW is it used? Well, this post aims to provide a solid foundation of Object Oriented programming presented in an easy to understand way. So that even a complete beginner can get it.

Just a quick note before we start. I will include coded examples in this post, but I have written them in Java. So please be aware that other Object Oriented programming languages won’t look exactly the same as these examples. However, I feel it is important to include examples because the principals are the same, and it will still give you a good idea of how Object Oriented Programming works.

Background vector created by Blossomstar - Freepik.com

Let’s start with a little introduction to Object Oriented Programming

Object Oriented Programming is centered around the creation and use of virtual objects i.e. objects that don’t exist in the real world. These objects can be thought of in that same way as any other real-world objects.

Now, there are two major characteristics of objects, which are fundamental to OOP. And they are Attributes and Behaviors.

Attributes – The physical makeup and state of the object. For example, a car HAS wheels, doors, an engine, a steering wheel etc.

Behaviors  – The actions that an object can perform. Again, with the car example, a car CAN accelerate, brake, turn etc.

Simply, think of what an object “HAS”, and what it “CAN” do.

In programming speak, we refer to attributes as an object’s variables, and behaviors as an object’s methods. Don’t worry, I will explain if you need me to!

If you have already had a taste of programming you may already be aware of what variables and methods are. And if that’s the case you can skip to the next section.

But for those who are not sure, here is a quick crash course.

What are variables?

To summarize, a variable is a container to store useful information. This could be a number, letter, word, sentence, true or false statement (referred to as a “Boolean”), or even another object! But for now, don’t worry about other objects, we’re going to keep it simple!

And for the purpose of simplicity, we are going to say that we have a variable called “Name” and we want to store the word “Owen” in it. Well, it’s as easy as saying:

Name = Owen

Now the variable called “Name” stores and represents the value of “Owen”. For the record, this is not written in a programming syntax i.e. code speak. It’s only to illustrate the basic point. But in case you were wondering, here is what that would look like written in Java:

Three things to mention:

  1.  The semicolon, this weird thing “;” at the end, just denotes the end of a statement. Kind of the same way we use a “.” at the end of a sentence. However, not all languages use them. For example, Python doesn’t.
  2. The word String refers to the data type, which lets the variable know what type of data we want to store. A type of data could be a letter, word, true or false, number, or decimal. In this example String means a word, so we want to store a word in the variable “Owen”.
  3. Because the variable is of type String we have to surround the value, “Owen”, in quotes. This does not need to be done with any other data type.

For reference the common types are:

  • int – stores a number
  • float = stores a decimal commonly called a floating point number
  • boolean – stores a “true” or “false” value
  • char – stores a letter i.e. a character
  • string – stores a word or string of words

In relation to objects, we create object variables, known as member variables to store data. These member variables tell us specifics about what the object HAS. Variables need to be unique so that the specific data contained can then be retrieved, displayed and manipulated by methods, which brings us to the next question…

What is a method?

At its basic level, a method is a series of steps outlined in an object, which tells said object e.g. a car, to do a certain thing e.g. drive.

These steps are all neatly packaged in a contained block of code, normally represented by “{}”. It’s this block of code that tells the object to stop being lazy and DO SOMETHING! But before we can tell it to do something we need to be able to reference it, so like a variable we give it a name.

At a rudimentary level, you can imagine if we had a method named “turnEngineOn”, designed to, can you guess? Yes, turn the engine on. It may resemble something like this:

* The text after “*” is just a comment added for context.

turnEngineOn      *this is the name of the method
{
Turn the car engine on      *this is the code that makes the object “do something”
}      

A few things to note here:

  1. Again, this is not programming syntax, it’s just for visual representation.
  2. The name looks weird because it is written in what’s called “CamelCase”, which is the generally accepted way to write a method for readability.
  3. I have surrounded “Turn car engine on”, these bad boys”{}”, because typically blocks of code in methods are contained within curly brackets.

There is more to a method than this, but it illustrates the basic structure. However, below I have tried to give the full picture, and I have done my best to keep it simple!

Generally speaking, a method will have 4 main parts; a name, parameters, body, and a possible return value.

Name – The same way a variable need a name, a method also needs a name. This allows us to refer to that specific method in the object to say “we want the object to do this”. Typically this is known as “calling a method”.

Parameters – It’s a fancy way to say brackets, you know these things “( )”, the normal none curly ones. Parameters follow the name, and are the location where you pass data in the form of variables to your method, should it require it.

A method may not need any data. For example, if the method is updating, or setting the value of an objects member variable e.g. changing our “Name” variable from earlier to equal “Tim” instead of “Owen”, then the parameters may be empty. Parameters tend to be used to interact with another object or to use external data in the methods step by step instructions.

Body – The body follows the parameters and is that block of code surrounded by “{}”, which I mentioned earlier. This is the powerhouse, those series of operations, which result in your object doing something.

Return value – Your method may return a value, for example, a number, text or even an object. This just means your method will spit out some form of result once it reaches the last step. It’s like being handed all the ingredients to make an apple pie, making it, and handing it back. However, methods don’t always have a return value. If your method performs a calculation or creates something meaningful, which you need somewhere else in your program, then a return is necessary.

For reference here is an example of a simple method called “returnMyName” written in Java:

Let’s break this method down…

  1. First, we have the word “public”, don’t worry too much about this now. “Public” is a keyword know as an “Access Modifier”, which we will cover later in this post.
  2. Second, we have the word “String”. This is where we specify the data type to return. And as we want to return the variable “myName”, which is a String, we put “String” after “public”. If we don’t want to return anything we can add “void” instead of “String”.
  3. Next up we have the name, which is pretty self-explanatory and as you can see demonstrates camel case, which we have already covered.
  4. After that, we have the parameters i.e. brackets…these things “()”. As you can see they are empty, and that’s because we don’t need to pass any outside data to this method. Although we could have. And in fact, I could have written: “(String name)”. So rather than setting “myName = Owen;”, I could have put “myName = name;”. This would have taken whatever word was set as “name” in the parameters and put it into the variable, “myName”.
  5. And finally, in the body we set the variable value, then use the keyword “return” to say we want to return the String “myName”.

Background vector created by Blossomstar - Freepik.comBack to Object-Oriented Programming with some quick terminology 

I am sure you are probably interested to see what an object actually looks like when it’s written in code, and how it all works. And I promise I have examples so you can fully understand. But there are a few basics terminologies we need to cover first just so you are not completely confused like I was!

Those few things are “Classes”, “Constructors”, “Declaration”, “Instantiation”, “Initialization”, and “Instances”. I know they sound scary but don’t worry. Here’s another little crash course to give you a basic understanding.

Classes

A class is essentially a file that holds the blueprint for building an object. It includes a description of how the object should look (attributes) and behave (methods), plus instruction on how to build it (the constructor). You wouldn’t build a house without first having a blueprint, and the same applies to objects. Therefore every object will first start its life as a class. You will see full examples of a class at work later, but for now here a little taster:

First, we specify that we are creating a class using the word “class”, then we give the class a name. Again, dont worry about the word “public” we will get to that when we talk about Encapsulation. It sounds scary, but it’s not.

Constructors

We have the class, aka the blueprint, but how does an object actually get built? Well, that’s the job of the constructor.  This little guy is a method, which set the values of an objects member variables (attributes), which describe the object so that it can come into being. The constructor specifies the information it needs, then applies it.

As I said, the constructor is a method so it looks very similar. The main difference is that it shares the name of the class. So this example will be the constructor for the class, “Person”.

Here’s the example:

As you can see the parameters, aka “()” are populated with variables. These variables get passed to the body, i.e. the code between “{}”. At which point they are used to set the member variables of the object upon creation. This essentially brings the object to life.

Declaration

The first step to actually bringing an object into life, metaphorically speaking, is to “declare” it. Basically announcing to the world, or more importantly the program, what class we want to create our object from this class, then give it a name. For example, we have a class called “Car”, so we want to first announce that we are creating a Car object, which we are then going to name Tesla Model X.

Instantiation

Once we have declared the type and name of object we wish to create, we need to get the ball rolling by letting the program know that we are creating a completely NEW object. This is normally done simply by writing the keyword word “new” and it’s what programmers mean when they say “instantiate”. Basically, just start creating this new object. And here’s an example:

Initialization

After we’ve said we want to build a “new” object, we need to supply any information, which may have been requested by the constructor of the class. For example, in the contractor of our Car class, may have asked for the number of wheels, number of doors, colour of the car etc. This information get’s added into parameters (brackets) and is passed into the constructor so it has all the information to build the object. Here’s an example, assuming the car has 4 wheels, 5 doors and is black.

*Because the colour is of type String we put “” around it. However, we don’t have to do this with any other data types.

Instances

Once an object has been created we can now refer to it as an “instance”. This is a single reference to a unique object. To put this a better way, you can have several car objects, one called “Mustang”, one called “Model X”, and one called “Porsche”. Each of those is a single INSTANCE of a car object.

Example time – What does an OBJECT look like in actual code?

So the idea of an object is pretty straightforward, it CAN do certain things, and it HAS certain things. But how does this all translate into real code? Well, I have created some examples below, with explanations to help you understand.

I am aware that I’ve used a lot of car examples! So to switch things up I’m going to imagine that I’m creating a game, in which I am going to need to create a “Player” object.

This will be a very simple example just to illustrate the concepts and structure of an object. If you get stuck I suggest going back and looking at some of the previous explanations and examples.

We create an object in 2 steps, first we create our blueprint and then we construct it.

Step 1

The first step is to create a “Player” class, and hopefully, now you know what a class is.

Context for above code:

  1. We define our Player class using “public class Player{}”.
  2. We move into the curly brackets and specify all the member variables (attributes) of the Player class i.e. name, health, weapon.
  3. We create our constructor and mention the variables we want to pass through the parameters “()”, in order to set the objects member variables. Remember the objects member variables are denoted using “this.”. See above section on what a constructor is if you’re unsure.
  4. We add a method (behavior) called “attack()”, which uses this Java method “System.out.println()” to display “Player has attacked opponent” when the method is used.

Step 2

Now we have created the class, or in other words the blueprint for our Player object, we can begin building it and doing stuff! And to do this we have to start writing some code in the “main method” which is traditionally located in the “Main class” file.

The main method is the entry point for your programs and is what executes your code. Basically, the main method takes your code and brings it to life. Normally when a new project is created in your Integrated Development Environment (IDE) it will automatically generate the Main class and main method for you. How thoughtful!

So lets being…

Context for above code:

  1. A new Player called “PlayerOne” is declared.
  2. We then instantiate the object with the “new” keyword.
  3. The new object, “PlayerOne” gets initialized with the values “Owen”, “100, “Sword, which represents the name, health, and weapon.
  4. An instance of Player called “PlayerOne” has now been created and we can now tell that object to attack by writing “PlayerOne.attack();”. For reference, an object’s methods are executed by first specifying the instance (object), then adding a “.” followed by the method name.
  5. The “attack()” method has been called so PlayerOne now executes the code i.e. the steps by step instructions outlined in the “attack”()” method. In this example, the action we described was for the statement “Player has attacked opponent” to be displayed.

And that the basics of creating an object! See it’s not that bad. Now let’s look at some fundamentals principals of Object-Oriented Programming.

Let’s dive into the 5 main principals of Object-Oriented Programming 

Background vector created by Blossomstar - Freepik.com

1. Inheritance

Here’s a quick summary, and don’t get scared off, I will simplify this in a second!

So, inheritance describes the relationship between two classes, and often this relationship is thought of in a parent and child dynamic. Therefore, it’s very common to hear the words “Parent class” and “Child class”. Essentially, the child will inherit behaviors (methods) and attributes (variables) from the parent. In programming terms, this means methods and variables are shared from the parent to the child. And because this is the case, we can access methods and variables in the parent from the child. This allows us to reuse code.

I think the simplest way to think about inheritance is as an “is-relationship” between two classes. This is to say one class “is” a type of another. So a car “is” a type of vehicle, a dog “is” a type of animal and a flower “is” a type of plant. And here’s how that would work looking at the animal scenario.

Step 1 – First, we have to think about our parent class, which will be our “Animal class”. This will be the base class which all other animals will descend from (inherit from).

Step 2 – We begin by listing all the common behaviors and attributes that animals share and add this to our “Animal class” in the form of method and variables. For example, all animals have a head, body, can eat and breath etc.

Step 3 – Next our child class, which will be the “Dog class”. And like any animal, it will have all the same characteristics. However, a dog also has legs, a tail, and barks. So these will additionally need to be added as variables and methods.

Step 4 – Finally, we can create a parent and child relationship between the “Animal” and “Dog” classes using inheritance. This will give the “Dog” class access to the variables and methods in the “Animal” class, which eliminates the need write the same code that defines a dog as having the ability to eat and move etc.

Here’s an example in code:

2. Composition

Composition basically means building an object from other objects. And when you think about it, the word “composition” means the physical make up of something, or for lack of a better word, it’s ingredients.

Where inheritance is considered to be an “is-relationship”, composition can be thought of as a has-relationship. What is an object made of? Or what does it have? Let’s revisit the car example. A car “has” an engine, steering wheel, doors, gearbox and so on and so forth. All these things are objects in their own right.

Composition allows us to build more complex and fully formed objects, but how do we do this exactly? Well, you may have already noticed all the things that make up a car can be considered as attributes i.e. variables! So it’s simply a case of constructing a class that includes the necessary objects as it’s member variables.

And again, like inheritance, composition gives us the ability to reuse code because the objects that make up the overall, all share their behaviors (methods) and attributes (variables) with that overall object. So if the car object wanted to access a method in the engine object, called “startEngine”, it’s more than welcome too.

Here’s an example in code:

3. Encapsulation

Encapsulation is all about protecting classes by hiding or restricting access to its components i.e. it’s variables and methods. It’s like having a security system so your average Joe can’t just waltz in and start messing around with your stuff. But rather than it being your average Joe who restricted its other classes or code.

There are standard parts of a class that we don’t want public to every Tom, Dick, and Harry. A typical example is the member variables of a class which describe the attributes of an object. It’s very common to restrict access to an objects member variables to that objects own methods. These methods are commonly named “Getters” and “Setters”, which fall into the category of “Accessors” and “Mutators”. More strange terminology! Don’t worry, I’ll explain.

A Getter method, know as an Accessor –  Is a method that “gets” the value stored in the objects member variable and spits it out the form of a return somewhere else. Refereed to as an Accessor because it can “access” parts of the object.

A Setter method, know as a Mutator  – Is a method that “sets” the value of an objects member variable. Referred to as a Mutator because it can change or “mutate” parts of the object.

Why do we want to do this you ask? Great question! A valid reason for restrict access in this way is because if those variables were public. Then technically they could be accessed and changed from anywhere. And if for some reason a mistake was made that changed the variable in a way that was unintended. That mistake could again, be anywhere! At least if it’s restricted to the class we only have to look in one place.

This isn’t so much of a problem when you have a couple of lines of code. But when you have thousands, it can be a real headache trying to find the culprit!

Basically, it’s to limit access so we can maintain CONTROL over our objects. And therefore, reducing the chance of them being changed in unexpected ways.

By now you may be asking “how do we restrict access?”. Well, we use what’s called “Access Modifiers”. These are keywords which precede variable and method names to denote the level of access available to outside code. The 3 main keywords are:

Private – This means that only the current class will be able to access the variables or methods.

Protected – This means only the current class and any child classes will have access to the variables or methods.

Public – This means the variables or methods are open and can be accessed anywhere.

Here’s an example in code:

4. Abstraction

In life when we say something is abstract, we generally mean something that is a thought and has no concrete existence. We have a rough idea of what this thought is but not the details of how it looks and interacts with the world.

Abstraction in Object Oriented Programming is the same concept. We define all the things that an object has and can do without specifying any of these. The object only exits as an idea until another class comes along to fill in the details.

An example, we can create an abstract class called “Animal”. And like a normal class, it will outline the variables (attributes) and methods (behaviors) associated with animals. However, once the names of these methods and variables have been defined no further detail is added. So the code, which actually sets the variables and provides the step by step instruction for the method, is left BLANK.

Only when we create another class e.g. a “Bird” class, to inherit from Animal, do those variables and methods get filled in.

Abstraction is really useful for ensuring the correct use of our classes by forcing methods to be implemented. What does this mean? Let’s continue with the animal example. All animals must eat, otherwise, they die. And because “Animal” is an abstract class it will force the “Bird” class to use the eat method, so now our bird won’t die!

A child class that inherits from a normal (non-abstract) parent class is under no obligations to use its methods.

Abstraction is also considered to be closely linked on Encapsulation as the complexities i.e. the details of the class are hidden. Remember it just defines what the object does, not how it does it.

In Java, we make a class abstract by using the keyword “Abstract”. Here is an example in code:

5. Polymorphism

Let’s start out with the meaning of this strange word. So, what does it mean? Well, Polymorphism means one name, many forms. I know that sounds very cryptic! But essentially its referring to how the same method can be adapted to perform different actions. Hence the “one name, many forms” thing.

Polymorphism is closely linked to inheritance as it involves the child class redefining the behaviors (methods) of its parent.

In essence, you can have multiple objects, which inherit from the same class and all those objects can appear with the same methods. However, those methods may all do different things, even though they are all built from the same blueprint. How is this possible you may ask? In two way…

Polymorphism comes in two main forms, Overloading and Overriding. To make it easier I like to think of Overloading as the copying of methods and Overriding as the taking control over methods.

Overloading – Is having multiple methods with the same name, copies if you will. And each one asking for different information to be passed into its parameters aka brackets. You may have one method called run(), where nothing is in the parameters, and another called run(speed), where a particular speed is given.

Overriding Is the ability of a child class to take control (override) of a method in its parent class and change the action (implementation) it performs. The method will still have the same name but now can perform a different action.

Here’s an example in code:

Well, those are all the basic principals and fundamentals of Object Oriented Programming. I hope this has been useful and not too confusing. Once you understand the basics, you will soon be on your way to building much larger more complex objects. But just remember the principles taught here. They will serve you well. Go forth and conquer!

Feature image designed by Graphiqastock