digitalmars.D.learn - Code spliting in module and packages
- Matthieu (10/10) Jul 20 2014 Hi!
- bearophile (11/14) Jul 20 2014 Put related stuff in a module, and unrelated stuff in other
- Mike Parker (8/14) Jul 20 2014 I don't think there is a "D way." It's a matter of personal preference.
- Matthieu (7/7) Jul 21 2014 Hi,
- bearophile (5/10) Jul 21 2014 Also, try to use less classes and more free (pure) functions :-)
- Dicebot (4/4) Jul 21 2014 Probably most idiomatic D way is to use files _instead_ of
- bearophile (4/8) Jul 21 2014 What's stopping it from being feasible?
- Dicebot (4/12) Jul 21 2014 Stuff like this :
Hi! I can't find any good tutorial about how to split my source code in modules and packages. I don't want to use a Java splitting style (one class per file) or something like that, I want to use the D way, but it's so hard to find it! Can someone explain to me how to do it well, please? In the same time, is there someone who knows where to find a good style guide for D, something like the PEP for python? Thx. Matthieu
Jul 20 2014
Matthieu:Can someone explain to me how to do it well, please?Put related stuff in a module, and unrelated stuff in other modules. If the module grows too much, split it up in two or more. It's about the same as in Python. Just remember that classes can see each other private members only if they are in the same module. So if you move things to another module, sometimes some stuff (like unittests) breaks.In the same time, is there someone who knows where to find a good style guide for D, something like the PEP for python?A starting point: http://dlang.org/dstyle.html Bye, bearophile
Jul 20 2014
On 7/21/2014 7:13 AM, Matthieu wrote:Hi! I can't find any good tutorial about how to split my source code in modules and packages. I don't want to use a Java splitting style (one class per file) or something like that, I want to use the D way, but it's so hard to find it! Can someone explain to me how to do it well, please?I don't think there is a "D way." It's a matter of personal preference. I don't like to see huge modules, so I prefer to keep them small. But what is a reasonable level of separation for me may not be the same for you. Just go with what feels natural to you. --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
Jul 20 2014
Hi, Thanks for your answers. I'll continue to code as I ussed to do, and try to improve my style to have a better usage of the modules (today i'm most one class per file, so I don't use the modules at all). Bye, Matthieu
Jul 21 2014
Matthieu:Thanks for your answers. I'll continue to code as I ussed to do, and try to improve my style to have a better usage of the modules (today i'm most one class per file, so I don't use the modules at all).Also, try to use less classes and more free (pure) functions :-) This means a little more functional style. Bye, bearophile
Jul 21 2014
Probably most idiomatic D way is to use files _instead_ of classes :) It is a bit idealistic though and is not yet 100% feasible in practice.
Jul 21 2014
Dicebot:Probably most idiomatic D way is to use files _instead_ of classes :) It is a bit idealistic though and is not yet 100% feasible in practice.What's stopping it from being feasible? Bye, bearophile
Jul 21 2014
On Monday, 21 July 2014 at 18:02:33 UTC, bearophile wrote:Dicebot:Stuff like this : http://forum.dlang.org/post/mailman.57.1405963972.32463.digitalmars-d puremagic.com Also infamous private name clash issue.Probably most idiomatic D way is to use files _instead_ of classes :) It is a bit idealistic though and is not yet 100% feasible in practice.What's stopping it from being feasible? Bye, bearophile
Jul 21 2014