SOLID Principles

SOLID Principles

If you’ve been programming in PHP for a while or just programming for that matter then you may have founds ways to improve your code, you know – take it to another level.

All credit goes to Reval Govender for this post, check out the video here – SOLID Principles

Efficiency, Scalability, Maintainability, Extensible and loosely coupled code comes to mind when thinking about advancing your programming skills. Enter SOLID Principles, don’t worry – there will only be 5 of them to keep in mind. You’ll be okay.

The Five SOLID Principles

  1. S – Single Responsibility
  2. O – Open/Close
  3. L – Liskov Subtitution
  4. I – Interface Segration
  5. D – Dependency Inversion
Continue reading “SOLID Principles”

Git using GitFlow

Git using GitFlow Guidelines

I was recently introduced to a Git methodology called Git Flow. Git Flow itself is more of a guideline that they are rules. Vincent Driessen coined the term, however much like myself, developers were probably already implementing this approach long before it gained popularity, or some variant of it. I do remember working on a small team in a past life, long ago when I was a young and chipper programmer. I do remember collaborating with my dev team and using a flavor of GitFlow. Looking back, I now see it’s power in both and even really large development teams. I must admit though, s’been a long time since I’ve worked on a team, so this will be an interesting run for me. Continue reading “Git using GitFlow”

Object.create vs the new operator in Javascript

Object.create() vs the new operator in Javascript

One of the more advanced topics in Javascript is the distinction between the Object.create() and the new operator when constructing new objects. More than that, Javascript being a client side language – is unlike other server side languages, compiled or interpreted.

As a result Javascript has some weird parts to it putting off some developers to some other more less dynamics languages but drawing in more curious developers to Javascript land. These weird parts shouldn’t be seen as a disadvantage though if you thoroughly spend quality time getting to know Javascript – you can use these new patterns, concepts to your advantage.
Continue reading “Object.create vs the new operator in Javascript”

Leverage Browser Caching with .htaccess

Leverage Browser Caching with .htaccess

If you’re an SEO marketeer or a developer – you will see this a lot.

From Google Page Insights, Pingdom, SEM Rush, GTMetrix and other page speed tools – “Leverage Browser Caching” is bound to come up. If you’re ignoring this, then you’re business, your client, or site is at a major loss. Page speed is a huge variable when a customer first engages with your site – chances are high rate of drop offs will occur if you don’t leverage browser caching.
Continue reading “Leverage Browser Caching with .htaccess”

An intro to GZIP and compression

An intro to GZIP and compression

GZIP is one of those big words used in programming to generally describe compression. Then again, you end up asking what “compression” is in the context of programming and computers. These two terms can be a little intimidating to the noob and not until you’ve really implemented it, or experienced it first hand you won’t really know it’s true nature and the fundamental idea behind it. So let’s do that.

We often see these two terms come up frequently during page speed optimizations. Software tools like GTMetrix and Page Speed Insights. If you’re running into page speed issues or a really slow loading page, these tools will recommend compressing your files. Alright so what does that mean?

Alright, a lot actually. But in simple terms:

Compression is the process of encoding information using fewer bits. — Ilya Grigorik, Google

Continue reading “An intro to GZIP and compression”

Javascript – Functional Programming Part 1

Javascript – Functional Programming Part 1

I haven’t covered any advanced topics until now – functional programming in Javascript is an advanced topic in my book. Not only is functional programming an advanced topic, it’s quite special and specific to the Javascript language. Even a well seasoned developer could get a little frazzled by the concept of functional programming – especially those who code in more statically typed languages – like C or Java.

I, myself have mulled over this a long time – especially because I haven’t built any applications using much of functional programming. Frameworks and libraries – yes, but I’m talking about writing my own proprietary code. Programmers unknowingly utilize functional programming all the time – with this, comes closures, prototypical inheritance – other advanced patterns found in our javascript libraries today.
Continue reading “Javascript – Functional Programming Part 1”

Javascript’s call, apply and bind methods

Javascrip's apply, call and bind methods

I’ve been mulling over getting this post up for a while now – simply because functions are a big deal in Javascript. Javascript functions are packed with so many properties, methods and it’s fundamental nature requires some quality time in understanding its features.

There are a few things to keep in mind when dealing with Javascripts call(), apply, and bind methods()

  • call(), apply() and bind() are three methods every function has access too
  • bind() creates a copy of the function object in question
  • call(), apply() and bind() methods are methods that allow an object to point to a different ‘this’ variable when invoked.
  • Common patterns used in conjunction with call(), apply() and bind() are function borrowing and function currying.

Continue reading “Javascript’s call, apply and bind methods”

Importing sql database using the command line

Importing sql database using the command line

This is definitely worth a post. Just when I want to disregard this utility as trivial – every now and then I get a consulting gig where I need to run a full backup – yes of everything, files, database, the works. You see, sometimes I get a task that isn’t as black and white as it may seem at first glance – something is a bit unconventional, but you know – there is nothing wrong with that. Sites come in all shapes and sizes, in all sorts of architectures. It’s good to get exposed to a variety even really weird ones. Look I’d rather poke around a dev site over production no matter how tempting it is – I’ve seen way too many sites go down in my life time, it’s not worth the gamble. I tell every junior developer – the first thing you should do is create a back up. First thing you should do. Then you can show off your programming skills later and you know – be that “rockstar” developer you were meant to be.

Continue reading “Importing sql database using the command line”

Javascript’s defer vs async attribute

Javascript’s defer vs async attribute

Flashbacks of vanilla javascript cloud my mind – back when we didn’t have Jquery. All we had was Javascripts’ event listener method to detect whether the entire DOM was loaded before scripts were fired off.

Why was this necessary though? Well, if you’re a developer you very well know – page speed. And back in those days, programmers weren’t so mindful of placing external javascript files – the head section, footer and I’ve seen some sprinkled throughout the body. Not optimal at all – this can have huge negative implications in terms of functionality and speed.

Continue reading “Javascript’s defer vs async attribute”

Fixing a network 404 error using typeof

Fixing a network 404 error using typeof

Javascript’s typeof operator is an essential debugging tool that many young programmers often miss. Countless times I’ve run into situations where my program wasn’t working because either my variable was unnoticeably coerced or I was just completely unaware of a data type. As mentioned in a previous post – a season programmer should know their data types! Another thing a seasoned programmer ought to know is to prevent themselves from being too arrogant – yes, we need help and using the “typeof” operator is there to the rescue.

Continue reading “Fixing a network 404 error using typeof”