|
Well i'm well on the way of getting back to where i was before changing the architecture. It's quite a lot of work still but the code becomes incredibly more maintainable. Hundreds of dependencies just disappears. Anyway, one thing is causing me trouble. Like said here const is really infectious and I'm starting to spend lots of valuable time converting things to const through long hierachies of classes just because C++ can't hide non-const objects calls behind const functions called in controller->outputs. Is this how you deal with it? Making sure all get-functions are const everywhere? Well i'm considering skipping the const on the model parameter in the controllers output functions because i have better things to do with my time I guess this is just a rant because of disappointment on the bad handling of the const return values in c++ but feel free to share your experiences anyway... |
Submitted by SolidBenny
Wed, 08/19/2009 - 16:12
|

I'm already making sure i do all the changing in controller input, within the model and in its update function so the code should be nice anyway.
Yeah I remember it being a
Yeah I remember it being a bit of a pain "consting" everything before I got used to it. Nowadays it's actually nothing I think about and more and more of my stuff is getting "consted".
But yes, sometimes it's more work than it's worth... esp. when working on an existing code base. I'd take it step by step adding the const when and where it seems appropriate.
There is some special keyword you can use to have things const in the declaration but yet change members, I can't remember it now though (possibly "mutable") but searching the VC help should solve that.
yeah i can imagine it being
yeah i can imagine it being pretty ok if its all built like that from the start. and it actually went pretty smooth for a while but now it started affecting really big stuff and i started thinking i could do something better with my time.
yeah the site i linked mentioned mutable but i didn't look into it anymore. maybe i should check it out. i didn't get the impression it solved my problem though.
---------------
Solid Core Entertainment
Developer of Roadclub and Sense: Survival Prelude (Developer blog)
I like it
The whole const thing (references and methods) is imho a major (good) feature of C++. It helps to enforce design decisions.
I would personally bite the bullet and be consistent, but that's of course subjective.
/johno
"you can't stop the change"
You should pretty much
You should pretty much always const declare everything per default, and then take the time to think things through when you want to remove them. But since you already have a code base up and running I'd say do a little at a time, and when you add new code make sure at least that uses const per default.
______________________________________________________________
There's no kill like an overkill!
Yeah i agree that its a good
Yeah i agree that its a good thing and it keeps you doing the right things. I think its a bit TOO restricting when you can't have non-const stuff behind a const call though. Get-functions probably mostly works as const but i seldom use them to change anything anyway.
I'd prefer to be strict like johno but i'm back to work on monday and i'd like to get another iteration out there as soon as possible. spending these days consting my whole codebase doesn't feel like a good way of spending them
I'm doing like malice suggests and try to keep const wherever possible and make the new code better and maybe i'll take another crack at purifying it later.
---------------
Solid Core Entertainment
Developer of Roadclub and Sense: Survival Prelude (Developer blog)
Post new comment