« Archives in November, 2011
28
November

Busy Holidays? Never!

Hey everyone,

I seem to be neglecting this blog once again! I think it’s about time I make a post to keep you all informed of what’s been happening over the past week. I’ve actually been pretty busy with coding and gaming (yeah, ok, not ‘busy’ in the normal sense). I’ve made a few adjustments to the Ajax system being used by this blog (for starters). That change I made won’t be that noticeable for most people, but it’s helpful for the back-end of the site. I’ve also been working on a new statistics plugin over the past couple of days, since the one I’m currently using is pretty crap. I’m thinking I might open up the statistical information it collects for you all to view, but that idea is still in the works. If anyone has any ideas of how I could do that, feel free to post a comment below.

Last Thursday it was Thanksgiving in America (as some of you may know). At the time, I was thinking of making a post saying about it for my American audience, but I (obviously) didn’t end up doing it. In spite of that, I’d just like to wish you all a belated happy Thanksgiving.

Soon I may be posting some game and movie reviews, since I haven’t done too many of them just yet. Be on the lookout for reviews on Call of Duty: Modern Warfare 3, Crysis 2, Halo: Reach, The Adjustment Bureau, and Battle: Los Angeles (for starters). I may also do reviews on others that I haven’t played/watched in a while, but only after playing or watching them again. If anyone would like to suggest a game or movie (or both) to review, post that in the comments too!

That’s all I can think about telling you all right now. Remember to keep on the lookout for new pages appearing on my home page! Thanks for taking the time to read this post.
Robert

22
November

Reaper Quicky #17

Hey everyone,

Just thought I’d do a quick post saying I’ve completed a giant update to my site home page (available here). There’s not much content, and it was (and is) only made up of one page, but I thought it needed an update from the old white look. There is more to come soon, so keep a look out for new pages popping up there.

Hope you all enjoy it.
Robert

21
November

Weekly catchup – Week nineteen (exam special)

Hello everyone. Welcome to the final of this series for 2011!! I’m still considering whether I’ll continue with series 2 next year, so it’d be really helpful if I could get some feedback from you all if I should or not. Post a comment below with what you think! Anyway, into the exams.

Friday 11/11/2011: First exam for this semester was EDC. It was probably the best designed exam I’ve ever sat! I wasn’t able to complete the whole thing, but I got the majority of it done (and hopefully correct). It did seem a bit packed with content, though. Talking with people afterwards, many of them thought the same way. But I don’t think anyone will be penalised, since many people thought the same thing.

Monday 14/11/2011: Yes, that’s right. Only had two full days to focus study on this one. It was OS, which turned out to be the worst exam EVER!!! Don’t get me wrong, I’ll most likely pass, but it was pretty bad. It didn’t cover a fair bit of the course content, and when it did cover something we learnt it wasn’t stated clearly what was expected. In fact, question one was just to fill in blanks which didn’t have much context (making it very hard to answer).

Saturday 19/11/2011: Last exam for third year!! Unlucky it was on the weekend, but oh well. This last one was DS. I actually liked it, because it covered the course content fairly well and wasn’t too difficult. I was able to complete the majority of it before the end of the exam. In fact, I found myself writing right up to the last second. Unfortunately, I wasn’t able to finish the sentence I was doing. But doesn’t matter, the marker should get what I was on about.

That ends this series for the year. I hope you’ve all enjoyed reading what’s been happening in my life in terms of my studies for this past year.
Robert

15
November

Hostcell Review

Hey all,

One thing I’ve been thinking about doing is reviewing my current hosting company (Hostcell). I know not everyone will want or need a website, so this is not necessarily for anyone in particular, but it may help out those looking for a suitable company to get started in building or maintaining a website.

I joined Hostcell back in 2009 to get some web space to play around with the Facebook API (mostly the Javascript library available at the time). I also hosted a major part of my first year Internet Computing website on here. I’ve taken that part of the site down now, but if anyone would like to see it feel free to get in touch (with a comment below). I can easily put it back up and give you all the link. During late 2009 and 2010, I played around a fair bit with setting up a website to help other developers with the Facebook Javascript API. That website became fairly popular, receiving at least one visitor per day (yeah ok, not that popular, but it’s more than I ever expected). Since then I’ve been working on this blog, the Facebook Javascript API (now replaced with the new SDK) site as well as a new chat website (soon to be released). The server Hostcell was using when I joined had the occasional downtime, which made development slow sometimes, but it was reasonable for a completely free host.

In the past year, the company has changed ownership to ‘younger blood’. The change over wasn’t the smoothest, since the new owner seemingly wanted to change everything overnight. But the community was able to reason with him, and things started rolling a lot more smoothly. Unfortunately, the completely free plan (the one I was on) was removed, to be replaced by the post-2-host plans. Those plans were very reasonable, though. I think that can be put down to the community given the chance to help create the plans, and vote upon which would be the best. Hostcell also opened up to offering a paid hosting option. I personally haven’t chosen this path, so I don’t believe I can comment on it, but the paid plans seem just as reasonable as the post-2-host. Instead, I’ve kept to post-2-host. Specifically a plan that gives me 1GB of disk space and 5GB of bandwidth for 8 posts on the Hostcell community forums per month. These amounts are more than enough for a small website.

After the major part of the change over, the hosting was migrated to a newer server. So far, it seems to be more reliable than the old server. I personally haven’t noticed any downtime (apart from the admin changing settings, etc). It’s been very helpful with development, especially when the project has been as large as getting the chat website working, or as small as upgrading this blog when an update comes out (as some of you may know, this blog uses WordPress as the major code-base).

The forums is a good place to relax and talk with a group of smart individuals with similar interests to yourself. The community isn’t too large, but the users that visit regularly are a friendly group of people. This helps a lot with reaching your required posts (with post-2-host accounts). The moderators and administrator (the owner of Hostcell) are also very friendly and always seem willing to help out with server or other related problems.

To sum everything up, Hostcell is one of the best hosting companies around today. I’d say the post-2-host option is comparable to many of the paid server options available elsewhere, and the paid options out-do the rest. The community is fun to be a part of, so I hope it continues to grow.

Hopefully this helps those looking for hosting to decide upon who to go with, and gives everyone an idea of what I do to keep this site up-and-running.
Robert

10
November

How to: Javascript Classes

Yes, finally! It’s time to show you all how to create your own Javascript classes. Unlike most object orientated programming and scripting languages, there is no concrete way to define a class. For example, in Java you’d do something like this:

public class Stuff extends AnotherClass{
   public Stuff(){
      // ...
   }
   // ...
}

Javascript has the class (and other related) keywords, but they have not been implemented. Because of this, classes need to be defined in a slightly different manner. The first step is to create the initial class, using a function:

function Stuff(){
   // ...
}

This function is the only constructor for your class, so if you want more than one way to construct the class you need to play around with the parameters that are passed in.

As with other object orientated languages, you can use the ‘this’ keyword within your constructor. The ‘this’ keyword is the only way to set attributes on the constructed object (with the class construction method I’m using). It is also possible to define variables in the constructor (using the ‘var’ keyword) then make functions that are able to access these, but the code within the constructor can get messy. An example of this is:

function AClass(){
   var something = 5;
   this.getSomething = function(){
      return something;
   };
}

This results in ‘something’ being private, which may be a helpful thing for your script. Unfortunately, with my method (read on), it is impossible to see or do anything with these variables unless a public function is created in the constructor. I’d only recommend this method for smaller classes that don’t need to deal with a super class.

For larger classes, I’d recommend using the ‘prototype’ method of class construction. This is the method I use most often when dealing with Javascript classes. In this method, you create your function (as above) then set the prototype attribute on the created function object to an object containing all the functions you want for every object created, like so:

function MyClass(param1, param2){
   this._p1 = param1;
   this._p2 = param2;
}
MyClass.prototype = {
   _p1:null,_p2:null,
   getP1:function(){
      return this._p1;
   },
   getP2:function(){
      return this._p2;
   }
};

A simple notation I’ve seen used a fair bit with this method (and one that I use myself) is to make all private attribute and function names start with an underscore. This method also allows for inheritance in a simple way:

function AnotherClass(p1, p2, p3){
   this._p1 = param1;
   this._p2 = param2;
   this._p3 = param3;
}
AnotherClass.prototype = new MyClass();
AnotherClass.prototype.getP3 = function(){
   return this._p3;
};

This unfortunately removes class privacy, since the subclass needs to know about the superclass’s ‘private’ fields. Personally, I haven’t used the inheritance model because of this. It’s still a very powerful tool in terms of being able to create a class hierarchy within your scripts.

To simplify creating classes, it is possible to make a function that does all the hard work of constructing your classes:

function createClass(obj){
   // get the constructor
   var theClass = obj.ctor || function(){};
 
   // now the prototype
   theClass.prototype = obj.instance || {};
 
   // any any static variables or methods
   if(obj.static){
      for(var key in obj.static){
         theClass[key] = obj.static[key];
      }
   }
 
   return theClass;
}

If you’ve been following along with the entirety of this tutorial (including previous posts), you should be able to work out what each part of the above function does.

This ends the Javascript tutorials. Next time, I may go through the Javascript libraries that are available. Until then, keep coding.
Robert

04
November

Reaper Quicky #16

Hello all,

Has anyone noticed how problems they thought weren’t something to worry about, and had gone away, are still there and continue to get worse over time? It’s really quite worrying to see those problems come back to bite you in the arse, especially since they seem quite petty and insignificant. For example, a friend of mine has been working on one of his clients website to transfer it to a new server. He only just found out that the server he’s moving the site to is running a different architecture, and has problems running the existing script. You’d think that, with standards the way they are, the script would work on the new server as well (or at least partially work).

I’ve come across similar things happening in my own life, but I’ve been fortunate enough to not have them get in my way of living life the way I want to as well as getting work done.

Now for the question for you all to answer: what problems have you come across in your lives that you thought were never there, and how have you combated them to get to your ultimate goal? Post your answers in the comments below!

Robert