Many questions

grauzone none at example.net
Wed May 6 00:17:40 PDT 2009


I don't want to split a big class into several smaller classes, just to 
be able to distribute it across several source files.

Actually, the D module system makes me to implement several "aspects" of 
something as several classes. Just to be able to put the implementation 
into several files. Of course, you could argue splitting it into smaller 
classes is cleaner (and forces you to do a cleaner design etc.), but in 
reality, this just causes code bloat. You need additional code to 
interface with the other classes, ensure encapsulation, etc. But putting 
it into a single class is so much simpler, and in the end KISS > complexity.

Oh, how much simpler was programming, when you'd just define global 
variables and global functions in several source files? At least that's 
what I think when I look at such "simple" code. (My opinion usually 
changes if I have to fix bugs in it.)

Open types could help to make putting different aspects of a class into 
different files. You know, just adding new member variables or virtual 
functions to a class from "outside". Oh, and you can do this for free in 
dynamic languages. I think they call it "monkey patching", but it has 
the following disadvantage: all the added members live all in the same 
namespace, regardless of what source modules did add them to the object.

By the way, Aspect oriented programming languages won't solve this. 
Usually they are clusterfucks which just add complexity on top of 
already complex languages. A good example is AspectJ.



More information about the Digitalmars-d mailing list