Category: Geekpulp

  • Listen to your heart

    Listen to your heart

    JavaScript is responsible for the behaviour of your website/app. At the heart of affecting the behaviour of the page is listening for user interaction events. These are things like button clicks, key presses and drags and drops. To do this, first we select an element then we add an event listener. To add an event…

  • This is our concern, Dude

    This is our concern, Dude

    In web development, there’s a concept called “the separation of concerns” between your HTML, CSS and JavaScript. Each language plays a role in web development and it pays to remind ourselves what these roles are: HTML = Structure CSS = Appearane JavaScript = Behaviour There are some overlaps between them, but this should be minimised…

  • GitHub flow

    GitHub flow

    I’ve recently been attempting to contribute to some open-source GitHub projects with varying degrees of success. One thing that’s extremely useful to do before you start contributing is to develop a basic understanding of the standard GitHub workflow. It’s not especially complicated but it can be a real faff if you don’t do it correctly…

  • No Comments

    No Comments

    When I was first learning to code, something that came up a lot was to always comment your code. Code comments have value, but despite what my teachers at the time may have thought, you should try not to rely on comments. This isn’t to say you shouldn’t communicate to the reader what the code…

  • DRY variables

    DRY variables

    The concept of DRY code is simple, Don’t Repeat Yourself. So if you look at some code you’ve just written and notice it’s looking a bit moist, AKA the same stuff repeating over and over, there’s a good chance it’s an opportunity to refactor. This is also true with variable declaration. Take the this example:…

  • Zombie code

    Zombie code

    Part of developing (and certainly learning to develop) is creating code, commenting it out, and creating a better version. As you get into a flow state with coding it’s really easy to get into the habit of doing this and not going back and clearing out the undead code comments. Here’s an example of what…

  • Keep your friends close and your variables closer

    Keep your friends close and your variables closer

    Back in the day, I used to have this habit of declaring all of my variables at the top of the file. My thinking at the time was it would keep everything organised so if I needed to jump to one I’d know where to go looking. While that might sound like a sensible approach…

  • How to function correctly

    How to function correctly

    Coding is a fairly amazing thing to be able to do. There are effectively no limits to what can be done when you’re more or less writing the universe from scratch. Having said that if Spider-Man movies have taught us anything (and I think we can all agree they have) it’s that with great power…

  • Simplify conditional statements

    Simplify conditional statements

    Consider the following code: Looks good right? It’s logical and easy to understand, just your standard if statement. All true, but over the course of an entire project you’ll make a lot of considtional statements like this and using 5 lines of code when 1 will do can create some serious size increases to your…