Hi,
‘keep classes small’ is the idea, how do you break down big classes?
I have a big class with a rather large cohesion, I could break it down in a few smaller classes but they would still need each other often.
So I could either add the smaller classes inside one main (small) class or I could setup some kind of tracking of which object refers to which other object (which is an administrative nightmare)
Or alternatively you could think of a wrapper class (for 3th party hardware, or DB, etc). Sure you can only wrap the functionality you like or you could perhaps break it down in a few smaller classes based on functionality but in the end… do you have classes inside classes or do your main objects have the various classes as their children and do you keep track on what is where elsewhere (hope you get my drift…)
Wondering how you do this/feedback…
Hi Guys,
Thank for the book tip Dave, i ordered it (the old fashioned way).
I don’t really have a hard time to extract smaller classes from bigger ones, but I wonder what the best way would be (after you extract them) to have them work together.
Since some classes/data simply have a strong coupling (which was the reason it was in 1 big class to start with).
You may end up with one class owning multiple smaller classes which is more or less the same, or you may end up splitting the (highly coupled data) in multiple classes but then you have to keep track on which data belongs to what…
Think of the example of a piece of hardware.
Or think of a simple control like the windows button or listbox, etc, both are not exactly small classes, if you look at the properties alone…
So how would you break down a standard (MS) button class in smaller classes???
Regards.
--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.
Visit this group at http://groups.google.com/group/clean-code-discussion.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discussion+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
ok so bottom line, is you are saying (correct me if i'm wrong), put that big fat mama (the big class) on a diet (hmm, force a child birth) and this new skinny mama will have (own) multiple smaller child classes, correct? ;-)
other (related) toppic but what are your thougts on Ian Coopers presentation? (see here http://vimeo.com/68375232 ) basically in this case you wouldn't have to change your tests (if i had any to start with) since the 'skinny mama' would still have the same interface, so that would make sense...
That's exactly what I've been doing for the last couple of days.
Making inner classes to group closely related code together and then promoting them to top level classes.
Coupled with aggressively extracting methods I've cleaned up the code a lot and found one major bug.
And this is new code to replace the legacy code... I wish the rest of my team did TDD and cared about clean code... But that's another story...
Tristan
--
The only way to go fast is to go well.
--- You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discussion+unsub...@googlegroups.com.
To post to this group, send email to clean-code-discussion@googlegroups.com.