Recent Weblogs

Links I like

Static Inheritance

There have been great strides in the javascript user community of morphing the language to be more structured and accomodate for more Object oriented design patterns. One of the most widely used and well understood pattern is inheritance. The idea of a "child"(sub) inheriting properties from its "parent"(super) and in some cases over ruling some properties for its own benefit but majorily relying on what it has inherited from its parent class.

Prototype's inheritance

Prototype is a wonderful javascript library that I have based a lot of my web application development on and without a doubt has saved me an inordinate amount of time, totally recommend it to all web developers building rich applications. It handles inheritance a multitude of ways and if you would like to read more about how to build classes using it view the javascript class entry.

Back on course with the topic, Prototype uses Object.extend to allow for one object to "inherit" properties from another object. Using this we can "extend" an object from another. This is but javascript doesn't support anyform of visibility scope operator(public, protected, private) such that a subclass will override all methods from its super class such that when you call the initialize function it instantiates none of the super's properties.

Use New to Initialize

Justin Palmer writes a very interesting article about how to handle some of those issues by extending the class from a new instantiation of the super. This works great as long as you don't have to work with the DOM ...at all. He brings this point up in the blog and plays around with other examples of how and when this would fail.

A Solution to Last the Generations

I keep hearing the term "Syntactic sugar".. if you're looking for sweets im sorry to say i have no such sugar. Although I do provide a solution to maintain the super's functionality in sub classes and their sub classes. The idea is that you can statically leverage the super's respective function and apply the current object to it.

					

var Super = Class.create();
var Sub = Class.create();

Object.extend(Super.prototype,
                {
                    name : "Super",
                    initialize : function(param){
                    
                    
                    },
                    inheritance : function(){
                    
                        this.name += " inheritance is great";
                        
                    }
                
                }
            );
Object.extend(Object.extend(Sub.prototype, Super.prototype),
            {
                name : "Sub",
                initialize : function(obj){
                    
                    this.obj = $(obj);                            
                    Event.observe(this.obj, "click", this.inheritance.bindAsEventListener(this));                                    
                
                },
                inheritance : function(){
                    Super.prototype.inheritance.apply(this, arguments);
                    
                    alert(this.name);
                
                }
                
                
            }
        );    

It isn't the prettiest way to inherit the functionality but it beats the alternative of having to re-write the code. Meaning that when the Super's inheritance function changes, the sub won't have to be updated. It doesn't get Dean his "super" operator but its not bad. Anyways have a good one!

Comments

August 21, 2008gazeteler

The drivers were released this month so support for Vista is there

September 18, 2008Driver yükleyin

Thanks

October 02, 2008cinsel ürünler

very good

October 02, 2008hikaye

thanks wery good...

October 21, 2008penis büyütücü

Thank you very much for this information.
Good post thanks for sharing.
I like this site ;)

October 29, 2008figurin

Thank you very much for this information.
Good post thanks for sharing.
I like this site ;)

January 16, 2009airbag tamiri

thanks

January 21, 2009almanya chat

Than'sqss

January 23, 2009papatekusa

thank you,it's useful

October 11, 2009whotiwent

Online buy wholesale cheapest products direct from Chinese wholesaler at wholesale price from http://www.wholesale-shopping.com

August 09, 2011NoelleDuke31

I guess that to receive the <a href="http://bestfinance-blog.com">loan</a> from creditors you must have a firm reason. Nevertheless, one time I've received a consolidation loan, just because I was willing to buy a car.

August 26, 2011credit loans

Make your own life easier get the loan and all you require.

August 28, 2011mortgage loans

Houses and cars are not very cheap and not everyone is able to buy it. However, business loans was created to help different people in such situations.

August 29, 2011loan

Do you recognize that this is high time to get the credit loans, which can help you.

August 31, 2011essay writing services

From time to time different students are willing to detect the issue referring to custom write. Hence, we could propose to take the support of the essay writing service. In fact, it’s available to use some stuff from the this topic page.

August 31, 2011writing services

The piece of your work is marvelous. People, which purchase the online term paper from essay help service have to lern your supreme topic. With this information that supposes to be easy to reach a success.

September 24, 2011home loans

I would like to propose not to hold back until you earn enough money to buy different goods! You can take the loans or student loan and feel yourself fine

October 02, 2011term papers

Do not aim for effort if you want it, simply do what you love and trust in, and success will come with our professional term papers writing service.

October 03, 2011cheap papers

Various university students have troubles after they use buying papers online options. It can be just because they choose not professional custom firms. It cannot occur when you have relations with experts!

October 03, 2011essay writing service

I like working with professional essay writing service, they have done my solid term paper. The work is elegant and I will be back, be sure. Notify, all of you to use this company!

October 06, 2011writing my paper

Do you guess that nobody can support you with your academic papers writing? That's not true, because freelance essay writing company should help you every time you need!

October 08, 2011cheap essay writing service

In frustration, college students ask people such as sisters or mates to aid them with research papers writing. Nonetheless, they forget that only specialists who are hired at custom paper writing services can to provide fitted help! Hence, make a proper selection!

October 08, 2011thesis

With the purpose to forestall the mistakes in some writing thesis, this can be the best to order the best outcome connected with this good topic at the dissertation service in web. It’s not so hard to have the PhD getting that great way.

October 09, 2011social bookmarking site

Frequently, it can be more clever to visit the social bookmarking site . Specialists will be able to cope with optimization stuff.

October 09, 2011business loans

One understands that men's life seems to be not cheap, however different people need money for different things and not every man gets enough cash. So to receive some loans and sba loan should be a proper solution.

October 11, 2011dissertation

I do know that you did difficult task, completing your master’s knowledge just about this topic. Therefore, that kind of work scholars do completing the thesis writing or just thesis samples searching.

October 11, 2011essay writing services

You interested me in your supreme knowledge. Thus, I would attempt to find out the trustworthy essay writing services to buy the essay thesis related to your stuff.

October 13, 2011buy an essay

With the help of your perfect idea people would buy essay at the custom writing services close to this good topic.

Name
Site
Comment
  CAPTCHA Image
Reload Captcha Image
Captcha