Thanks to everyone for the responses. I'll respond to Bearophile's detailed comments:
> Few notes: > - opCall() of AvgWeighted was abstract. > - keep in mind that in D classes are CamelCase; > - variable names are written like weightSum (but once in a while a underscore doesn't kill). I think it's obvious from my syntax that my background is with C; I'm not experienced with Java, C# etc. This may explain some of the problems I'm having. Regarding opCall I was following the syntax described here: http://www.digitalmars.com/d/2.0/operatoroverloading.html#FunctionCall ... but clearly without understanding it properly. What I was aiming for was a bit smartarse -- to have a class which could in some cases be treated as a function. Each of these classes (later ones will be more sophisticated) is meant to be a data analysis tool which takes a dataset of user-object ratings and user and object reputation values and helps aggregate the ratings and in the process update the reputation values. The aim was that if you just wanted a once-off analysis you could use the class in a throwaway fashion -- hence the use of, avg_weighted(......); rather than avg_weighted aw(.....); The aim is that you would use the second if you were interested in employing the analysis multiple times, and that the class will have other functions that can be used for different or secondary analyses from the main one. It's maybe not the best way to approach what I want to do, but since D is a new language for me, I thought I would be playful with it and try and bend it around in some interesting ways. > - Be careful because ref arguments are tricky. The choice is deliberate here, because the arrays passed to the constructor (or opCall) are meant to be modified. > - There is a line like foreach (r; reputationUser) r = 1; that can be a bug. I guess that I should put a 'double' in front of the r, no? In any case, I guess there is a better way of setting all elements of an array equal to 1.0. > - foreach (objectID, rating; reputationObject) rating /= weightSum[objectID]; can be another bug. ... so should be uint objectID, double rating ... ? I think it's obvious that I want each the value of each element of reputationObject to be divided by the value of the corresponding element of weightSum -- is there a more intelligent way of doing this? Reading Andrei Alexandrescu's article on Dr Dobb's gave me the impression something could be done using chain(), but I couldn't work out how (and probably misunderstood). > - Use better attribute names in Rating struct, when you need to comment a variable name then it's often a wrong name. > - To create structs you can most times use the syntax I've used in the main. > - In methods/functions divide your code into paragraphs; > - keep your indentations more coherent It's nice to see the stress in D on well-written code. Thanks for taking the time to clean up mine. :-) > - I suggest to add contracts and unittests. As you might have guessed, I'm not a developer -- can you provide more info? Thanks & best wishes, -- Joe