Includes anywhere

BlitzMax Forums/BlitzMax Programming/Includes anywhere

JoshK(Posted 2007) [#1]
I have a rather large type...a TRenderer...that I want to split up into multiple include files. It would be nice if I could just include a file anywhere, even in the middle of a type. I don't see any reason the preprocessor would have a problem with this.


Gabriel(Posted 2007) [#2]
Agreed. Types can easily get very big and in order to split them up you currently have to extend them, which is a bad practice when they shouldn't really be inherited. Being able to include in the middle of a Type ( even if an alternative keyword had to be used for some reason ) would be very handy.


tonyg(Posted 2007) [#3]
Isn't there an argument that, once a type has so many attributes, it is better practice to collate associated attributes their own type?


JoshK(Posted 2007) [#4]
I don;t have a lot of fields. I have a few methods, each of which contain a large amount of code.


Jim Teeuwen(Posted 2007) [#5]
From an OOP standpoint, if a type becomes unmanageably large, it can often be divided up into separate types as it probably contains code that has nothing to do anymore with the actual purpose of the class.

When creating a class, decide carefully what exactly it's purpose is and make sure that the code in it serves only that purpose.

I know it is convenient to 'just add this and that' at times but it runs the risk of creating a class that is ambiguous in it's use.

Ofcourse it is always possible to stick to these rules and still get a class that is just so damn huge it becomes hard to maintain, but tbh in my 6 years of OOP programming I have never had that happen to me.
I did create some large classes, but careful consideration showed that I had broken those rules and the class could easily be made more manageable by taking out unrelated parts and giving them their own classes.

Classes that become too complex to handle are more often the result of design mistakes on the developers side, then they are out of necessity.


JoshK(Posted 2007) [#6]
That's stupid. Why would I break the renderer up into separate classes?


Dreamora(Posted 2007) [#7]
Because a renderer doesn't work in a single step nor do the GPU pipelines ...
This would allow a logical and powerfull seperation and make the code far more manageable (and potentially make it worlds easier to fix code which isn't possible with a few tousand lines in a single method. A few hundred wouldn't need a new file, scope folding is enough to handle < 10'000 line files)


FlameDuck(Posted 2007) [#8]
Isn't there an argument that, once a type has so many attributes, it is better practice to collate associated attributes their own type?
Yup. The principle of high coherency, low coupling.