Design Pattern Names

Started fooling around with some industry-specific software implementations. In one software design document, I came across a reference to an old familiar term "design patterns". This part of the text was describing XML Schema Design Patterns. Below is the first paragraph, which made me laugh :o)
"As with software design, there are design patterns associated with XML Schema design. The most popular XML Schema design patterns are Russian Doll, Salami, Bologna, Venetian Blind and Garden of Eden."
Unlike the GoF, these guys seem to be hungry....
Anybody have any experience implementing the Bologna design pattern?

I agree with dubwai's take on this. These are not design patterns, in my opinion. These are language-specific, very defined, programming algorithms for handling a few typical issues with processsing XML-based data.
To label these as "design patterns" is a bad thing and just another step to adding to the confusion of what an object-oriented design pattern really is.
Moreover, the name of an object-oriented design has a very important role. Care should be taken when naming a design pattern; a name should convey the meaning or intent of the pattern. To call a "design pattern" Salami Slice is a joke, in my opinion.
One of the most important aspects of design patterns is that they are NOT specific, coded solutions to any problem. And, they are design tools to guide the process of designing software. Implementation details are outside the scope of design patterns.
Generally, I find that these work well with the Provolone and SandwichOil patterns. lol

Similar Messages

  • Name of the design pattern

    Hi
    I have been studying a piece of code somebody else wrote. I am wondering if this is the Factory Method design pattern that this represents. I am new to patterns and I would be very thankful for any suggestions.
    public class Creator {
         public Person create(String gender) {
              if (gender.equals(�M�)
                   return new Male();
              else if (gender.equals(�F�)
                   return new Female();
              else
                   return null;
    thanks in advance

    Yes, you are right this is a Factory Method creational design pattern.
    See http://en.wikipedia.org/wiki/Factory_method_pattern for more information.
    Ussualy class which is used to create instances of other classe called XXXFactory and implemented as singleton.
    Regards,
    Yevhen

  • Does any body have any design patterns of JSF Web Application Developping?

    Can any one answer me some questions?
    #1.I am an amatuar of people who develop Web Application.For some reason,We choose the JSF to develop our item.through some introduction,I know the UI component of JSF is resided in Server side,is it right?but I am a little confused that:if there are many users who are exploring our jsf website.(to simplify my question,image I had just one web page and just one button)How many UI components(buttons) will be there?How it(they?) works?
    #2.Does any body have the success experience (for example design pattern)to develop web applications?if We just concern about the Add,Delete,Modify,Query operations of some data.
    I just do my job according to my feeling.
    I will give every page a pagebean(backing bean),and I am not sure how to combine the business data with the pagebean.some one suggested that I should use delegate pattern to separate my business log and page logic.But I am still confused by following things:
    #2.1 does JSF have the same ability to help us construct the model dialog just like swing to
    help us control the operation flow?
    #2.2 If there is not,Does the following way work?I put every tabledata's property as corresponed component.if user choosed the row in the table,My Listener will syncronize the row data to the components.But
    #2.2.1 if JSF has the components according to the web users' number,how can My Listener tell which component should be update?Should I maintain the map?
    #2.2.2 If the problem I imaged above is false,Does any body can tell me how to custom      the ListDataModel,so I can use it like Swing?because now I can just use some view data to insert into ListDataModel,but after some selection operation,my business object must be find according to the selected data,it is not an interesting job!
         I am waiting for your advice!

    Ok I'll try to explain Step by step please correct me if I make any mistake because I have not played much with shared variables.
    To create a shared variable to an RT target go to the target if tou have already otherwise add an RT target by right clicking the Project>>Add targets and Devices
    Then in the target Right clikc and select the variable as shown below.
    Then once the Shared variable settings window opens Enter a variable name and then Select the type "Network Published"
    In the right side you can select the data type for the shared variable and even you can choose your custome controls.
    After selecting the data type go for the Network and select buffering if required else leave it if you are planning to use the variable just for display purpose.
    Then you can enable the RT FIFO if required (Not able to explain how it works and why it is used).
    Then after completing the Shared variable setup you can access the variable in the VI in both the Host and the RT.
    You can bind the variable to a control so that if any data from the RT is coming you can read the data from that control.
    Once you have placed your shared variable in the BD you can change the access typr to read or write depending on your need.
    This might not explain the complete shared variable concept but I believe that this would defenelty give you a kick off to start using the shared variable. Please correct or add more comments if anybody know better.
    Good luck.
    The best solution is the one you find it by yourself

  • Design patterns for updating a fact table

    I have a fact table and about 10 dimensions.
    One of these dimensions can be missing values, so the fact table row will link to an UNKNOWN value.
    When the correct value is finally entered in the dimension table i want to update any associated fact rows.
    Whats the most efficient way of doing this?

    I know i have to use a lookup transformation ;-) 
    I wouldnt be at teh stage of even having a fact table if i didnt know that! I was looking for a design pattern, not the name of a shape!
    The solution i went with was to take a hard line on any rows with unknown values. If when importing the data there are unknown values for two of the most important dimensions, those rows are not inserted into the fact table, but instead pushed to an ErrorLog
    table.
    Users run a report that shows what this table contains and if they really want those rows, they insert the correct dimension values and rerun the import, which will only import any rows not already in the fact table.
    This way:
    1. all sorting & filtering issues are resolved as there will be no unknown rows for the most important dimensions used in sorting and filtering.
    2. we can quickly see any rows with unknown values and figure out whats wrong. its always missing reference data that the client didnt think to give us. a quick insert of the dimension data and import and the rows get imported.
    thanks for the replies.

  • JavaBean Models, Command Bean and J2EE Design Pattern

    Hello,
    I have read the available "How To", “Using EJBs in Web Dynpro Applications” where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.
    I have developed a WD App which uses EJBs to read data from the DB.
    Let's suppose I only have two tables: BOOKS and AUTHORS.
    Let’s also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();
    I also have a Command Bean which I imported in my WD App.
    My questions are:
    How should I design my Command Bean?
    Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?
    Or instead should I design two Command Beans, one for each call?
    In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?
    Furthermore, how should I store the data in my command bean? In instance variables?
    If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?
    I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.
    One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?
    I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.
    Some guidance or tips would be highly appreciated.
    King Regards

    I have the same problem.
    Does anyone know the solution?
    Thanks
    Davide

  • Is this a good design pattern?

    Hi,
    I am working with a team to create an application that can acquire data from up to 24 thermcouple channels.  We plan to create a wizard to assist the user in setting up the test (specifiying stop conditions, sample rate, channels to sample, output file, and email/text notifications).  After the setup, if the user does not cancel out, then the program continues.  We have defined parallel loops and their roles, trying to fit into a producer/consumer design pattern.  I have attached the main file which shows the structure of the program.  We are trying to keep it clean and modular.  Before diving into development, we are finalizing a detailed design specification so that different people can work on each of the loops' subvis.  I was hoping that people could review the block diagram and offer suggestions for improvement or validate that we have chosen a good method of implementation.
    Notes about the block diagram
    The plan is for data driven stop conditions to be detected by Event Notifier, handled by the Main UI event, and then the Data Collector is instructed to stop (as well as the Main UI loop).  When Data Collector stops, it releases queues, the queue reference becomes invalid, and then the loops with the Dequeue will be stopped.
    I am not sure if an additonal event structure should be in the DataCollector to specifically handle the Stop button on the UI because if it is in the Main UI event structure, the DataCollector would not be stopped immediately.  This is important to stop quickly because the sample rate could be VERY long.  I understand about using an event structure instead of WAIT, but didn't know if there is an efficient way leaving it down in the Main UI event structure....????
    Data Collector is the producer, it currently only collects data and passes it on.  If the program is going to contain a start collection button, or pause/resume, I need to figure out how to handle this with the Main UI event structure.
    Event Notifier consumes data from the Data Collector.  It looks at all data and should set a flag if a stop condition is met.  The flag will be handled by the Main UI event structure to tell Data Collector to stop.  The event notifier also sends a notification to the Email/Text Caller when thresholds have been exceeded warranting a reason for the user to be notified via text or email.
    Email/Text Caller waits for notification and then calls a subVI to send an email or text with certain data and channel information.  The subVI call is lengthy, so we decided to put this in its own loop instead of a case structure inside the Event Notifier.
    Report Generator logs all collected data to a file.  A second queue was used, but uses the same data as the first.  Is this the correct implementation since two consumers need the same data?
    Main UI - handles changing of sample rate, possibly the stop button, possibly start/pause/resume of data collection.  Also handles when Event Notifier sets flag for a data driven stop condition, which then should provide a mechanism to stop the Data Collector.
    A big question that i have is.... Should the Main UI event structure just be in the Data Collector so that the loop can be stopped immediately?  All of the UI events (stop button, start/pause/resume data collection) directly effect the Data Collector.  Should the data Collector have a state machine instead?
    I feel that the 3 consumer loops (Event notifier, Email/Text Caller, and Report Generator) seem like a good implementation, but i am not confident about the Data Collector and Main UI loops.  Should they be combined?
    Solved!
    Go to Solution.
    Attachments:
    updatedMain.vi ‏13 KB

    A couple of thoughts:
    Overall it looks workable- remember to name your queus and notifiers- then you can depop the BD and launch each loop in its own sub-vi without wiring all those queues between loops- Just obtain ref to named queue.
    "Data collector" needs a supervisor to control how often the data is collected- I'm thinking a QSM with "init- collect- stop" states.  A simple timed loop could produce the "time to acq ticks" under control of the sample rate control. This puts both the DAQ init and cleanup functions within the Data Collector's perview so it aids coehesion and solves the exit without waiting for the loop to iterate.
    I'm not a fan of duplicating data- I assume analisys is pretty much just some comparisons- so it is pretty quick- Why not append summary data to the same queue? And make it a single element queue- the report loop can then inspect the queue and look for a summary data "index" - if its greater than the last index written append the darn data to the report?  Preview queue works great for these situations.
    Do not combine the UI handeler with anything else! Do you see the snag?- hint: here thar be spaghetti.  keep the functions seperated for solid scalable and maintainable code.
    One last thought:  Its getting less popular to stop loops on the error out of a dequeue.  First it returns a default element that can cause your listeners some headaches.  Second it doesn't let you run cleanup code.  Use a stop command <enum> built into the element data as an executive to determine when to stop.  We'll try to get the examples updated to show current best practices.
    Jeff

  • EJB3 Design Patterns (Session Beans)

    I've been learning about EJB3 and JSF as a potential technology for a new web app. As part of my learning about EJB3 and JSF, I came across this tutorial on the NetBeans site:
    http://www.netbeans.org/kb/55/ejb30.html
    In the tutorial there is one entity class, NewsEntity, from which a session bean is created, NewsEntityFacade and the interface NewsEntityFacadeLocal. It seems a little weird to me that the interface is called NewsEntityFacadeLocal and the implementing class called NewsEntityFacade. I would think that the interface should be called NewsEntityFacade and the implementing class NewsEntityFacadeLocal.
    Question 1: Can anyone explain why the names are backwards (at least to my thinking)?
    Also, I've been trying to find some best practices on EJB3 design patterns, but haven't come up with much. I did find some at https://blueprints.dev.java.net/bpcatalog/ee5/persistence/ejbfacade.html. Based on this pattern and the NetBeans tutorial, I think I've come across two different patterns, but since most of the examples are very simple, it's hard to tell.
    Question 2: Are these two distinct patterns?
    1. Session facade/entity (NB example)
    2. Session facade which groups business logic and may reference multiple entity beans.
    Question 3: If I have identified two patterns, can anyone tell me what they consider the pros/cons of either/both?
    Thanks in advance!

    The SRDemo available as an automatic update in JDeveloper 10.1.3.0.4 shows an application using local EJB 3.0 session beans. To access them in the web application you will need an entry in the web.xml like:
      <ejb-local-ref>
        <ejb-ref-name>ejb/local/SRPublicFacade</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <local>oracle.srdemo.model.SRPublicFacade</local>
        <ejb-link>SRPublicFacade</ejb-link>
      </ejb-local-ref>To lookup the session bean within you presentation you need to do a JNDI lookup. In my example I have:
    new InitialContext().lookup("java:comp/env/ejb/local/SRPublicFacade");Doug

  • Design Patterns, The Decorator

    When trying to implement the classic decorator design patterns your decorator executable might look like this:<br><br>
    <pre>
      METHOD validate.
        DATA: Validator TYPE REF TO validation_manager.
       CREATE OBJECT:
         Validator TYPE validation_manager.
        ,Validator TYPE validate_format                 EXPORTING x_validator = Validator
        ,Validator TYPE validate_values                 EXPORTING x_validator = Validator
        ,Validator TYPE validate_relation_input       EXPORTING x_validator = Validator
        ,Validator TYPE validate_relation_database EXPORTING x_validator = Validator.
        me->lst_result = validator->validate( me->lst_data ).
        WRITE: / 'Processing Validate Activity'.
      ENDMETHOD.                    "validate</pre><br><br>
    The validate method ends up in endless resurcion in the memory. The reason is that I'm using the same variable as the resulting instanse and as parameter. It seems like the constructor treats both the result and the parameter as the same field/instanse regardless import parameter such as VALUE/REFERENCE. If I change the method to use an extra field in the method validate like:
    <br><br><pre>
      METHOD validate.
        DATA:
          validator  TYPE REF TO validation_manager
         ,recursive  TYPE REF TO validation_manager.
        CREATE OBJECT validator TYPE validation_manager.
        recursive ?= validator.
        CREATE OBJECT validator TYPE validate_format
          EXPORTING x_validator = recursive.
        recursive ?= validator.
        CREATE OBJECT validator TYPE validate_values
         EXPORTING x_validator = recursive.
        recursive ?= validator.
        CREATE OBJECT validator TYPE validate_relation_input
          EXPORTING x_validator = recursive.
        recursive ?= validator.
        CREATE OBJECT validator TYPE validate_relation_database
          EXPORTING x_validator = recursive .
        recursive ?= validator.
        me->lst_result = validator->validate( me->lst_data ).
        WRITE: / 'Processing Validate Activity'.
      ENDMETHOD.                    "validate</pre><br><br>
    Now the decorator engine works, but why does the first implementation not work when the same one executes fine in php, c++, delphi, java and other languages.<br><br>
    If you do not know what I'm trying to discuss, look up "Design Patterns - Simply", and jump to the chapter about the decorator design pattern. I'm trying to use this design pattern for a validation manager within my Business Process Engine, which needs to be able to configure what types of validation needed for on specific process (BPMN).<br><br>

    Hi Matt, Thanks for the formatting..:) I will post the complete program as it's only a prototype program. Trying to get the format under control.
    </body>
    Report  ZDP_DECORATOR_XMP01
    REPORT  zdp_decorator_xmp01.
    parameters: bestimpl  TYPE boolean_01 default 0.
    TYPES:
      BEGIN OF processdata
       ,name   TYPE char30
       ,street TYPE char30
       ,zip    TYPE char5
       ,city   TYPE char30
       ,email  TYPE char50
       ,phone  TYPE char20
    ,END OF processdata
    ,BEGIN OF result
       ,msgid  TYPE msgid
       ,msgtyp TYPE msgty
       ,msgno  TYPE msgno
       ,status TYPE char1
    ,END OF result.
    CONSTANTS:
    true     TYPE boolean_01 VALUE 1
    ,false    TYPE boolean_01 VALUE 0.
    CLASS validationmanager DEFINITION
    CLASS validation_manager DEFINITION.
      PUBLIC SECTION.
        METHODS:
          validate
            IMPORTING
              x_data             TYPE processdata
            RETURNING
              value(y_result)    TYPE result.
    ENDCLASS.
    CLASS validationmanager IMPLEMENTATION
    CLASS validation_manager IMPLEMENTATION.
      METHOD validate.
        WRITE: / 'Common validation'.
      ENDMETHOD.                    "validate
    ENDCLASS.
    CLASS Validate_Decorator DEFINITION
    CLASS validate_decorator DEFINITION INHERITING FROM validation_manager ABSTRACT .
      PUBLIC SECTION.
        DATA: validator TYPE REF TO validation_manager.
    ENDCLASS. 
    CLASS validate_format DEFINITION
    CLASS validate_format DEFINITION INHERITING FROM validate_decorator.
      PUBLIC SECTION.
        METHODS:
          constructor
           IMPORTING value(x_validator) TYPE REF TO validation_manager
         ,validate REDEFINITION.
    ENDCLASS.   
    CLASS validate_format IMPLEMENTATION
    CLASS validate_format IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor( ).
        me->validator = x_validator.
      ENDMETHOD.                    "constructor
      METHOD validate.
        y_result = validator->validate( x_data ).
        IF y_result-status IS INITIAL.
          WRITE: / 'Now doing the format checks'.
        ENDIF.
      ENDMETHOD.                    "validate
    ENDCLASS.
    CLASS validate_values DEFINITION
    CLASS validate_values  DEFINITION INHERITING FROM validate_decorator.
      PUBLIC SECTION.
        METHODS:
          constructor
           IMPORTING value(x_validator) TYPE REF TO validation_manager
         ,validate REDEFINITION.
    ENDCLASS.
    CLASS validate_values IMPLEMENTATION
    CLASS validate_values IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor( ).
        me->validator = x_validator.
      ENDMETHOD.                    "constructor
      METHOD validate.
        y_result = validator->validate( x_data ).
        IF y_result-status IS INITIAL.
          WRITE: / 'Now doing the values checks'.
        ENDIF.
      ENDMETHOD.                    "validate
    ENDCLASS. 
    CLASS validate_relation_input DEFINITION
    CLASS validate_relation_input DEFINITION INHERITING FROM validate_decorator.
      PUBLIC SECTION.
        METHODS:
          constructor
           IMPORTING value(x_validator) TYPE REF TO validation_manager
         ,validate REDEFINITION.
    ENDCLASS.
    CLASS validate_relation_input IMPLEMENTATION
    CLASS validate_relation_input IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor( ).
        me->validator = x_validator.
      ENDMETHOD.                    "constructor
      METHOD validate.
        y_result = validator->validate( x_data ).
        IF y_result-status IS INITIAL.
          WRITE: / 'Now doing the relation input checks'.
        ENDIF.
      ENDMETHOD.                    "validate
    ENDCLASS.
    CLASS validate_relation_database DEFINITION
    CLASS validate_relation_database DEFINITION INHERITING FROM validate_decorator.
      PUBLIC SECTION.
        METHODS:
          constructor
           IMPORTING value(x_validator) TYPE REF TO validation_manager
         ,validate REDEFINITION.
    ENDCLASS.  
    CLASS validate_relation_database IMPLEMENTATION
    CLASS validate_relation_database IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor( ).
        me->validator = x_validator.
      ENDMETHOD.                    "constructor
      METHOD validate.
        y_result = validator->validate( x_data ).
        IF y_result-status IS INITIAL.
          WRITE: / 'Now doing the relation database checks'.
        ENDIF.
      ENDMETHOD.                    "validate
    ENDCLASS.  
    CLASS process_execution DEFINITION
    CLASS process_execution DEFINITION.
      PUBLIC SECTION.
        METHODS:
          startevent
         ,getdata
         ,validate
         ,process
         ,endevent.
      PRIVATE SECTION.
        DATA:
          lst_data   TYPE processdata
         ,lst_result TYPE result.
    ENDCLASS.                    "process_execution DEFINITION
    CLASS process_execution IMPLEMENTATION
    CLASS process_execution IMPLEMENTATION.
      METHOD startevent.
        WRITE: / 'Processing startevent'.
      ENDMETHOD.                    "startevent
      METHOD getdata.
        me->lst_data-name        = 'Hans Andersen'.
        me->lst_data-street      = 'H.C Andersens Boulevard 112'.
        me->lst_data-zip         = '1557'.
        me->lst_data-city        = 'København'.
        me->lst_data-email       = 'hcATandersen.dk'.
        me->lst_data-phone       = '0045-31162211'.
        WRITE: / 'Processing Get_Data Activity'.
      ENDMETHOD.                    "getdata
      METHOD validate.
        DATA:
          validator  TYPE REF TO validation_manager
         ,recursive  TYPE REF TO validation_manager
        IF bestimpl = true.
          CREATE OBJECT:
            validator TYPE validation_manager
           ,validator TYPE validate_format EXPORTING x_validator = recursive
           ,validator TYPE validate_values EXPORTING x_validator = recursive
           ,validator TYPE validate_relation_input EXPORTING x_validator = recursive
           ,validator TYPE validate_relation_database EXPORTING x_validator = recursive.
        ELSE.
          CREATE OBJECT validator TYPE validation_manager.
          recursive ?= validator.
          CREATE OBJECT validator TYPE validate_format
            EXPORTING x_validator = recursive.
          recursive ?= validator.
          CREATE OBJECT validator TYPE validate_values
           EXPORTING x_validator = recursive.
          recursive ?= validator.
          CREATE OBJECT validator TYPE validate_relation_input
            EXPORTING x_validator = recursive.
          recursive ?= validator.
          CREATE OBJECT validator TYPE validate_relation_database
            EXPORTING x_validator = recursive .
          recursive ?= validator.
        ENDIF.
      Recursive call of the validate and it's successors
        me->lst_result = validator->validate( me->lst_data ).
        WRITE: / 'Processing Validate Activity'.
      ENDMETHOD.                    "validate
      METHOD process.
        WRITE: / 'Processing Process Activity'.
      ENDMETHOD.                    "process
      METHOD endevent.
        WRITE: / 'Processing endevent'.
      ENDMETHOD.                    "endevent
    ENDCLASS.    
    CLASS mainapp DEFINITION                                             *
    CLASS mainapp DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          main.
    ENDCLASS.   
    CLASS mainapp IMPLEMENTATION                                         *
    CLASS mainapp IMPLEMENTATION.
      METHOD main.
        DATA:
          p89 TYPE REF TO process_execution.
        CREATE OBJECT p89.
        p89->startevent( ).
        p89->getdata( ).
        p89->validate( ).
        p89->process( ).
        p89->endevent( ).
      ENDMETHOD.  
    ENDCLASS.     
    START-OF-SELECTION.
      mainapp=>main( ).
    Edited by: Matt on Dec 22, 2009 2:03 PM Fixed formatting

  • Design patterns for Dynamic Class Loading

    Hi,
    I have to develop a program for uni that dynamically loads classes based on names in a text file. All the classes subclass an abstract class with a constructor that takes one argument. This means I can't use the Class.forName(className).newInstance() method of class loading. I have researched some design patterns I could use and have come up with the following 3:
    Factory pattern; "Robocode" pattern (not it's real name, but Robocode uses it); and, the "one I made up myself" pattern.
    The robocode pattern instantiates a class using the default no-argument constructor then immediately sets all properties that shoud have been provided in the constructor:
    Object o = Class.forName(myClass).newInstance();
    o.setProperty(property);Personally I think this is ugly and a cheap fix instead of doing it properly.
    My own pattern finds the constructor that takes the arguments I need then calls it to create the object:
    Class c = Class.forName(myClass);
    Constructor cons = c.getConstructor(new Class[]{Class.forName("java.lang.String")});
    Object o = cons.newInstance(new Object[]{"hello"});What's the best to use? Are there any other patterns I should consider?

    My own pattern finds the constructor that takes the
    arguments I need then calls it to create the object:
    Class c = Class.forName(myClass);
    Constructor cons = c.getConstructor(new
    Class[]{Class.forName("java.lang.String")});
    Object o = cons.newInstance(new Object[]{"hello"});
    I have followed this basic 'pattern' several times though I would use
    Constructor cons = c.getConstructor(new Class[]{String.class});
    It works great.

  • Which Design Pattern and how to design using OOP this scenario

    I am having trouble designing a module, can anybody help me?
    Because it will be hard to maintain this kind of module, I also think that this can test my skill of design pattern usage.
    Requirement
    This is basically an agricultural project (web application). I need to design a module where some calculation takes place.
    There are different crops involved like maize, tomato, okra etc. Each of these crops has different traits.
    Each trait has a measurement scale which lies in integer like 200-1000. Now let's say I have planted the crop and done measurement noted down the traits. Now I want to do some sort of measurement. Some measurements are simple and some are complex.
    Example
    Lets take an example of crop maize. I have recorded observations for 15 traits. (We'll use trait1-trait15 as examples, the actual name can be like plt_ht, yld, etc.)
    I recorded 5 observations for each trait:
    trait1 trait2 trait3 trait5 trait6..... trait15
    01,02,03,04 01,02,03,04 01,02,03,04
    User logs into system and selects his crops and enters data for these observations. I have to calculate either average or sum of the data entered for each trait.
    Complexity / centre of the problem
    So far it's simple but complexity comes when I have some different formulas for some of the traits.
    Example: trait YLD has a formula based on which I have to calculate its value, which may also depend on some other traits. Each different crop can have different traits.
    All this I am able to do - whenever user selects crop I will check for those specific traits and do calculations (if it's not a special trait then I either average or sum it, based on db entry), but there is a lot of hard coding.
    I would like to have suggestions on a better way of handling this.
    My code needs to handle both simple and complex calculations.
    Simple calculations are easy, I have take average of value entered for trait.
    The problem comes when I have to do complex calculations, since each crop have different traits with their own formulas, so to calculate I have to check for crop and then for complex trait. So I have to hardcode the trait name of complex traits.
    Can any tell me how I can design this using Java oops [?!?] so that I can make it generic?
    I have about 10 different crops. Some calculations are specific to crops, so there will be lot of code like the if below:
    hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("MZ") && traitName.equalsIgnoreCase("Shelling")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
        avg=avg*dataPoint;
        traitAvg=getMaizeYeild(traitName, traitAvg, population, avg, hybrid, area);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YLDGM")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
        //avg=avg*dataPoint;
        Object[] dataValues=getOKRAYield(traitName, traitAvg, population, avg, dividend,hasZeroValue,hybrid,repl);
        traitAvg = (HashMap<String, Float>) dataValues[0];
        hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("HP") && traitName.equalsIgnoreCase("w1-w10")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPts, dataTraits, traitValues,dataPvalues, dataPoint, type);
        avg=avg*dataPoint;
        Object[] dataValues=getHotPepperYield(traitName, traitAvg, population, avg,dividend,hasZeroValue,hybrid,repl);
        traitAvg = (HashMap<String, Float>) dataValues[0];
        hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_70")) {
        traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_100")) {
        traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg, dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("ELCV_60")) {Can anybody think of a way to make a generic approach to this?

    There are crops and each crop have traits , traits are actually a mesuremet
    scale to decide growth of a seed of a particular crop.
    This module is to for planters to observe growth of seeds sowed of certain
    crops and take down n no of observation for each trait and upload in csv format.Once they enter
    data i have to either avg out the values or sum the values or sometimes
    there are more complex function that i have to apply it may differe for each
    trait .This is the whole module about.Just to give an idea about how they
    will enter data
    Hyubrid(seed) trait1 trait2 trait3 trait5 trait6..... trait15
    Hybrid1 01 02 03 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    Once they enter data in this format i have to give result something like
    this.
    Here avg colum does not necessaryly mean avg it can be sum or any formula
    based resutl.Hybrid is the seed for which they record the observation.
    I have shown avg column only for two tratis it is actually for all the
    traits.
    Hyubrid(seed) trait1 Avg trait2 avg trait3 trait5 trait6..... trait15
    Hybrid1 01 01 02 04 03 04 01
    HYbrid2 04 04 06 10 08 04 01
    HYbrid2 04 04 06 12 08 04 01
    HYbrid2 04 04 06 14 08 04 01
    HYbrid2 04 04 06 12 08 04 01
    Hope this clarifies atleat a but
    The data are not correctly indented but there is no way i can format it.

  • Database Design Pattern

    hi all,
    I am developing a J2SE application which is communicating with two DB schemas.
    Do any one suggest any good design pattern to manage these type of situation.
    I was thinking to create two DAO classess for two different DB schemas?
    I am using oracle 10g as database.
    Regards

    Keep in mind that Oracle is not a database. Oracleis a database management system (DBMS).
    RDBMS, no? Both acronyms apply; Oracle is a DBMS and a RDBMS.
    Then what is the official name for the
    database itself? There is no official name for "the" database, because Oracle is not a database. Oracle, SQL Server, etc. are software for managing relational databases. They provide users with the ability to create relational databases. They provide various transactional and security features related to relational databases. They host a query language interpreter so that users can search relational databases. They have internal systems databases for managing the databases that users create.

  • Is MVC2 a design pattern or architecture? for yes and no why?

    I am using JSF which follows MVC2. Is MVC2 a design pattern or architecture? For yes and no why? what is the difference between design pattern or architecture?

    Hi There,
    Maybe this will help answer your questions...
    Firstly, MVC2 is a proprietary name for the Microsoft .NET framework based around the Model-View-Controller pattern - it is an updated version of their first attempt - MVC.
    The Model-View-Controller pattern harks back to the days of SmallTalk, and as far as I am aware is not included in the original Gang Of Four design patterns, although there is no reason why it can't be considered a design pattern.
    Software architecture is about how different parts of the system fit (interface) together and how they relate, including static relationships (cardinality relationships, state) and processes (what happens when), it most often consists of many design patterns each used to address the various needs of a complete system.
    Hope this helps
    Rich

  • What is a design pattern?

    Howdy,
    I hear a lot of talk of deasign patterns in ABAP...
    My question is what on earth is a design pattern and why/how would it be useful?
    Any ideas anyone

    Hi Steve.
    The good point to start with design patterns is to read book "Design Patterns - Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. It gives strong, consistent understanding of patterns basis with real life examples.
    Short introduction extract:
    "Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice". Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a context.
    In general, a pattern has four essential elements:
    The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two. Naming a pattern immediately increases our design vocabulary. It lets us design at a higher level of abstraction. Having a vocabulary for patterns lets us talk about them with our colleagues, in our documentation, and even to ourselves. It makes it easier to think about designs and to communicate them and their trade-offs to others. Finding good names has been one of the hardest parts of developing our catalog.
    The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.
    The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, because a pattern is like a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in our case) solves it.
    The consequences are the results and trade-offs of applying the pattern. Though consequences are often unvoiced when we describe design decisions, they are critical for evaluating design alternatives and for understanding the costs and benefits of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Since reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility, or portability. Listing these consequences explicitly helps you understand and evaluate them."
    Regards,
    Maxim.

  • The drawback of design patterns

    It is more and more important to get the skill of using design patterns as a programmer , and there is many material about it , all of them talking about the benefits of using patterns, But I know that Patterns is not so better as they argued , Patterns also have deficiency , Patterns can not be used every where .....
    What I want here is that I hope to hear heatly discussing about the "the drawback of design patterns" , please using your head , typing what u know here !

    Patterns can not solve the problems such as "code
    scattening" and "code tangling"Okay, so there are some problems that patterns can't solve. Apparently by your logic, the fact that concrete doesn't cure cancer is a deficiency of concrete. I suppose that's logically defensible, but it also contains precisely zero information, so it's a pointless statement.
    , these the
    headaches are in the domain of OO , Design Patterns
    are only smart design idiom within OO , but they can
    not solve the drawback of OO , and Patterns should
    not be used everywhere Okay. So, again, concrete is in the domain of construction, but it cannot solve the drawbacks of construction, so that's a deficiency of concrete. Again, zero information, thus pointless.
    , the places where they should
    be used is the place where u face "May be change in
    the future " ! Patterns are not so much about future change as they are about providing a common vocabulary--a means of communication--and a stock of parts to draw from when solving certain problems.
    Use Patterns add many classes into your code ,Maybe, maybe not.
    Good design adds classes. Poor design stuffs everything into a few bloated classs. Many classes is not necessarily a bad thing, and if you've employed good design, you'll likely have the same design as specified in a pattern. So using patterns doesn't in and of itself add classes. The pattern-ness comes into play in applying the name to the good design you did anyway.

  • What kind of design pattern is this?

    Hi ,
    I am just learning the designpattern. So when I went through different kinds of design pattern, I got some doubts as it looks same some design patterns. could anybody please tell what kind of design pattern is the following one?
    public interface IExporter{
         void export();
    public class ExcelExporter implements IExporter{
    public void export(){
    //TODO implementation
    public class CVSExporter implements IExporter{
    public void export(){
    //TODO implementation
    }thanks in advance..

    Well - in structure, it is nearest to the Command pattern as far as I can tellOr Strategy. Or Builder. Several design pattenrs may share the same class structure, the difference is in the context, forces, and the parts one want to be flexible. And if someone wants to make it explicit which pattern is applied, they should name things accordingly.
    As Saish said this example shows little more that inheritance at work. Not a pattern in itself, but a core element of the language. Trying to "identify" a pattern that is not obvious from the context is either:
    - a sign that the original coder completely missed the point of using a pattern (which is, as Saish said too, assentially about communication)
    - a sign that the maintenance coder is looking for patterns where there aren't
    - an exercise question
    but it differs in so much as its motivation is to polymorphically allow the use of different exporters rather than provide a set of action commands.That shouldn't count as a difference, merely as an "application" (it's perfectly valid to have a hierarchy of commands all devoted to exporting, although, as stated, if the original coder applied the Command pattern, he should have made it explicit, by renaming the interface, e.g. to ExportCommand).

Maybe you are looking for

  • Mac Pro 2.66 crashing with more than 2GB ram

    I curently have a base config of 1GB ram (2 512MB chips), the systems runs fine, I then added memory in various configs and it always kernel panics when I exceed 2 GB. System runs fine until i try something memory intensive like Aperture or Photoshop

  • Adobe Media encoder- Prozedureinsprungpunkt Fehler

    Ich habe adobe premiere Pro neu installiert da der Media encoder entweder abgestürzt ist oder einfach nicht reagiert hat.... Jetzt bekomme ich diese Fehlermeldung sobald ich den encoder starten will: Der Proezedureinsprungpunkt „??0NewHandlerInitiali

  • Will I lose my unlimited data if I upgrade from an Android to an iphone?

    I am due for an upgrade in a few months and I am really leaning towards the new iphone. My question is...I have an unlimited family data plan, if I switch to an iphone will I be forced to change data plans? I work in litigation and I use a lot of dat

  • Why won't Photoshop website accept temp passwords so new ones can be inserted?

    About 6 temp passwords have been sent to me so I could insert a new password for Photoshop help. None were accepted. Why? I'm sorry--- I've spent 2 hrs. trying to fix this mess and I have a meeting to go to.....will try tomorrow.....mm

  • Configuration not saving

    My DVDSP4 is acting very strange. On startup, it always asks me to choose Application defaults, even though I have Show at startup unchecked. I choose my desired configuration, click OK, and then the Choose Defaults window goes away and comes up agai