<myBlog show="last" ⁄>
<mySnippets order="rand" ⁄>
<myPhoto order="random" ⁄>
<mySnippets type="lang" ⁄>
<myQuote order="random" ⁄>
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myVisitorsMap ⁄>I know, it's taken you years to understand class inheritance until you could do it in your sleep. It took me years as well. We've had it engrained in us for a while: design a class to model some object in our problem space, worry about encapsulation and behavior, think about creating descendants that increase the specificity of our first more-general class, and perhaps keep on going to produce higher, more-specific classes. We exult in those class models and in the type-safety they give us.
Some of us, as we learn more, start to find that the implementation inheritance model gets to be too restrictive and too wordy. We start experimenting with the interface inheritance model where, essentially, we think about inheritance of behavior rather than of behavior plus data. Our class models become shallower and not filled with classes than descend from classes which descend from others and so on all the way down. We use delegation of the interface as a coding model.
But JavaScript doesn't do all that. It has objects inheriting from objects. Period. Furthermore those objects are dynamic in nature: we can add new members or remove them at a moment's notice. No, this is not the description of anarchy, but a realization that perhaps classes are just too restrictive. Certainly, you can use libraries like Prototype that try to provide you with a class model type structure to your applications, but it is far better to just embrace the way that JavaScript works.
The problem is that JavaScript is conflicted in what you do for inheritance. Despite the speech from the high ground just then that JavaScript objects inherit from other JavaScript objects, there's so simple support for it in the language. Instead we have this unholy trinity of constructors, prototypes and the new keyword that hide object inheritance in order to smooth the way for us developers coming from a classical object-oriented language.
este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:
http://blog.boyet.com/blog/javascriptlessons/javascript-for-c-programm...
<myNews show="rand" cat="programacao" ⁄>