Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Writers block on complex object model

Thread view: 
Phy6 - 05 Nov 2007 16:33 GMT
Hi, I am trying to find an easily extended way to write compose
concrete objects for my application.

The objects I am using are all things (nouns) like Customer, Database,
Shop, Task, Year, etc. etc.  LOTS of classes like this.

I have GUI components (Tapestry) that display messages regarding the
object or objects.

I want to be able to do something like Customer.plural to get the
String "Customers".  I'd like these conjugates available statically,
so no instance is needed (In case the object is null)
I have 4 conjugates for each noun: singular, plural, singular
possessive, plural possessive.

Furthermore, sometimes the GUI components can work on many different
types of these objects, so the class should not be hard-coded in the
component.  It should code something like:
Noun.plural to get the String "Customers"
But we can't override static fields.

Of course the concrete classes each have unique fields, along with a
getLabel() method which generates a String for identifying each
instance.
They also have getId() which is a code that uniquely identifies the
object (used for compare,equals,hashcode)

Any Ideas?
Roedy Green - 05 Nov 2007 21:22 GMT
>Of course the concrete classes each have unique fields, along with a
>getLabel() method which generates a String for identifying each
>instance.

You need a Grammar class that takes a root and produces the various
variants.  You write your rules then have HashMap of exceptions that
you add to as you discover them when the rules fail.

Your static methods would be wrappers for this Grammar class.

You might use Class.getName to get you the root string.

What is the slickest way to get hold of the Class object for the
current class in a static method?  an instance method?
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 05 Nov 2007 21:53 GMT
> Hi, I am trying to find an easily extended way to write compose
> concrete objects for my application.
[quoted text clipped - 10 lines]
> I have 4 conjugates for each noun: singular, plural, singular
> possessive, plural possessive.

How about a ResourceBundle that defines each of those four names off a key for
each class?  The class can look up its plurals and possessives for display
purposes.

bundle.getString( Task.getPluralPossessiveKey() )

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.