Dee-sign patterns.

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Tue Sep 27 08:57:17 PDT 2011


After using D for quite a while I've developed some minor design
patterns and code style suggestions, that could be useful.
I wanted to post them somewhere on the internet, but then i thought,
that the best place to put D-related useful information is on the
official webpage itself.
So i ask you guys, do you think it would be a good idea to create a
section on http://www.d-programming.language.com/, devoted to design
patterns, guidelines, best practice advices and similar stuff?
If so, I'd like you to post your experience to that section, so there
will be a big and reliable source of help on how to program on D on
it's official site.

Example of a coding pattern:

If you have a class or struct, that has a lookup function by string
identifier, consider using opDispatch to add a very convenient syntax
sugar to your class or struct. And if the lookup term can be run-time
defined, make an opIndex for that, write the implementation in opIndex
and forward the call from opDispatch to opIndex, possibly doing
caching, knowing, that the search term is compile-time defined.

Cheers,
Gor.


More information about the Digitalmars-d mailing list