Why not inherit from List?

There are some good answers here. I would add to them the following points. What is the correct C# way of representing a data structure, which, “logically” (that is to say, “to the human mind”) is just a list of things with a few bells and whistles? Ask any ten non-computer-programmer people who are familiar … Read more

What’s wrong with overridable method calls in constructors?

On invoking overridable method from constructors Simply put, this is wrong because it unnecessarily opens up possibilities to MANY bugs. When the @Override is invoked, the state of the object may be inconsistent and/or incomplete. A quote from Effective Java 2nd Edition, Item 17: Design and document for inheritance, or else prohibit it: There are … Read more

Why do I have to access template base class members through the this pointer?

Short answer: in order to make x a dependent name, so that lookup is deferred until the template parameter is known. Long answer: when a compiler sees a template, it is supposed to perform certain checks immediately, without seeing the template parameter. Others are deferred until the parameter is known. It’s called two-phase compilation, and … Read more

How can you represent inheritance in a database?

@Bill Karwin describes three inheritance models in his SQL Antipatterns book, when proposing solutions to the SQL Entity-Attribute-Value antipattern. This is a brief overview: Single Table Inheritance (aka Table Per Hierarchy Inheritance): Using a single table as in your first option is probably the simplest design. As you mentioned, many attributes that are subtype-specific will … Read more

What are the nuances of scope prototypal / prototypical inheritance in AngularJS?

Quick answer: A child scope normally prototypically inherits from its parent scope, but not always. One exception to this rule is a directive with scope: { … } — this creates an “isolate” scope that does not prototypically inherit. This construct is often used when creating a “reusable component” directive. As for the nuances, scope … Read more

Prototypical inheritance – writing up [duplicate]

Constructor function introduction You can use a function as a constructor to create objects, if the constructor function is named Person then the object(s) created with that constructor are instances of Person. var Person = function(name){ this.name = name; }; Person.prototype.walk=function(){ this.step().step().step(); }; var bob = new Person(“Bob”); Person is the constructor function. When you … Read more