Writers block on complex object model

P

Phy6

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?
 
R

Roedy Green

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?
 
L

Lew

Phy6 said:
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.

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() )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top