How can you represent inheritance in a database?

I’m thinking about how to represent a complex structure in a SQL Server database. Consider an application that needs to store details of a family of objects, which share some attributes, but have many others not common. For example, a commercial insurance package may include liability, motor, property and indemnity cover within the same policy … Read more

Explicitly calling a default method in Java

Java 8 introduces default methods to provide the ability to extend interfaces without the need to modify existing implementations. I wonder if it’s possible to explicitly invoke the default implementation of a method when that method has been overridden or is not available because of conflicting default implementations in different interfaces. interface A { default … Read more

What’s wrong with overridable method calls in constructors?

I have a Wicket page class that sets the page title depending on the result of an abstract method. public abstract class BasicPage extends WebPage { public BasicPage() { add(new Label(“title”, getTitle())); } protected abstract String getTitle(); } NetBeans warns me with the message “Overridable method call in constructor”, but what should be wrong with … Read more

Is it possible to make abstract classes in Python?

How can I make a class or method abstract in Python? I tried redefining __new__() like so: class F: def __new__(cls): raise Exception(“Unable to create an instance of abstract class %s” %cls) but now if I create a class G that inherits from F like so: class G(F): pass then I can’t instantiate G either, … Read more

Use of .apply() with ‘new’ operator. Is this possible?

In JavaScript, I want to create an object instance (via the new operator), but pass an arbitrary number of arguments to the constructor. Is this possible? What I want to do is something like this (but the code below does not work): function Something(){ // init stuff } function createSomething(){ return new Something.apply(null, arguments); } … Read more