• Category Archives
  • Design
  • 8 Posts

Interesting ways of using Go channels

I’ve created this post to document slides accompanying a talk on Go channels given by John Graham-Cumming during GopherCon 2014. The presentation was entitled ‘A Channel Compendium‘ and is available to view on youtub.com.

During the talk, he presents interesting ways of using Go channels and makes you aware of the possibilities and advantages of concurrent programming. For me personally, this opened my eyes to several new ways of structuring programs and novel techniques for synchronising work done across multiple processor cores.

Stop abusing arrays in PHP

This is an issue i’ve wanted to get of my chest for a long time. It’s been latently brewing inside me for a considerable amount of time and it’s starting to come to a head. The issue is with PHP and the total abuse of arrays. Whether this issue is an artifact of the language’s historical baggage or because PHP just attracts a lot of inexperienced developers is up for debate. My problem here is that arrays are nearly always used where objects should be!

Alternative function syntax in D explained

This is an extension article to Templates in D explained where i introduce the alternative function syntax and how it complements template usage. This article will expand a little more on that syntax and make clear what is available in D and why.

An alternative syntax has not been included by accident but by design and as a result can potentially make code more complicated to understand and add more friction to first learning the language. This particular trade off, i believe is worth it, enabling particular features when using different paradigms.

Templates in D explained

Let’s get one thing straight from the outset, template metaprogramming scares the hell out of most developers! I have no idea why, probably because it simply sounds scary? Whatever the reason, many developers shy away from even learning about such techniques, let alone use them. This is such a shame because templates offer a superb tool for programming at a higher level of abstraction which is something that can aid in better program design.

Even though many programming languages support template metaprogramming this article is about using templates in D. D is one of the best languages i have ever used and the more i use it the more i realise it’s getting everything just right. Hopefully this article will remove the above fear and educate developers on what can be achieved.

Forget currying, use partial application

I’m currently reading more about advanced JavaScript design patterns and an interesting concept i’ve come across a lot is Currying and Partial Application. For years i’ve used partial application but not known its name or how it can be used to its fullest, so it was a pleasant surprise to read more and fully understand it. Currying on the other hand is partial application’s more serious cousin and something i’ve never really used. Here follows the differences and why they may or may not be useful.

Implementing dynamic, read-only object properties in PHP

I was recently working on a PHP project where i needed (or would of liked) an object to have publicly available properties which were read-only. Unfortunately PHP doesn’t support this and the usual way of implementing something similar was to have private properties and standard getter methods. The trouble with getter methods is that sometimes they seem a little like overkill, especially if you’re only accessing a name or an age, etc. Do you really need a method call to return a simple string or number that is always the same? Plus, in my opinion, they are harder to read than properties, although it could be argued only slightly.

Hey, stop ruining my work!

Recently a friend of mine ask me to design and create a small website for their fledgling business. Although slightly weary of creating such websites, he was a good friend so i agreed to do it free of charge. The business was something i am not familiar with and while nothing to do with technology i approached the project with enthusiasm and proceeded to gather information from him as i would any other client.

Now, this is what puts me off creating such websites: the information gathering stage. At first i asked him what do you want the site to do for you? He didn’t really know. So i asked him what content should it contain? He wasn’t sure. Not too surprising though i guess because he wasn’t technically minded and never owned a website before, so i suggested i should come up with something to start with then use that as a base to build on and amend as needed.