aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Smelling the smell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Smelling the smell" Watch "Smelling the smell" New topic
Author

Smelling the smell

Roshan Lal
Ranch Hand

Joined: Nov 13, 2001
Posts: 64
Good Morning Everyone,

A new requirement has just come up to us, from our internal customers. It says to create new types which are identical to some existing ones except the names. Now, these classes are just data classes, no behaviour. Basically, they correspond to MS Word templates. The data members of the classes are fields in the word templates.

The first question I asked why such a new type is needed which differs from the existing one only in name .They said these new types are just "for tracking purposes". The documents (objects) corresponding to the existing type (word template), they use for their own purpose but the new documents(in the new type/template) would be sent to the end customer (external customers).

We are scheduled to have a meeting to discuss these. However, I would like to have others' opinions on this whether having two types differ only in name is ever a good idea. If other poeple came across such issues.
The only thing I'm currently inclined to decide is not to inherit the new class from existing one, even if the data members are identical, allowing the possibility of removing or changing attribute types.

Thanks
Roshan
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Why do those customers know about the classes at all? What kind of interface are they using to your system?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Roshan Lal
Ranch Hand

Joined: Nov 13, 2001
Posts: 64
Originally posted by Ilja Preuss:
Why do those customers know about the classes at all? What kind of interface are they using to your system?


They create documents of different types using different templates. Using a web interface they select desired document type (for each type there is a pre-defined template) so they have to know the document type. Using the template they create their document (the content) and upload/checkin them. To later search these document they have to fill-in the meta-data about these documents e.g state (draft, reviewed, approved), reviewer, review-date, end client firm name, end client firm size, dozens of such fields. So far, the number and types of these meta-data fields are different for different documents types.
Now they want to have another document type which differs from an existing document type only in type-name, that is where I am having doubts. The only reason they say they want to have such a document type and not use an existing one with identical meta-data fields, is for tracking purpose. The documents of this new type would be sent to their client firms, the documents created using existing type is not sent to the client firms.
Of course it is possible to add another meta-data boolean field in existing document type saying sent to their client or not. They prefer a new type over having added another flag. I'm debating whether it is good idea at all to have two document types with identical meta-data. These meta-data fields are member fields in our class so if we go by our users' request, we would have to store these meta-data in a class which is identical to an existing one except different name.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Can you not just extend the old class with the new one?



That way you get all the fields and behaviour of the old class with a new name, but with no duplicated coding.

Or have I missed the point?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Roshan Lal
Ranch Hand

Joined: Nov 13, 2001
Posts: 64
Originally posted by Frank Carver:
Can you not just extend the old class with the new one?



That way you get all the fields and behaviour of the old class with a new name, but with no duplicated coding.

Or have I missed the point?


Thanks Frank for your comment. I suspect they will change their mind and may want to remove some of the data members in the new type which are present in the existing type, that is the main reason for not inheriting from the existing type.

This requirement is in very preliminary stage. I am going to meet them in person in couple of days and hope to find more reasons they are asking for a new type. The current reason given, "only for tracking purpose", does not look good enough.

Thanks
Roshan
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It sounds to me like you have a one-to-one mapping of document types to Java classes? Perhaps it is time to give up that correlation?

It seems to me like you are feeling the pain of mixing a business decision (should there be a new document type) with a technical decision (should there be a new class). If it makes sense to the users to introduce a new document type, but it doesn't make sense technically to introduce a new class, it sounds to me like the most reasonable thing to do is finding a way to introduce a new document type without having to introduce a new class.

How does that sound to you?
Roshan Lal
Ranch Hand

Joined: Nov 13, 2001
Posts: 64
Originally posted by Ilja Preuss:
It sounds to me like you have a one-to-one mapping of document types to Java classes? Perhaps it is time to give up that correlation?

It seems to me like you are feeling the pain of mixing a business decision (should there be a new document type) with a technical decision (should there be a new class). If it makes sense to the users to introduce a new document type, but it doesn't make sense technically to introduce a new class, it sounds to me like the most reasonable thing to do is finding a way to introduce a new document type without having to introduce a new class.

How does that sound to you?


You are quite right, Ilja. Technically it does not make much sense to introduce a new type but for business people it probably does. The comment
"finding a way to introduce a new document type without having to introduce new class" is interesting. I'll look into it.

Thanks again
Roshan
Ricky Clarkson
Ranch Hand

Joined: Jul 27, 2006
Posts: 131
It might be simpler to introduce factory methods. Then instead of adding a new type, just add a new factory method that does the same thing. Unfortunately, you can't sensibly get rid of duplication if it exists in the requirements.

It would be worth working on the requirements, get rid of the duplication there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Smelling the smell
 
Similar Threads
I don't see an advantage of Generics of Java 5 here!
My two bits
Looking to find a solution
why java has single rooted hierarchy?
The power of scripting languages