| View previous topic :: View next topic |
| Author |
Message |
Peter Pitt
Joined: 20 May 2006 Posts: 114 Location: Egypt
|
Hi everyone, I'm having a bit of a design problem and want a bit of advice. A have a class called Product. On that class I have three functions, getById, getByName and getByDate. As the project goes developers keep adding functionality to the class, getByDateAndId() ... etc
Soon the class has loads of functions in it and it's unmaintainable
So what can I do to stop that happening? |
| |
|
|
|
|
plantino
Joined: 13 May 2006 Posts: 96
|
| Peter Pitt, try to use Decorator pattern |
| |
|
|
Klimapol
Joined: 27 May 2006 Posts: 134
|
| Use interfaces. |
| |
|
|
Peter Pitt
Joined: 20 May 2006 Posts: 114 Location: Egypt
|
| Klimapol, how would that stop my classes getting bloated? |
| |
|
|
Klimapol
Joined: 27 May 2006 Posts: 134
|
| They'll start to encourage better behaviour. |
| |
|
|
Peter Pitt
Joined: 20 May 2006 Posts: 114 Location: Egypt
|
Klimapol, does't matter, I've just realised I'm not that stupid
indeed
Klimapol, they do do that but it would stop a developer adding a new function, thus the classes getting bloated
S/would/wouldn't/
plantino, so basically add a wrapper class which gets bloated but doesn't mess up my original class |
| |
|
|
plantino
Joined: 13 May 2006 Posts: 96
|
| Peter Pitt, it is depends on what you want |
| |
|
|
Peter Pitt
Joined: 20 May 2006 Posts: 114 Location: Egypt
|
| what I really want is for new functionality not to make my class unmaintanable |
| |
|
|
plantino
Joined: 13 May 2006 Posts: 96
|
Peter Pitt, unmaintainable ? could you provide more info ?
you can extract interface or use facade ... |
| |
|
|
Peter Pitt
Joined: 20 May 2006 Posts: 114 Location: Egypt
|
Well when I implement Product it'll be clean and short (maintainable). As time goes by my boss is going to as for, say a list of Products order by Date which are red, so the developer that's doing that will create get(colour, 'date')
So that's another function
I'm worried about lots of functions appearing in my class and it becoming 1 million lines long
Thus, unmaintanable
Or am I worrying about nothing? |
| |
|
|
| Page 1 of 2 |
Goto page 1, 2 Next |
|