On 3/18/12 6:37 AM, Manu wrote:
On 18 March 2012 06:42, Andrei Alexandrescu
<seewebsiteforem...@erdani.org
<mailto:seewebsiteforem...@erdani.org>> wrote:
    Then probably struct is what you're looking for.


No, I definitely want a class. ref type, gc mem, etc.
struct doesn't support virtual at all. I have 2 virtuals, this
particular class has around 50 public methods, almost all of which are
trivial accessors, called extremely heavily in hot loops. More similar
classes to come.

Then perhaps it's a good idea to move accessors outside and take advantage of UFCS.

I've never in 15 years seen a large-ish class where the majority of
methods are virtual. Who writes code like that? It's never come up in
my industry at least.

I consider thick interfaces and shallow hierarchies good design. An interface that's too small invites "inherit to extend" approaches and casts. The fact that Java made "extend" a keyword that really means "narrow" is quite ironic.


Andrei


Reply via email to