Module-based programming

Ali Çehreli acehreli at yahoo.com
Fri Jul 26 09:00:56 PDT 2013


On 07/26/2013 08:33 AM, Land wrote:

 > What about inheritance and interfaces,
 > though? Am I supposed to put all the interface/inherited methods into
 > the object

At least technically, yes. There is no other way for interfaces and 
function overriding.

 > and all the other, utility methods, as free functions?

Some people think that as long as a function can be implemented as a 
free-standing function, then it should be a free-standing function. My 
earlier canTravel() is a good example. (Aside: In D, there is no 
free-standing function, they are all at least parts of modules.)

Others think that any function closely related to a type should be a 
member function. Interestingly, canTravel() is good example here as 
well. :) Since most modern cars do report estimated distance the car can 
go with the remaining fuel, canTravel() can also be designed to be a 
member function.

Ali



More information about the Digitalmars-d-learn mailing list