Writers block on complex object model

Discussion in 'Java' started by Phy6, Nov 5, 2007.

  1. Phy6

    Phy6 Guest

    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?
     
    Phy6, Nov 5, 2007
    #1
    1. Advertising

  2. Phy6

    Roedy Green Guest

    On Mon, 05 Nov 2007 16:33:51 -0000, Phy6 <> wrote,
    quoted or indirectly quoted someone who said :

    >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?
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Nov 5, 2007
    #2
    1. Advertising

  3. Phy6

    Lew Guest

    Phy6 wrote:
    > 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() )

    --
    Lew
     
    Lew, Nov 5, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish

    closing writers and outputstreams

    Andy Fish, Nov 13, 2003, in forum: Java
    Replies:
    1
    Views:
    510
    Thomas Weidenfeller
    Nov 13, 2003
  2. Duke Hamacher

    APIs for SAX writers

    Duke Hamacher, Oct 12, 2004, in forum: XML
    Replies:
    3
    Views:
    386
    Donald Roby
    Oct 14, 2004
  3. M.Kumar

    Advanced C++ writers

    M.Kumar, Aug 1, 2004, in forum: C++
    Replies:
    3
    Views:
    404
    Julie
    Aug 2, 2004
  4. morrell
    Replies:
    1
    Views:
    967
    roy axenov
    Oct 10, 2006
  5. dale

    Writers Block

    dale, Feb 15, 2008, in forum: Perl Misc
    Replies:
    11
    Views:
    168
Loading...

Share This Page