Friday, January 21, 2011

"extends" or "extended" ??

I've just read a post on the Django-users mailing list. It was a simple mistake, and quickly corrected by other participants of the list; but it made me think a bit about semantics...

The point was about Django template inheritance: as most OOP languages, Django lets you define a 'base' template and then another 'derived' template that 'extends' the base one. The user in question then used the base template and expected it to contain the 'derived' parts. As everybody pointed, he should have called the 'derived' template instead. Again, just like on OOP languages, where you instantiate the derived classes, and they inherit behavior from its base class(es).

But this kind of mistake seems to be a common one among those first approaching template inheritance. Why is this so? My guess: because 'extends' is a transitive verb.

Lets say I have a chair, and everybody around here knows what a chair is and how it looks. Then I come with some tools and "extend the chair" maybe add some armrests. What do I have now? the same chair, with armrests. If somebody else asks for "the chair", he'll get the 'extended' chair.

But that's not how OOP inheritance works: a class that 'extends' another doesn't make any change to the base one. It's a new class with inherited behavior. That's old news to any programmer.

Don't you think that the 'extends' keyword in Django templates and Java class declarations is a little misleading? I understand that it means "I'm just like that, but extended"; but how come it uses 'extends'? To me, it sounds like some pompous marketing: "this newfangled gizmo copies and extends the old system"

4 comments:

Anonymous said...

188bet 188bet matchpoint matchpoint 제왕카지노 제왕카지노 william hill william hill 카지노 가입 쿠폰 카지노 가입 쿠폰 온라인카지노 온라인카지노 카지노사이트 카지노사이트 코인카지노 코인카지노 바카라사이트 바카라사이트 betway betway 173

Hi Every One said...

Prezi Pro is a great software for creating presentations. It is easy to use and has many features that make it stand out from other similar software. One of the best features of Prezi Pro is the ability to create a safe and beguiling picture. This makes it ideal for businesses and individuals who want to create a professional and cyber secure presentation. Download Prezi Full Version Crack

cyber pc said...

Fairly a group of victims is searching cracked data recovery application, such as Recuva Pro so as to save the cash even as receiving data back. Recuva With Crack

The Blogger Worlds said...

I hope you respect: everyone who meets you no matter how they treat become: a great person. I hope you grow: to be a very kind and responsible person. New Baby Wishes