[Grace-core] Fwd: [important] Traits

James Noble kjx at ecs.vuw.ac.nz
Tue Mar 12 18:36:28 PDT 2013


> Number (1) is what you would expect, but number (2) is very bad.  We can set a good example in our libraries by ALWAYS providing factory objects.  But we have to make the traits public too,  so that clients can inherit from them.   So I don't see a way of preventing clients from client using them directly.   Maybe allow object trait-expression ONLY in method that are annotated as factory methods?

there is the Modula-3 solution: Modularise!

put the traits (and thus most of the code)  into a "CollectionsImplementation" Module.

put the types (& factory methods?)  in another module "Collections"

most clients just import the CollectionsImplementation module.

other issues are 
 - how would we organise the factory methods?
  - one factory object for the whole library (abstract factory AKA object algebra)?
  - one factory object for each "class" ?



none of these things can change the fundamental properties of this scheme
 - that we have two things - classes and objects, or perhaps three including factories
    that we have to be explicit about

 - inasmuch as our model follows the classical Java/C#/C++/Python/ etc model
   - it will be easier for all those SIGCSE people to learn
   - they will use it in the same way that Java et al are used.

  we can't put classes & *new C* into the language and not expect people to use them.

perhaps that pushes back towards "new" method sent to a class.  What's a class?  Magic.

J




More information about the Grace-core mailing list