digitalmars.D - Split D class file
- B.Schulte (3/3) Sep 22 2007 Hi!
- BLS (3/8) Sep 22 2007 ... answering without thinking too much... probabely Mixin templates.
- redsea (2/10) Sep 22 2007
- BLS (4/17) Sep 23 2007 Well that's not a big deal IMO. In case that it is "mission critical"
- Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= (4/12) Sep 23 2007 Inheritance, composition and mixins are quite common design patterns in ...
- BLS (6/20) Sep 23 2007 Was my first idea too. Means having a fat class is more an design issue
- Robert Fraser (2/3) Sep 23 2007 I'll need to see how the code coverage ABI works, but it might be more t...
- Jarrett Billingsley (8/16) Sep 23 2007 It keeps what amounts to a large static array of ints (longs?), and inse...
- Robert Fraser (2/23) Sep 23 2007 I _was_ assuming it already did these things, but now I'm assuming not.....
- Jarrett Billingsley (7/8) Sep 23 2007 Don't know about all possible cases, but a simple test using a templated...
- Chad J (25/30) Sep 23 2007 Just to make sure it's clear, here's how it's done with mixins:
- =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= (23/28) Sep 24 2007 I think you need Partial Class Definition. It has been requested before
Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.
Sep 22 2007
B.Schulte schrieb:Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.... answering without thinking too much... probabely Mixin templates. Bjoern
Sep 22 2007
code coverage report can not support mixin template :( BLS Wrote:B.Schulte schrieb:Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.... answering without thinking too much... probabely Mixin templates. Bjoern
Sep 22 2007
redsea schrieb:code coverage report can not support mixin template :(Well that's not a big deal IMO. In case that it is "mission critical" write adequate intermediate functions instead. Or do I miss something ?BLS Wrote:B.Schulte schrieb:Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.... answering without thinking too much... probabely Mixin templates. Bjoern
Sep 23 2007
B.Schulte wrote:Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.Inheritance, composition and mixins are quite common design patterns in OO languages. D also has hybrid member/free functions. If none of those help, you probably have a major problem in the program design.
Sep 23 2007
Jari-Matti Mäkelä schrieb:B.Schulte wrote:If none of those help,Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.Inheritance, composition and mixins are quite common design patterns in OO languages. D also has hybrid member/free functions.you probably have a major problem in the program design.Was my first idea too. Means having a fat class is more an design issue than an language related prob. But since I am going to translate a MFC like GUI using a lot of GDI wrapper functions I am not that sure. ;-) Bjoern....
Sep 23 2007
redsea Wrote:code coverage report can not support mixin template :(I'll need to see how the code coverage ABI works, but it might be more than possible that code coverage for those lines are tracked but there's no way to display it. If that's the case, some IDE might someday be able to expand the templates inline and ho coverage, or alternatively aggregate this data and show coverage for an entire template (and maybe use pretty colored lines to do so if you ask nice). "someday" being the keyword.
Sep 23 2007
"Robert Fraser" <fraserofthenight gmail.com> wrote in message news:fd6odt$14qt$1 digitalmars.com...redsea Wrote:It keeps what amounts to a large static array of ints (longs?), and inserts an "inc [address of counter that corresponds to this line]" instruction after each line of functional code. To that end, it'd have to keep track of every instantiation of a template, be it mixed in or whatever, and count all those instantiations' lines separately. It'd probably also have to indicate which instantiation of the template each line count was for.code coverage report can not support mixin template :(I'll need to see how the code coverage ABI works, but it might be more than possible that code coverage for those lines are tracked but there's no way to display it. If that's the case, some IDE might someday be able to expand the templates inline and ho coverage, or alternatively aggregate this data and show coverage for an entire template (and maybe use pretty colored lines to do so if you ask nice). "someday" being the keyword.
Sep 23 2007
Jarrett Billingsley Wrote:"Robert Fraser" <fraserofthenight gmail.com> wrote in message news:fd6odt$14qt$1 digitalmars.com...I _was_ assuming it already did these things, but now I'm assuming not...redsea Wrote:It keeps what amounts to a large static array of ints (longs?), and inserts an "inc [address of counter that corresponds to this line]" instruction after each line of functional code. To that end, it'd have to keep track of every instantiation of a template, be it mixed in or whatever, and count all those instantiations' lines separately. It'd probably also have to indicate which instantiation of the template each line count was for.code coverage report can not support mixin template :(I'll need to see how the code coverage ABI works, but it might be more than possible that code coverage for those lines are tracked but there's no way to display it. If that's the case, some IDE might someday be able to expand the templates inline and ho coverage, or alternatively aggregate this data and show coverage for an entire template (and maybe use pretty colored lines to do so if you ask nice). "someday" being the keyword.
Sep 23 2007
"Robert Fraser" <fraserofthenight gmail.com> wrote in message news:fd6osr$15j1$1 digitalmars.com...I _was_ assuming it already did these things, but now I'm assuming not...Don't know about all possible cases, but a simple test using a templated function shows that it collapses the counts for all instantiations of the template into one. So if you call three separate specializations of the templated function, it'll show (in the listing) the templated function having been called three times, instead of splitting up the specializations.
Sep 23 2007
B.Schulte wrote:Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.Just to make sure it's clear, here's how it's done with mixins: // file 1, main.d or whatever import std.stdio; import second; void main() { Big biggy = new Big(); } class Big { this() { writefln(getDescription()); } mixin BigPeice!(); // getDescription() ends up defined here. } // file 2, second.d template BigPeice() { char[] getDescription() { return "Big is a hypothetically very big class and must be split."; } }
Sep 23 2007
Hi B.Schulte wrote:Hi! Is it somehow possible to store some methods of a class in another D file? The class is really getting too big. Well, maybe some of you suggest me to split the class in multiple ones, but this class is important to be one part. The only way would be to have many many friend classes. But that's also very strange.I think you need Partial Class Definition. It has been requested before but hasn't got much traction: http://www.digitalmars.com/d/archives/digitalmars/D/14513.html http://www.digitalmars.com/d/archives/digitalmars/D/Partial_class_implementation_55745.html I think it's a very useful feature for external code generators. For example: * GUI code generated by a form designer stored in a Form.designer.d file. * Record structures generated from official specs (Something I've wonders). * Model classes generated from a Database Schema. Very useful when the schema changes and you have to update your database. * etc... I would really love to hear how difficult it would be to implement on DMD or GDC because I really have no idea. Adding it to the language is another matter. Cheers. -- Julio César Carrascal Urquijo http://jcesar.totumo.net/
Sep 24 2007