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"

3 comments:

sheela rajesh said...

Amazing experience on reading your article. It is really nice and informative.
Python Training in Chennai
Python Training in T.Nagar
JAVA Training in Chennai
Big data training in chennai
Selenium Training in Chennai
Python Training in Chennai
Python Training in Tambaram

Anonymous said...

This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...

Big Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery

Anonymous said...

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