Messaging system design pattern

Hi,
I'm working on a messaging system build into my application.
As a system administrator, I create messages for all the users. When a user logs in, I want unread messages to be displayed so I have to keep track of wich user read or didn't read newly created messages.
The simplest way would be to keep track of which message was read by which user but that would increment my database until the end of time (or at least until 2012 )
I would think that it's better to keep track of which user didn't read which message but then things would get complicated when a message is deleted.
Also, should I store the user with the message or should I store the messages with the user?
Does anyone have experience on this? Any suggestions?
It's not a technical problem but an architectural one.
Thanks,
Dany

ok, suppose I have a READ_STATUS field, how would you store it then?? You have to keep track of ALL your users and that for all your messages. Suppose you have 25000 users? What I do now is store a comma delimited string for all unread users. So, in a new message, I create a string with the id's of all current users, like 1,2,3,4....24999,25000. In Flex, I convert this string to an array, which makes it easy to delete the current user's id and then write this string back to the db. Something inside me tells me that there have to be more effecient ways to do this...?
BTW, I don't use ORM, that's just the problem. If I have a person with several addresses, I keep a seperate table for the addresses and retreive those before sending a single person value object back to Flex. As it's not likely that a person would have more than 100 addresses (unless he is a criminal or Michael Jackson) this method is fine, but with storing thousands of user id's per message, well... suggestions?
Dany

Similar Messages

  • Dispatch messages system design consult

    I have a design question and would like to have suggestions.
    I am using Weblogic 11g, EJB3.0 , Weblogic JMs
    I have a system which it's target to retrieve and dispatch messages to couple of resources(databases).
    Each message contain information and target database key.
    So here is an flow example:
    I get from web service a message and key target. I parse the message and dispatch it to the right database via the key target.
    There is a possibility that a message will contain more then one target database.(for example the key 'all' means that I should dispatch to all databases.
    If Insert is failing in one of the resources a rollback will occurred and I a re-try will re-execute the whole operation.
    So now this is my issue:
    Should I make the number of the queues as the number of my resources? (and dedicated each Queue to a specific resource)
    (In this case I parse each message and just send it to the right queue while an MDB will listen and do the insertion to the right database)
    If I do it that way I wont be able to make it dynamic, Meaning each time a new resource will need to be added/removed in the future I will need to open the code and make the right changes.
    What you desgigners think? How could I implement it better dynamiclly?
    thanks for your help,
    ray

    ok, suppose I have a READ_STATUS field, how would you store it then?? You have to keep track of ALL your users and that for all your messages. Suppose you have 25000 users? What I do now is store a comma delimited string for all unread users. So, in a new message, I create a string with the id's of all current users, like 1,2,3,4....24999,25000. In Flex, I convert this string to an array, which makes it easy to delete the current user's id and then write this string back to the db. Something inside me tells me that there have to be more effecient ways to do this...?
    BTW, I don't use ORM, that's just the problem. If I have a person with several addresses, I keep a seperate table for the addresses and retreive those before sending a single person value object back to Flex. As it's not likely that a person would have more than 100 addresses (unless he is a criminal or Michael Jackson) this method is fine, but with storing thousands of user id's per message, well... suggestions?
    Dany

  • Choice of design pattern for data acquisition system

    Hello all
    I have a trouble about selecting the suitable design pattern / architecture for a data acquisition system. 
    Here is the details of the desired system:
    There is data acquisition hardware and I need to use it by observing parameters on User interface. 
    the data acquisiton period, channel list to scan should be chosen on User interface. Besides, there are many user interface interactions. e.g. if user selects a channel to add scanlist, then I need to enable and make visible some other parts on user interface. 
    When user completes the channel selection, then he will press the button to start data acquisition. Then I also need to show the scanned values on a graph in real time and log them in txt file.
    I know that I cannot use producer consumer pattern here. because the data acquisition loop should wait for parameters to scan channels. and it works in a given period by user. so the user interface loop performs higher rate then consumer loop (data acquisition loop). it means queue will be bigger bigger. if I use notifier it will loss some data come from user interface. 
    is there any idea about that ? is there any suitable design pattern for this case ? 
    Thanks in advance
    best regards 
    Veli BAYAR
    Embedded Systems Software and Hardware Engineer 
    "You live in a graphical world. Why not program in one?"
    Solved!
    Go to Solution.

    johnsold wrote:
    Veli,
    I recommend the Producer/Consumer model with some modifications.
    You might need three loops.  I cannot tell for sure from your brief description.
    The User Interface loop responds to the user inputs for configuration and start/stop of acquisition.  The parameters and commands are passed to the Data Acquisition loop via a queue. In this loop is a state machine which has Idle, Configuration, Acquisition, and Shutdown states (and perhaps others). The data is sent to the Processing loop via a different queue. The Processing loop performs any data processing, displays the data to the user, and saves it to file. A notifier can be used to send the Stop or shutdown command from the User Interface loop to the other loops.  If the amount of processing is minimal and the file write times are not too long, the Processing loop functions might be able to occur in the Timeout case of the UI loop Event structure.  This simplifies things somewhat but is not as flexible when changes need to be made.
    I am not sure that a Design Pattern for this exact setup exists but it is basically a combination of the Producer/Consumer (Events) and Producer/Consumer (Data) Design Patterns.
    Lynn
    Check out this thread: http://forums.ni.com/t5/LabVIEW/Multiple-poll-case-structures-to-event-help/td-p/2551309
    There are discussions there about a 3-loop architecture that may help you.
    Jeff
    Jeffrey Zola

  • BPM distroy the SWCV design pattern

    Hi XIer,
    I am designing our SWCV as following:
    We need to integration one SAP R3 and 3 legacy systems using XI.
    So we created one SWCV for creating Data type, interface type and interface message for SAP,another 3 SWCV for 3 legacy systems for interface structure define. The Fourth SWCV is used for containing mapping objects, like message mapping and message interface.
    This is a good design as far as I know, but it comes problem when we want to use BPM,in BPM we need to define Container variable, but when we want to create an abstract interface as Container, it just allowed abstract interfaces under the specific SWCV which contains this BPM, so I am just confusing BPM will touch R3 and another legacy system, so looks like our design pattern can be used in such secnario.
    Could you give me any idea about how to design SWCV if you want to use BPM? thank you very much

    Zhang,
    it should not be a problem with SWCV you can use any SWCV in BPM when using the container variable use correspoding SWCV where the coinater variable or abstract interface is desinged SWCV.
    Regards
    Sreeram.G.Reddy

  • Design Pattern for execution queue

    Anyone know of any good design patterns for using a JMS Queue and MDB's
              as async
              execution queue which maintains execution order by some key
              

    Enforced ordering on redelivery will be supported in the
              next release, but only if the application clamps the pipe-line
              size down to its minimum and the MDB pool size down to one.
              I don't think enforced ordering is supported in the current release.
              We are looking at least partially addressing the general design
              pattern below in the release after next. I don't think I can
              get away with being more specific. (Sorry.) Currently, I
              think something along the line of Larry's solution is the only way to
              accomplish it. Interestingly, the recent thread started
              by "[email protected]" on correlating requests and responses
              seems to be somewhat related.
              Tom, BEA
              Larry Presswood wrote:
              > Well you are both correct however we have something which works
              > however it does involve some threading primitives which generally is not
              > a good idea
              > inside wlas but seems to work.
              >
              >
              > Generally have a singleton on the server which has slots for each key
              > with message
              > numbering for each message and force a wait if message for key is out of
              > order
              > during fifo processing rules. IE do what things you can do in parallel
              > but gate for
              > the last step.
              >
              > I think there is a general remote execution pattern out there.
              >
              > The general problem to solve is this:
              >
              > In a messaging system you want to process messages for each key/session
              > in order however
              > with a large number of sessions its possible to parallel messages for
              > different sessions
              >
              > Otherewise you can either create custom queues or a topic with a
              > selector and then
              > create custom consumers which does not behave as well from a resource
              > perspective
              > as MDB's do.
              >
              >
              >
              >
              >
              >
              >
              > Nick Minutello wrote:
              >
              >>I may be completely wrong - but I think that Larry is referring to the inherant
              >>out-of-order message consumption that you get when using MDB pools to consume
              >>from a Queue.
              >>
              >>In short, the only design pattern here is to deploy the MDB to only one machine
              >>in the cluster - and set the pool size to 1.
              >>
              >>In-order execution is incompatible with the parallel execution that MDB's give
              >>you.
              >>
              >>-Nick
              >>
              >>
              >>
              >>Tom Barnes <[email protected]> wrote:
              >>
              >>
              >>>Hi Larry,
              >>>
              >>>Generally, I think it is best to have a seperate queue per key if the
              >>>
              >>>number of keys is small. This prevents starvation of a particular
              >>>message. For example when handling message-priority, low priority gets
              >>>
              >>>an MDB pool of size 1, high priority gets and MDB pool of size 10.
              >>>
              >>>Note that WebLogic JMS allows a queue to specify a sort-order keys based
              >>>on arbitrary message fields. Note that the in-flight message pipe-line
              >>>
              >>>between server and asynchronous clients is unsorted.
              >>>
              >>>Tom, BEA
              >>>
              >>>Larry Presswood wrote:
              >>>
              >>>
              >>>>Anyone know of any good design patterns for using a JMS Queue and MDB's
              >>>>
              >>>>
              >>>>as async
              >>>>execution queue which maintains execution order by some key
              >>>>
              >>>>
              >>>>
              >>
              >>
              >>
              >
              

  • Design pattern for continuous record printing

    The Java printing API requires that during the print process a program retain enough information so that it can draw any page that is requested at any time. The API makes a call to the print method in the Printable interface with a specified index and the program is supposed to handle it.
    I've been able to successfully use this method quite well for some time but now I've encountered a more complex situation and I am hoping someone can help me design a way to do what I need.
    I have a data conversion program that may process millions of database records. I'm writing a conversion report for it where a variety of notification messages will print, possibly hundreds of thousands of messages (I know a report that long isn't very useful but our clients have to print it and file it as a FDA requirment). Because of the potentially large quantities of records involved I don't want to retain all of that information to allow any page can print at any time. I won't have a print dialog so there will be no way to selectively print pages anyway. I want to open the report at the beginning of the conversion and then call functions to write report records. When a page fills up it should print and start another. At the end a close function should be called to tell the Printable to start returning NO_SUCH_PAGE to end the process.
    Does anyone know a design pattern that will accomplish this? The behavior I'm seeing is that the Printable.print method gets called twice per page, once to determine if the page exists, then again to print the page. I could retain enough information to print the one page, but then I'm doing page counting that the API wasn't designed for and I'm afraid it will fail when I put it on other systems.

    Have you thought about separating the two business functions of (1) executing the data conversion, and (2) generating the report(s)?
    You could capture the information about the "report generating" conversion events in an XML file, and then generate your reports from this datastore. You may find some performance benefits in the conversion piece, and have greater flexibility when dealing with the XML information store.
    I want to open the report at the beginning of the conversion and then call functions to write report records. Here you would write report records to an XML file, or many XML files. You also put a counter in the conversion program that will start the reporting program after a specified number of event have occured. This will allow you to generate reports as the conversion program is still running.
    I could retain enough information to print the one page, but then I'm doing page counting that the API wasn't designed for and I'm afraid it will fail when I put it on other systems. You should try to avoid "page counting".
    A

  • How can I develop a web application using EJB design pattern?

    I have searched over the web and found quite a lot of tutorials on how to use the EJB design pattern.
    I know that there will be a home interface, EJB object interface and a SessionBean.
    But the tutorials often only cover a single class, this made me unable to get a complete picture of how EJB design pattern can be implemented into a whole system.
    I am now required to devleop an online shopping web application using EJB and JSP page.
    I think I will need to create a lot of classes: Member, ShoppingCart, Product...etc.
    What I want to ask is that, do I need to create a home interface, EJB object interface and a SessionBean for each of these classes?
    I really need some ideas on how to develop this system using EJB + JSP pages.
    Many thanks to you all.

    For every EJB that you want to create, you will need to code a home and remote interface and a bean class.
    You could start getting your ideas here
    http://www.theserverside.com/books/wiley/masteringEJB/
    http://www.coreservlets.com

  • Process Design Patterns in XI

    Hello,
    I heard that XI has got Design patterns such as Aggregation, Serialization etc. in the Process editor. Where do the messages get stored until the aggregation is carried? Does it make use any ODS in Integration server?
    We are using TIBCO and it does not seem to have this functionality.
    Thanks,
    Venu

    Hi Venu,
    The XI Business Process Engine is implemented on top of SAPs workflow engine, so the state of a process (including whatever messages it contains) is stored in the database underlying the SAP Web Application Server.
    Regards,
    Thorsten

  • The search for a perfect design pattern

    The search for a perfect design pattern
    I am searching tip to upgrade a labview program used. I am looking for the best approach to make
    my program more robust and scalable.Software and hardware. 
    Today the system consists of :
    GPS, weather station, ultrasound wind sensor, echosounder  and a  webcamera,  all connected to a computer.
    The computer OS is XP pro with Labview version 2009 installed. Except for the webcamera all peripherals have serial communication interface. 
    The webcamera  interface is ethernet.
    Device                           Data type                 Interval                    Interface
    GPS                                NMEA string                1 second                   Serial  rs232
    Ultrasound wind sensor   NMEA string                1 second                   Serial rs232
    Weather, temp,humid     NMEA string               35 seconds                 Serial rs232
    Echosounder                  NMEA string               500ms-5 seconds       Serial rs232
                                                                          (depending of depth)
    Webcamera                    Jpg                           Snapshot on demand  Ethernet
    The tasks to be solved
    All the data have to be stored.
    All the data have to be displayed in real time.
    Weather history data must be buffered to be plotted in a graph (pop-up windows).
    Absolute wind speed and direction have to be calculated.
    Option to send navigation data attached to email at desired time intervals.
    Image snapshot at desired time intervals.
    The data wich streams into the serial ports are not synchronized and vary in intervals . Would it be a good idea to put all the serial peripherals into a serial device server. Is it possible to let the server place a event in my software, to  trigger reading of the data, from the the server.  Or how could that be done in other ways?
    The perfect design pattern
    In version one of the software I use 4 parallel loops to read data at the serial ports, inside these loops the data was separated and outputted to a datasocket server.  I used datasocked read in other loops to present and store data. But it did not look good, and yes it was a mess, a really rat nest. I am looking for a better design pattern.
     Could some kind of producer/ consumer pattern be the way to go?
    Comments and tips are wanted.
    TIK

    Nice Project! Congratulations ;-)
    I am not an expert for large applications. But your project looks nice and manageable. Here my straightforward ideas:
    I would build a GUI, with menu bar, pop-up graph display thing.
    THen low level tasks with each one handling a RS232 device and feeding queues or fireing notifications.
    Maybe handle the snapshots in an event structure on the GUI blockdiagramm.
    When GUI and producer tasks are running, close the gap with a middle layer which captures the data and actualizes GUI by reference. For instance the graph-thing-dialogue triggers a "flush queue" and displays the last 200 entries of the array of data.
    I often run into issues when having defined too many userevent structures. I guess i am too stupid for that. Thats why i rather use queues (when i dont want to loose data) or notifiers (data is up-to-date). Nevertheless I like a "stop-all-tasks" user event...traditionally.
    My team is actually developing a large application. We are using LabVIEW classes and objects.
    So have fun!
    Yours
    RZM

  • Design Pattern / Best Practice Question

    Hi,
    I have been using Flex for a while now, but there is a
    scenario which I still have not found a solution I'm entirely happy
    with. I'm wondering if anyone else out there might have suggestions
    on a design pattern or best practice.
    Suppose I have a view which depends on model data which
    resides in some back end systems. That model data may or may not
    have been loaded (e.g. via a web service or remote object call) at
    the time the view is displayed.
    I don't know if the user will ever visit this part of the
    application so I would prefer to defer retrieval of the data until
    the user actually navigates to this view. Or I want to retrieve the
    data each time the view is displayed because the data is dynamic
    and could change between one presentation of the view and the next.
    Because the data comes from several systems, I cannot simply
    make one service call and display the view when it completes and
    all the data is available. I need to call several services which
    could complete in any order but I only want to display my view
    after I know all of them have completed and all of the model data
    is available. Otherwise, I can present the user an incomplete view
    (e.g. some combo boxes are empty until the corresponding service
    call to get the data completes).
    The solution I like best so far is to dispatch a single event
    (I am using Cairngorm) handled by a single command which acts as
    the caller and responder for all of the services. This command then
    remembers which responses it has received and dispatches another
    event to navigate to the view once all the results have returned.
    If the services being called are used in different
    combinations on different screens, this results in proliferation of
    events and commands. An event and command for each service and
    additional events and commands to bundle the services and the
    handling of their responses in the right combinations for each of
    the views.
    Another approach is to have some helper class listen for all
    of the model changes and only display the view when the model
    enters some state that is acceptable. It is sometimes difficult to
    determine just by looking at the model whether it is in the right
    state (e.g. how can I tell that a collection is the new collection
    that should just have been requested versus an old one lingering
    from a previous call). The logic required can get kind of
    convoluted and brittle.
    Basically, all of the solutions I've come up with so far seem
    less than ideal and a little hackish. I keep thinking there is some
    elegant solution out there that I am just missing ... but so far,
    no luck finding it. Thoughts?
    Thanks.
    Bill

    i think a service class is right - to coordinate your calls.
    i would have 1 event per call (so you could listen to individual
    responses if you wanted to).
    then i would use a flag. if you want to check for staleness,
    you would probably want two objects to map your service flag to
    lastRequested and lastCompleted. when you check, check if it's
    completed, and if it's not stale and that your lastRequested is
    less than lastCompleted (meaning that you're not currently waiting,
    i.e. you've returned since making a request). then make the request
    and update your lastRequested.
    here's a snippet of what i mean.
    ./paul
    public static const SVC1_LOADED:int = 1;
    public static const SVC2_LOADED:int = 2;
    public static const SVC3_LOADED:int = 4;
    public static const SVCALL_LOADED:int = 7;
    private var completedFlag:int = 0;
    then each call would have it's own callback.
    private function onSvc1Complete( evt:Event):void {
    completedFlag |= SVC1_LOADED;
    lastCompleted[ SVC1_LOADED ] = getTimer();
    dispatchEvent( new Event("svc1complete") );
    checkDone();
    private function checkDone():void{
    if( completedFlag == SVCALL_LOADED )
    dispatchEvent(new Event( "allLoaded" ));

  • Are there any Client/Server Application (using sockets) design patterns?

    Hi,
    The title of the post nearly says it all. I am searching for different design patterns related with the development of a client/server application. I understand that there must be any different ways on how a client/server application can be developed.
    Regards,
    Sim085
    Disclaimer:
    When I enter in the Socket forum on this site I recieve this message "Thank you for any participation in this forum. Due to a lack of relevant activity, we have decided to archive this forum on June 16, 2006. For future posts on this topic, we suggest you use the Networking forum" and I am not allowed to create a new post! However I can see posts done yesterday! All i did is add the forum in 'my forums'. Does this happen to you people as well?

    Hi Sim085...How are you?
    So look this:
    http://forum.java.sun.com/thread.jspa?threadID=5148926&tstart=75
    I don�t know if is what you want...but I hope in this^^
    Ok man...If you have one example for help you is better.
    [ ]

  • RE: design patterns involving EJBs and JDO

    Is the idea that you specify in some config file (xml?) the methods of
    your session bean, whether its stateful or stateless, the default bean
    transaction semantics, etc, then say "go" and it generates the home and
    remote interfaces and the skeletal session bean class?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:26 AM
    To: JDO-ListServ
    Subject: Re: design patterns involving EJBs and JDO
    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----
    From: Matthew <mailto:[email protected]> Adams
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated.
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric

    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----_
    From: Matthew <mailto:[email protected]> Adams_
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated._
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric_

  • Design patterns in WLI

    What design patterns could provide the best reuse of business processes and messaging infrastructure?

              Hi.
              I recently bought WROX Press book Professional J2EE EAI, which discusses Enterprise
              Integration. Maybe not on a Design Pattern-level (if there is one), but it gave
              me a good overview and helped me make some desig decisions. I´m not sure if its
              technical enough for those used to such decisions, but it proved useful to me.
              http://www.wrox.com/ACON11.asp?WROXEMPTOKEN=87620ZUwNF3Eaw3YLdhXRpuVzK&ISBN=186100544X
              HTH
              Oskar
              

  • 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.

  • Regarding which design pattern to use for this scenario???

    hi guys
    I am working on a J2EE application where I need to do translations for 3 different scenarios. It is basically a conversion from service order objects to invoices.
    First from a service order object to an invoice.
    Second a conversion from a transaction table.
    Third a conversion from a remote system.
    Finally the product is an invoice..
    What design pattern can i use ....is strategy pattern a good idea??
    Thanks
    J

    Hi,
    I think your problem is in result state. You can you sequencial block but for approve or reject you need to set target for each result state. Here I am providing a link. I think you will get your solution here please go through it.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/44/429bbd709914bce10000000a155369/frameset.htm
    if you have any query please let me know.
    Thanks
    Chandan

Maybe you are looking for

  • BAPI_ACC_DOCUMENT_POST tax with two vendor line

    Hi , I have a problem account tax parameter of Bapi_acc_document_post . I have to send two vendor lines , one of them with special gl indicator and one of them is tax related with zero amount . I fill account tax parameter properly but bapi doesnt no

  • HTTPS, DNS and dynamically updating DNS records

    Hello to you all, if you are able to help with a DNS problem that I'm having then please accept my thanks and appreciation in advance. First some background information, I recently  moved my server from my studio to my house where a new purpose built

  • Messages Appear then Disappear

    My iphone 5 (ios 7.1.2) has been acting up. It says i have two unread texts but ive opened them all. Earlier today i got a couple texts that showed up on the lock screen preview, but then disappeared when i opened up the messages. Emails show i have

  • Query comparison

    Hello , I would really apreciate if some one can help me with there expert opinion. Mentioned below is a query SELECT S.ACCT_EVENT_TYPE_CD ,S.CUST_ACCT_EVENT_ID ,S.EVENT_USED_BY_CD ,S.EVENT_SEQUENCE_CD ,S.DW_AS_OF_DT ,S.CUST_ACCT_EVENT_CD ,S.EXT_EVEN

  • TS4209 Macbook Air with OS X 10.8.2 not automatically connecting to known wifi network after sleep

    Macbook Air with OS X 10.8.2 not automatically connecting to known wifi network after sleep