I used to believe that virtual was a better default, but these days I think the opposite. My reasoning is that inheritance is a very poor tool for code reuse. The way I see it now, inheritance is a tool for modelling "is a" relationships and variations on objects, but it's bad to use it in an API as a "to implement your business logic inherit here" thing.

You get much better code reuse out of functions, especially with generic programming. (D being the number one generic language with its templates and CTFE.) The more loosely coupled the data becomes from the business logic, the higher application quality appears to be and the more breakage decreases. Presenting an interface for a library whereby the types can automatically be overridden is a good way to lead people into writing code that's going to break later and may burden the library's implementer with supporting something he didn't know he'd need to support. (e.g. in Nowak's ZIP library.)

Reply via email to