redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers

Ask your IT question here

design problem


Goto page 1, 2  Next
 
Post new topic   Reply to topic    Programming Forums -> JAVA programming forum
View previous topic :: View next topic  
Author Message
Peter Pitt
Enthusiastic Coder


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?

Reply with quote
 
plantino
Enthusiastic Coder


Joined: 13 May 2006
Posts: 96
Peter Pitt, try to use Decorator pattern
Reply with quote
 
Klimapol
Enthusiastic Coder


Joined: 27 May 2006
Posts: 134
Use interfaces.
Reply with quote
 
Peter Pitt
Enthusiastic Coder


Joined: 20 May 2006
Posts: 114
Location: Egypt
Klimapol, how would that stop my classes getting bloated?
Reply with quote
 
Klimapol
Enthusiastic Coder


Joined: 27 May 2006
Posts: 134
They'll start to encourage better behaviour.
Reply with quote
 
Peter Pitt
Enthusiastic Coder


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

Reply with quote
 
plantino
Enthusiastic Coder


Joined: 13 May 2006
Posts: 96
Peter Pitt, it is depends on what you want
Reply with quote
 
Peter Pitt
Enthusiastic Coder


Joined: 20 May 2006
Posts: 114
Location: Egypt
what I really want is for new functionality not to make my class unmaintanable
Reply with quote
 
plantino
Enthusiastic Coder


Joined: 13 May 2006
Posts: 96
Peter Pitt, unmaintainable ? could you provide more info ?
you can extract interface or use facade ...

Reply with quote
 
Peter Pitt
Enthusiastic Coder


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?

Reply with quote
 
Page 1 of 2 Goto page 1, 2  Next
Post new topic   Reply to topic    Programming Forums -> JAVA programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group