Brainiacs: Methodology to choose best of many class to handle abstract data

Discussion in 'Java' started by arieljake, Feb 8, 2005.

  1. arieljake

    arieljake Guest

    I am creating a program that will be handling files from potentially
    numerous sources. I will be extending a base Parser class for each
    possible source of data to extract data in a manner specific to the
    format of the File. Along with a parse(File) function, the Parser
    objects will also have a canParse(File) function.

    What I am looking for is to build a framework that will allow me to
    update the overall program by adding new sub-classes of Parser with
    ease. The Parser objects once created will not change much. Just the
    number of Parser object to be considered for parsing data.

    How can I "register" these Parser modules so that the appropriate
    Parser class can be requested to parse my data?

    Possible options I have thought of: a database with fields to be
    queried, a properties file, neural networks (though I don't know how
    yet), or simply a ton of if/else statements.

    Given certain characteristics and "header" attributes of the File, how
    can I efficiently determine the best Parser class to handle my data?

    thank you,

    Ariel
     
    arieljake, Feb 8, 2005
    #1
    1. Advertising

  2. arieljake

    Guest

    Look into Factory or Abstract Factory design pattern. Google around
    for "Gang of four" or design pattern in general. There is a large
    number of creation patterns that people use for these situations.
     
    , Feb 9, 2005
    #2
    1. Advertising

  3. arieljake

    arieljake Guest

    Thank you very much for the direction. For those that find this article
    in the future, here is an indication of how perfect of a solution the
    "Factory design Pattern" is for this question:

    >From "http://gsraj.tripod.com/design/creational/factory/factory.html":


    The Problem
    One of the goals of object-oriented design is to delegate
    responsibility among different objects. This kind of partitioning is
    good since it encourages Encapsulation and Delegation.

    Sometimes, an Application (or framework) at runtime, cannot anticipate
    the class of object that it must create. The Application (or framework)
    may know that it has to instantiate classes, but it may only know about
    abstract classes (or interfaces), which it cannot instantiate. Thus the
    Application class may only know when it has to instantiate a new Object
    of a class, not what kind of subclass to create.
    a class may want it's subclasses to specify the objects to be created.
    a class may delegate responsibility to one of several helper subclasses
    so that knowledge can be localized to specific helper subclasses.

    The Solution
    Factory Method...
     
    arieljake, Feb 9, 2005
    #3
  4. arieljake

    arieljake Guest

    Thank you very much for the direction. For those that find this article
    in the future, here is an indication of how perfect of a solution the
    "Factory design Pattern" is for this question:

    >From "http://gsraj.tripod.com/design/creational/factory/factory.html":


    The Problem
    One of the goals of object-oriented design is to delegate
    responsibility among different objects. This kind of partitioning is
    good since it encourages Encapsulation and Delegation.

    Sometimes, an Application (or framework) at runtime, cannot anticipate
    the class of object that it must create. The Application (or framework)
    may know that it has to instantiate classes, but it may only know about
    abstract classes (or interfaces), which it cannot instantiate. Thus the
    Application class may only know when it has to instantiate a new Object
    of a class, not what kind of subclass to create.
    a class may want it's subclasses to specify the objects to be created.
    a class may delegate responsibility to one of several helper subclasses
    so that knowledge can be localized to specific helper subclasses.

    The Solution
    Factory Method...
     
    arieljake, Feb 9, 2005
    #4
    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. Matthias Kaeppler
    Replies:
    1
    Views:
    469
    R.F. Pels
    May 22, 2005
  2. Sameer
    Replies:
    4
    Views:
    630
    Roedy Green
    Aug 31, 2005
  3. Uzytkownik
    Replies:
    3
    Views:
    610
    Uzytkownik
    Apr 3, 2005
  4. Iyer, Prasad C

    Abstract Methods & Abstract Class

    Iyer, Prasad C, Oct 20, 2005, in forum: Python
    Replies:
    0
    Views:
    549
    Iyer, Prasad C
    Oct 20, 2005
  5. Replies:
    4
    Views:
    863
    Rolf Magnus
    May 17, 2006
Loading...

Share This Page