Sample Design pattern problems

I am currently studying design patterns from "Head First design patterns".
Does any body know any website that contains sample design related problems so that I can test my designing skills?
Thanks

[Google for 'design patterns' here at sun.com|http://google.com/search?q=design+patterns+site:sun.com].

Similar Messages

  • What is the best design pattern for this problem?

    No code to go with the question. I am trying to settle on the best design pattern for the problem before I code. I want to use an Object Oriented approach.
    I have included a basic UML diagram of what I was thinking so far. 
    Stated simply, I have three devices; Module, Wired Modem, and Wireless Modem.
    In the Device Under Test parent class, I have put the attributes that are variable from device to device, but common to all of them.
    In the child classes, I have put the attributes that are not variable to each copy of that device. The attributes are common across device types. I was planning to use controls in the class definition that have the data set to a default value, since it doesn't change for each serial number of that device. For example, a Module will always have a Device Type ID of 1. These values are used to query the database.
    An example query would be [DHR].[GetDeviceActiveVersions] '39288', 1, '4/26/2012 12:18:52 PM'
    The '1' is the device type ID, the 39288 is the serial number, and the return would be "A000" or "S002", for example.
    So, I would be pulling the Serial Number and Device Type ID from the Device Under Test parent and child, and passing them to the Database using a SQL string stored in the control of the Active Versions child class of Database.
    The overall idea is that the same data is used to send multiple queries to the database and receiving back various data that I then evaluate for pass of fail, and for date order.
    What I can't settle on is the approach. Should it be a Strategy pattern, A Chain of Command pattern, a Decorator pattern or something else. 
    Ideas?

    elrathia wrote:
    Hi Ben,
    I haven't much idea of how override works and when you would use it and why. I'm the newest of the new here. 
    Good. At least you will not be smaking with a OPPer dOOPer hammer if I make some gramatical mistake.
    You may want to look at this thread in the BreakPoint where i trie to help Cory get a handle on Dynamic Dispatching with an example of two classes that inherit from a common parent and invoke Over-ride VIs to do the same thing but with wildly varying results.
    The example uses a Class of "Numeric"  and a sibling class "Text" and the both implement an Add method.
    It is dirt simple and Cory did a decent job of explaining it.
    It just be the motivation you are looking for.
    have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • What is command design pattern? what is the problem that it solves?

    Hi i have been reading few articles on command design pattern but was unable to understand what it is and what problem does it solve. As far as my understanding goes if there is a pre specified method in an object that could execute and perform the necessary activities then it is called as command design pattern. Why is it named as command design pattern, it is because in a shell we use commands to retrieve output. For example when we type "dir" in dos command prompt it returns the list of files. so here we have to remember a preexisting exe file named "dir" which does something when used. So here like we call it command because when "dir" is passed to the computers it returns something that is expected. may be the computer obeys the command issued and return something back. So like wise if there is a method that is defined as as the command, for example in struts framework the action class must have a method "execute()" which is called by the framework to execute the necessary action mapped to it. So if there is a predefined method like "execute" in struts then the object is said to be followed command design pattern. So what actually does it solve?
    What ever i have written is my understanding from the articles i have read about the design pattern. So kindly correct me if i am wrong. Help me understanding what actual problem does this pattern solves. Thanking you in advance.

    This is really off-topic for these forums. You might do better on StackOverflow.com. I'll just say that although the first Design Patterns book came as a revelation to me, it was more for (a) the nomenclature (decorator, factory, facade, etc) which is still with us and (b) about five of the original patterns, which told me things I didn't already know. I've never used any of the others, including Command, and the whole design patterns thing quickly degenerated into farce with what seemed like a sustained attempt to reduce the whole of computer science to design patterns, which really isn't the point. As an example, there is one in another book called Type Object, which is nothing but 3rd normal form, which can be defined roughly in a couple of sentences. This pattern went on for dozens of pages with a very artificial example. I wrote to the mailing list about it: 'Type Object considered hilarious'. I got a rude reply from the original author, which I guess I expected, but also an incredible response from the list owner, saying I should recast my objections in the form of a design pattern. That lost it for me. True story. Moral: don't take this religion, or any IT religion, too seriously. They come around every 18 months or so with the regularity of the next bit of Moore's Law. I've seen dozens of them come and go since 1971, all with something to say, all 90% nonsense.
    See here for a longer version of this incident.

  • Transaction Problem in Session Facade Design Pattern

    Hi
    Well Sorry for giving wrang title to the topic, coz of which I have not received and reply.
    I am using session facade design pattern.
    I have Action class calling session facade method "getData" . This method calls "findByPrimaryKey" method in BMP.
    Method "getData" has transaction attribute as "RequiresNew" and "findByPrimaryKey" has "Required".
    This combination does not assign identity to BMP hence I can not use setter getter method for retriving data(throws nullpointer exception when getter method accessed) I have made sure that I am accessing table and getting data in to BMP but as BMP is not ablle to hoild any identity its not allowing me to use BMP's getter method in session facade.
    I have Used Same transaction attribute for create method called by "addNew" method of session facade bean.
    Transaction method for "addNew" is "RequiresNew" and for "create" is "Required".
    It works fine and gives identity toBMP hense I can use Setter getter method defined in BMP bean.
    How can I avoid this and get BMP an identity?
    Thanking in Advance,
    Chintan.

    Sorry, how is this related to JSF?
    There's an OO/patterns forum out. Consider reposting the question over there with formatted code.

  • How to avoid multiple if else using design patterns.

    Hi,
    Which design patterns is used to avoid lot of if else in our code . Say for example if the user press 1 the out put should be one, if he press 2 it should be two like this upto 10. So we need to include lot of if-else part. How to avoid the multiple if else using design patter for this scenario. I can't find the solution for this problem can you guys help me?.

    I'm too lazy to read a whole text book, but the first google link provides a code sample which made me laugh.
    http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html
      double getSpeed() {
        switch (_type) {
          case EUROPEAN:
            return getBaseSpeed();
          case AFRICAN:
            return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts;
          case NORWEGIAN_BLUE:
            return (_isNailed) ? 0 : getBaseSpeed(_voltage);
        throw new RuntimeException ("Should be unreachable");
      }My implementation of The Bridge Over The Parrot Shop
    package forums;
    import java.util.Random;
    abstract class Bird {
      private static final Random random = new Random();
      abstract double getAirSpeed();
      public double getBaseSpeed() {
        return randomDouble(18.96);
      protected static double randomDouble(double max) {
        return random.nextDouble() * max;
      protected static int randomInt(int max) {
        return random.nextInt(max);
    class EuropeanSwallow extends Bird {
      double getAirSpeed() {
        return getBaseSpeed();
    class AfricanSwallow extends Bird {
      private int _numberOfCoconuts;
      public AfricanSwallow() {
        this(randomInt(4));
      public AfricanSwallow(int numberOfCoconuts) {
        _numberOfCoconuts = numberOfCoconuts;
      double getAirSpeed() {
        return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts;
      public double getLoadFactor() {
        return randomDouble(3.12);
    class NorwegianBlue extends Bird {
      private boolean _isNailed;
      private double _voltage;
      public NorwegianBlue() {
        this(randomInt(10)<2, randomDouble(12.0));
      public NorwegianBlue(boolean isNailed, double voltage) {
        _isNailed = isNailed;
        _voltage = voltage;
      double getAirSpeed() {
        return _isNailed ? 0 : getBaseSpeed(_voltage);
      double getBaseSpeed(double voltage) {
        return getBaseSpeed() * (1+(voltage/Math.PI));
    public class AirSpeedTest
      public static void main(String[] args)
        System.out.println("EUROPEAN: "+new EuropeanSwallow().getAirSpeed());
        System.out.println("AFRICAN: "+new AfricanSwallow().getAirSpeed());
        System.out.println("NORWEGIAN_BLUE: "+new NorwegianBlue().getAirSpeed());
    }... and the requisite background for the uninitiated [NORWEGIAN_BLUE|http://www.youtube.com/watch?v=4vuW6tQ0218] and [EUROPEAN v AFRICAN|http://www.youtube.com/watch?v=4b4bGAoVR7g].
    You have to know these things when you're a King you know.
    Cheers. Keith.

  • SERVICE LOCATOR ?? Is it really an interesting Design pattern??

    Hi everybody,
    i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
    It is said that by making use of a Service Locator we can :
    - hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
    - multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
    But i would like to understand at which side should that service locator object reside??!!??
    If it is at server side then the clients need well an initial context in order to make a lookup on that object.
    Conclusion :
    the service locator doesn't hide the complexities of initial context!!
    Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
    If it is at client side, each client needs his own services locator object
    Conclusion :
    multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
    There is certainly something that i don't understand so help me please!! Thanks.

    Hi Yves,
    But i would like to understand at which side should
    that service locator object reside??!!??
    If it is at client side, each client needs his own
    services locator object
    Conclusion :
    multiple client don't reuse the same service locator.
    What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
    a singleton. Since it is possible that there could be multiple
    class loaders/JVMs on the client side, and therefore, multiple
    instances of the "singleton" service locator. This is typical
    in a distributed environment (e.g. servlets/JSPs in a web-tier
    cluster using service locator). Thus service locator is not
    a truly "distributed singleton" object. But, the empahsis
    is to design the service locator such that it does not hold
    any state that needs to be replicated across multiple
    instances across different JVMs as mentioned. Thus, there
    is no need for multiple clients to use the "same" service locator,
    but still the benefits of implementing this pattern is realized.
    By making it a singleton, and keeping it from holding state
    that needs to be replicated, we realize the benefits of this pattern.
    You may also want to visit the J2EE Pattern interest list
    and see these relevant discussions :
    Topic: Service Locator and passivation
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
    Topic: Caching EJBHome interfaces
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
    Topic: Using Service Locator for Data Source caching
    http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
    hope this helps,
    thanks,
    -deepak

  • 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

  • Producer/Consumer Design Pattern with Classes

    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Jason

    JTerosky wrote:
    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Including the error cluster as part of the  private data is something I have never seen done and ... well I'll have to think about that one.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Producer/Consumer Design Pattern + DAQmx + Event Structure

    Dear community users,
    at the moment I try to implement the Producer/Consumer Design Pattern into my current project. For this purpose I am trying to make a "minimal-example" in which I use the Producer/Consumer Design Pattern for the data acquisition and analysis (display in GraphXY, calculation etc..) process. In the Producer Loop I perform the data readings via DAQmxRead.VI and in the Consumer Loop, in this example only, I display the data in a GraphXY. At the same time I want to control the data acquisition via an Event Structure, for example Start Measurement/Stop Measurement Buttons. To configure the measurement time, for example if the user only wants to measure 150 sec, I use the Time Out Event of the Event Structure. This is a technique which is often used, when data acquisition and Event Structures are used at the same time (Excuse me if this is wrong!). Due to understand the Producer/Consumer Design Pattern I looked up in the Template\Framework of LabVIEW.
    In the attachment you will find my "minimal-example", which -sadly-, not working. What should I do ? 
    Thank you.
    Best regards,
    tugrul öztürk
    Attachments:
    daqEngine_PCP.vi ‏35 KB

    Your VI will never stop due to the Ok Button that stops the producer loop is read OUTSIDE of the loop.  Add an event case for it.
    Move the Start and the Ok Button inside of their respective event cases.  This will allow the latch to reset when they are read.
    Change the Ok Button to a stop button.
    Use a Greater Or Equal instead of Equal for the measurement time comparison.  What if somebody randomly changes it to 0 on you?  Again, you will never stop.
    Is the DAQ only supposed to read for "Measurement Time".  Right now, it constantly reads.  So if you don't use the DAQmx Read, you will get a buffer overflow error.  You need to put the DAQmx Start Task inside of the Start event case and then the Stop DAQmx Task inside of the Timeout event case when the measurement time is exceeded.  You should also perform the read regardless inside of the Timeout event case.
    I HATE telling the consumer loop to stop by destroying the queue.  You can look data that way.  Instead, send something an empty array.  In the consumer, check for an empty array.  If it is empty, stop.  Destroy the queue only AFTER BOTH LOOPS HAVE COMPLETED.
    You should also report your errors in some way.  Simple Error Handler at the minimum.
    Since you are using Continous Samples, don't limit the buffer.  Leave the Samples per Channel unwired on the DAQmx Timing VI.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Chain of Responsibility Design Pattern

    Is there any java api which helps in implementing Chain of Responsibility Design pattern by parsing a XML file?. Can I use XML file to do this in Apache Commons Chain API?

    A quick look at the javadocs for that project suggest that, yes, indeed they do provide a way to specify a chain of command using XML.
    In fact I'm kind of confused why you even asked this question, since you already seem to know the answer.
    I've never heard of such a thing in the standard API, if that's what you're asking, probably because it's a simple pattern to implement, and most of the pain of any implementation is likely to be due to details specific to the problem domain, not the pattern.
    If you're really eager to use XML, you might want to check out Spring. You could configure a bunch of beans in a chain, if you like.

  • How to create plug and play design pattern on a environment

    Hi All,
    Help me to get a best design for my problem statement.
    Problem Statement: I have to create a platform where I should be able to plug and play different components. explaining better with example
    Example:
    1. I have to create a platform for school
    2. In this school platform we have to plug in multiple components like "Student", "Teacher", "Subjects", "ClassPeriods" etc.,
    3. These components should be easily plug/unplug and play
    4. Like, the component "ClassPeriods" want to purchase from Vendor 1 and plug it to "School" platform it should work.
    5. Incase if we want to unplug the "ClassPeriod" component provided bfy Vendor 1 from "School" platform and want to plug the "ClassPeriod" from Vendor 2. then the Design should support without any extra effort.
    Suggest me the best design pattern for the problem
    This design pattern is for ASP.Net
    Thanks,
    S.Kannan

    Sounds like you're looking at 'Composition'. As a background, and possible solution, take a look at MEF;
    http://mef.codeplex.com/
    http://pauliom.wordpress.com

  • 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

  • Design pattern / data loading solution

    Hello all!
    I have been working on a few projects which involve loading data, sometimes remotely, sometimes local, sometimes JSON, sometimes XML. The problem I am having is that due to the speed of development and the changing minds of various clients I am finding my designs are too rigid and I would like them to be more flexable. I have been trying to think of a reusable solution to data loading, and would like some advice as I imagine many of you out there have had the same problem.
    What I would like to do is to create a generic LoadingOperation abstract class, which has member variables of type Parser and Loader, which have parse() and loadData() methods respectivly. The Parser and Loader classed are interfaces and classes that implement these could be XMLParser and JSONParser, LocalLoader and RemoteLoader etc. With something like this i would like to have a new class which extends LoadingOperation for each thing to be loaded, weather thats a local XML file, or remote JSON, or whatever.
    The problem is is that specific Parser implementation cannot return custom data types without breaking the polymorphic behavior of the LoadingOperation class. I have been messing around with generics and declaring subclasses of LoadingOperation like
    class SpecificLoader extends LoadingOperation<CustomDataType>
    and doing similar things with Parser classes, but this seems a bit weird.
    Does anyone have any suggestions on what im doing wrong / could be doing better. I want to be able to react quickly to changing specifications (ignoring the fact that they shouldnt be changing that much!) and have a logical seperation of code etc...
    thanks for any help!
    psi have also asked this question here [http://stackoverflow.com/questions/4329087/design-pattern-data-loading-solution]

    rackham wrote:
    Hello all!
    I have been working on a few projects which involve loading data, sometimes remotely, sometimes local, sometimes JSON, sometimes XML. The problem I am having is that due to the speed of development and the changing minds of various clients I am finding my designs are too rigid and I would like them to be more flexable. I have been trying to think of a reusable solution to data loading, and would like some advice as I imagine many of you out there have had the same problem.
    What I would like to do is to create a generic LoadingOperation abstract class, which has member variables of type Parser and Loader, which have parse() and loadData() methods respectivly. The Parser and Loader classed are interfaces and classes that implement these could be XMLParser and JSONParser, LocalLoader and RemoteLoader etc. With something like this i would like to have a new class which extends LoadingOperation for each thing to be loaded, weather thats a local XML file, or remote JSON, or whatever.
    The problem is is that specific Parser implementation cannot return custom data types without breaking the polymorphic behavior of the LoadingOperation class. I have been messing around with generics and declaring subclasses of LoadingOperation like
    class SpecificLoader extends LoadingOperation<CustomDataType>
    and doing similar things with Parser classes, but this seems a bit weird.
    Does anyone have any suggestions on what im doing wrong / could be doing better. I want to be able to react quickly to changing specifications (ignoring the fact that they shouldnt be changing that much!) and have a logical seperation of code etc...That depends on the specifics.
    The fact that it seems like processes are similar doesn't mean that they are in fact the same. My code editor and Word both seem to be basically the same but I am rather sure that generalizing between the two would be a big mistake.
    And I speak from experience (parsing customer data and attempting to generalize the process.)
    The problem with attempting to generalize is if you generalize functionality that is not in fact the same. And then you end up with conditional logic all over the place to deal with differences dependent on the users. Rather than saving time that actually costs time because the code becomes more fragile.
    Doesn't mean it isn't possible but just rather that you should insure that it is in fact common behavior before implementing anything.

  • 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

  • ANN: New Design Pattern (DAO)

    Hello,
    Thanks for your overwhelming response to our previous sample applications demonstrating various [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/index.html]design patterns.
    Continuing with the series, this month we have showcased the [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/dataaccesstier/index.html]Data Access Object (DAO) Design Pattern which is considered as a best practice for applications accessesing the database or the underlying persistence layer from the business tier.
    The DAO implements the access mechanism required to work with the data source. The data source could be a persistent store like an RDBMS, an external service like a B2B exchange, a repository like an LDAP database, or an XML Repository. Using the scenario of web based News Application, this sample application demonstrates the effective use of this pattern.
    [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/dataaccesstier/index.html]Download the sample application to learn more about this pattern.
    More Sample Applications are available at [url http://www.oracle.com/technology/sample_code/index.html]
    http://www.oracle.com/technology/sample_code/index.html
    Thanks,
    Rajat
    OTN Team

    Hi
    This is because you are not using the latest jdbc driver version. Either use the latest ojdbc14.jar downloadable from the location given in the readme(Oracle Database 10g (10.1.0.2.0) drivers),
    Or simply comment this part in the code.
    Also you may just replace the close method call with ods=null;
    Hope this helps
    Shrinivas

Maybe you are looking for

  • Forms built in Acrobat not working in Preview!?

    I've built a form in Acrobat Professional (with text fields and radio buttons) that we want to fill out with Preview. The idea is to open the pdf with Preview, fill it out and in the Print dialogue, to "mail as pdf". Then if you close the original pd

  • Why this movie wont stop playing?

    Hi there , Im really needing some help with my flash file here, i have been following tutorial on how to make this animated gallery http://www.flash-game-design.com/flash-tutorials/gallery-flash-tutorial.html) and i seem to be going fine with it, but

  • ME5A - ALV

    Dears, While running ME5A report using ALV, the delivery date is not coming properly, i.e.,  it is coming as '20090722'.  What should be done so that it displays properly, such as '22.07.2009'. Thanks and Regards,

  • Inserting blank page into template

    I am working in a template. I would like to insert a blank page into the middle of it and create my own thing and then continue with more pages from the template. How do I insert a blank page.

  • SAP BW 7.0 - How to use control file?

    Hello experts, In my current project, I need to use a control file to load some flat files into BW. In version 3.5 we had a option in the infopackage where we could select if it was a csv or a control file. But in 7.0 version this option is not avail