This is an old blog. My new blog is moved here.

JavaScript Inheritance: How to write OO (object oriented) JavaScript

11/21/2008

In this blog post, I would like to give little insight into JavaScript inheritance, Inheritance in OO (object oriented) lingo, is the ability to pass properties (values) and methods (functions) from one object to another. This is quite useful, when you write code: organizing functions into classes, and variables into objects helps to keep your code organized and reusable.

So here is the example.

First example is passing inheritance from an object in “literal” notation.

var car_literal = {
brand : 'Mercedes',
color : 'silver'};

Here is a class that we want to import (inherit) the car_literal into

function dealer(){
this.name = "some variable";
return true;
}

Finally, here is the inheritance:

lion.prototype = car_literal;

And this is how we call call it:

    var c = new dealer();
alert(c.brand);

Goodbye Godaddy.com, hello Network Solutions

10/22/2008

Despite of my long partnership with Godaddy.com where I have been hosting most of my websites, I have come to an end of supporting this service. Since most of my development is done in .NET and Godaddy.com does not support remote access to SQL Server, any development or DB migration becomes impossible. As a temporary solution, I actually went and purchased hosting plan from Network Solutions and placed my SQL Server DB there, however Godaddy.com blocked my DB connection…

Namespace in jQuery, keep your ajax organized

7/15/2008

I have been wondering how to marry jQuery with the namespace concepts often used in the Object Oriented JavaScript development approach. In the passed I would just wrapped my jQuery binders to a namespaced function. Recently, I have seen another approach to namespacing the initial jQuery plugins itself. I suppose both of these approaches do not exclude each other, but can coexist. Depending on the complexity of your code you may choose one or the other.

Alternative to clearfix CSS method to clearing your floats

7/11/2008

There is an alternative to the clearfix. I thought this was the final CSS trick I would ever use, but just discovered a new one. Here is an example how to create a simple 2 column layout without running into the problem of not clearing the tags.

<style type="text/css">
body{ text-align:center;}
#wrapper{
width:800px;
background-color:#ff0000;
position:relative;
margin-left:-400px;
left:50%;
float:left;
}
#left_col, #right_col{ float:left; width:400px;}
</style>

<div id="wrapper">
<div id="left_col">
<p>test</p>
</div>
<div id="right_col">
<p>test</p>
</div>
</div>

piggyback SEO strategy/trick: are you hot or not?

6/25/2008

Recently, a friend of mine mentioned an interesting SEO strategy which I will call "piggyback SEO strategy." This is what you do: you pick a major domain name of a web site that is in the same market, and optimize your home page on that keyword. So for example: you have a dating site, and in the title of your page you put: "www hotornot com". Place this keyword a couple other times through out the page, and watch what happens after your page gets indexed. The truth is that a lot of people use google to navigate everywhere. Another friend of mine was telling me recently who amused she was when she saw her mother googeling yahoo.com.

I have in fact tested this piggyback SEO trick. In order not to commit a major breach to google's rules, I have actually build a feature of my professor's rating site oznamkujucitele.cz and calling it "the parody on hot or not" where students can upload the images of their professors and rate them much like on the "hot or not" type of websites. The result was that a couple months later, I did see the major traffic spike; however for some reason it did not last too long. Oh well, back to long tailing now :)