How to learn - The PHP Project Guide (2014)

The PHP Project Guide (2014)

18. How to learn

This may seem a strange question, because everyone learns differently right? Of course, but the basic principal to learning a programming language is the hard way. The hard way is not knowing how to do something and spending time working it out. It’s not asking for too much help, copying snippets of code or getting someone else to do it for you. If you do this, it’s not your work and you won’t learn.

Everyone learns differently, but within the programming world there is a massive trend of people simply copying. If poor code is copied and copied, nothing is learned. So how can you break free from not being able to work without reference to snippets of code? I find a really good method is to just try and spend time working on a problem. You may be used to working in an educational environment whereby you practice something, remove the original material and try and solve a problem or re-create something without referring to it. This works in so many cases! I’d highly recommend taking this approach to programming. If you have no idea of syntax, functions or structure of a language you may need to refer to resources online and this is fine, but there is a difference between researching parts of a language to looking at full source code. The PHP manual is a good place to start as it gives you information with official and user posted examples. Try and skip the larger examples though, as these are usually fairly complicated and probably won’t apply to your website. The official documentation often provides smaller snippets that give you quick and recommend example usage.

18.1 Stick with it

If you’ve spent hours attempting to solve a problem this is good for learning, but stop. Sit back and relax for a while and think about the problem without the need for code. How do things relate? What makes sense? How should the process flow? Once you’ve spent time assessing the problem away from a computer, you’ll be in a better state of mind to start writing code that does something useful. Write it down if you need to.

I tend to find the longer I experience a problem for the better I learn. This is because you’re actively seeking a solution and once that solution appears, you’re more likely to remember it. Learning is a process of solving problems, not trying to absorb code. Trying to absorb code does nothing but show you other people’s solutions for other problems. Sure, you can look at code that shows you how to create a forum, but what happens when you want to add a specific feature to that forum? You need to know how to write code, not how to copy it.

18.2 Teaching

Teaching is a wonderful and effective way to learn yourself, especially when others correct you. You don’t need to qualify to teach and help other people so join a forum and start answering people’s questions. If you get something slightly wrong, it’s more than likely that someone else will jump in and correct you anyway. Thus, you have just learned something new by attempting to help others. Being part of a community that offers help and support is such a great way to learn. You also have the added benefit of then being able to ask for help yourself, and as a respected and known member of a community you’ll always have people that are willing to help you back, perhaps even those you’ve helped in the first place.

It’s also a good idea to write tutorials, however basic. Writing tutorials means you can get feedback on alternative methods, such as faster ways of doing things. There will often be several solutions to problems and it’s good to get used to learning how and why things perform better. Posting tutorials to websites where comments can be posted and read are great. Just be sure to listen to this advice and update your code accordingly, or others may find your code and put it to use. It goes without saying that when writing tutorials you shouldn’t post reams of code without carefully explaining exactly what you’re doing and why, as this creates very little value.

18.3 Books don’t always help

Not this book, of course! This book is conversational and doesn’t list loads of code. If we did, it would be outdated by updates within PHP and would be rendered useless or less effective at some point. Once a book goes to print it’s difficult to recall all copies of a book and say “Hey, that function for reading files isn’t recommended, you should use file_get_contents instead!”. Reading a programming book full of code means you’re unaware that things can change in the future, and I rarely see books that warn against potential changes in the future. Think carefully before buying a book and if you do, ensure it’s extremely recent and if you’re unsure, check in the PHP manual to see if something has changed.

18.4 It’ll click

There is a phase that I’ve experienced and that I know many people have too, when something just clicks. Particularly with web development, this can feel like you’ve accomplished a lot. Once you learn how to do something, you find that this branches off and allows you to do much more than you originally thought you’d learned. This is usually true for database and application communication, where a lot of people are unsure about what tables they need to create and how they connect, query and output this information in a way they need.

I guarantee you’ll get to a stage where you can plan and deploy any database driven website with confidence. You might then need to learn more efficient ways of querying for speed enhancements but at least you’ll have built something. Being able to build something originally means you can quickly mock up a website to start to get people using or it show it to those who may be involved with it. You can then spend time tweaking and improving the product. This is a ‘lean’ way to work and is becoming popular, where investing a lot of time and money into a product initially is no longer desired.

18.5 Starting a project

Starting a project can be scary, but it all depends on how much effort you’ll put into it. If you’re not the type of person that likes learning about programming and has no desire to tweak, fiddle and change until something works or works better, it’s probably time to step back and hire someone passionate to do it for you. People often mistake passion for the desire to learn something when they’re actually only interested in the end result - the working product.

A project takes time, commitment and passion to survive and once you’re in a position to learn better and know what to do when you’re stuck with something, you can focus on what matter - the people who’ll be using the product.