Dee-sign patterns.

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Tue Sep 27 11:16:26 PDT 2011


Thanks for the feedback! I'll start compiling such recipes of good
practice in D.
If and when the proposal to extend the official website passes, I'll
post the results there, otherwise, I'll post it somewhere else and
give the link.

Cheers,
Gor.

On Tue, Sep 27, 2011 at 8:42 PM, Brad Anderson <eco at gnuk.net> wrote:
> On Tue, Sep 27, 2011 at 9:57 AM, Gor Gyolchanyan
> <gor.f.gyolchanyan at gmail.com> wrote:
>>
>> 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.
>
> I'd love some guidelines and tips for writing idiomatic D code like you've
> written above.  Whenever I'm learning a new language (as I am doing
> currently with D) I'm often concerned I'm not doing things the "proper" way
> and instead just using the techniques I know from other languages.  Python,
> for example, has Code Like a Pythonista [1] which I found very helpful for
> learning to do things the Python way.  Of course, it may be tricky getting
> people to agree on what "idiomatic D" is.
> Similarly, a "cookbook" (snippets for common problems) is also often very
> useful to both beginners and even experienced users of a language. Stack
> Overflow [2] may fill this role better than a custom rolled solution though
> since it's easier to keep solutions up to date. The R language community
> held a little event [3] where they filled Stack Overflow up with the top 100
> common questions and answers.  I think this is something the D community may
> want to consider (especially given the very high quality answers to
> questions about D that have been posted to Stack Overflow in the past).
> [1] http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
> [2] http://www.stackoverflow.com
> [3] http://blog.stackoverflow.com/2009/07/stack-overflow-flash-mobs/


More information about the Digitalmars-d mailing list