A start in design pattern

Hi guys,
I want to start learn j2ee design pattern , i browsed net but not got any significant point from where i can start. could anybody suggest me from where should i start .
Thanks in advance

The Design Patterns Java Companion
Head First Design Patterns
Huston Design Patterns
Overview of Design Patterns
~

Similar Messages

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

  • Design Patterns, best approach for this app

    Hi all,
    i am starting with design patterns, and i would like to hear your opinion on what would be the best approach for this app. 
    this is basically an app for data monitoring, analysis and logging (voltage, temperature & vibration)
    i am using 3 devices for N channels (NI 9211A, NI 9215A, NI PXI 4472) all running at different rates. asynchronous.
    and signals are being processed and monitored for logging at a rate specified by the user and in realtime also. 
    individual devices can be initialized or stopped at any time
    basically i'm using 5 loops.
    *1.- GUI: Stop App, Reload Plot Names  (Event handling)
    *2.- Chart & Log:  Monitors Data and Start/Stop log data at a specified time in the GUI (State Machine)
    *3.- Temperature DAQ monitoring @ 3 S/s  (State Machine)   NI 9211A
    *4.- Voltage DAQ monitoring and scaling @ 1K kS/s (State Machine) NI 9215A
    *5.- Vibration DAQ monitoring and Analysis @ 25.6 kS/s (State Machine) NI PXI 4472
    i have attached the files for review, thanks in advance for taking the time.
    Attachments:
    V-T-G Monitor_Logger.llb ‏355 KB

    mundo wrote:
    thanks Will for your response,
    so, basically i could apply a producer/consummer architecture for just the Vibration analysis loop? or all data being collected by the Monitor/Logger loop?
    is it ok having individual loops for every DAQ device as is shown?
    thanks.
    You could use the producer/consumer architecture to split the areas where you are doing both the data collection and teh analysis in the same state machine. If one of these processes is not time critical or the data rate is slow enough you could leave it in a single state machine. I admit that I didn't look through your code but based purely on the descriptions above I would imagine that you could change the three collection state machines to use a producer/consumer architecture. I would leave your UI processing in its own loop as well as the logging process. If this logging is time critical you may want to split that as well.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • 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

  • 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

  • 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

  • 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

  • Best architecture and design pattern to use

    I am currently designing a moderately sized LabView application and cannot decide on the best architecture/design pattern or combinations thereof to implement.
    The program basically polls an instrument connected to a serial port continuously at a 2-10Hz rate. When operator clicks a button to start a run, the polled data is then filtered, has math functions performed on the data, writes collected data to files, and produces reltime graphs and calculates point-by-point statistics. At the completion of a run, some additional data files are written. I pretty much know how to accomplish all these tasks.
    What is also required is main-vi front panel interaction by the operator to access a database (via a C# dll with .Net) to query for specifications to apply in order to determine pass/fail status. Setup conditions also need to be changed from time to time by the operator and applied to the data in real time (ie- a measurement offset). I have prototyped the database portion successfully thus far.
    For the main vi, I started off using the Top Level Application Using Events design pattern (Event structure within a while loop). Copious use of bundled clusters and shift registers keep the database data updated. I cannot figure out how to have the top level vi concurrently poll the serial device as outlined above. The Event structure is only active when defined control values change, and use of a timeout is no help since it prevent data from being collected while the user is accessing the database. All database and setup parameters must be applied to the data as it comes in from the serial port. Error trapping/recovery is a must.
    I believe what I need is two parallel processes running under my main vi (one for database and setup, the other for polling and data processing/display, but what would be the preferred choice here?
    Revert back to a polled loop in lieu of Events, use notifiers, occurrences, user-defined events, Producer-consumer loops?
    It�s been about 3 years since I have had an application on this level (which used a state machine architecture), and a lot has changed in LabView (using 7.1 Prof Devel). I am currently having a mental block while trying to digest a lot of features I have never used before.
    Suggestions Welcome!
    Thanks.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    I suggest a (3) state machine(s) architecture. The first is the user interface. Your main VI is a good start. Another state machine handles the instrument I/O (your serial polling). The third handles all data processing. The three loops run independently. Each has a wait to allow LV's scheduler to share CPU time among the loops. I like queues or functional globals for inter-loop communications.
    This allows a lot of flexibility. Each portion can be tested alone. Each can have different timing and priority.
    Spend some time thinking about what needs to be done and plan the structure carefully before you do any coding (except for little test programs to try new ideas).
    I also like Conway and Watts "A Software Engineering Approach to LabVIEW", published
    by Prentice Hall.
    Lynn

  • What is the best design pattern for multiple instrument​s?

    I have several PXI cards (DMM, O-scope, etc) that I want to create a master panel that can control all of the instruments individually, though not necessarily all at the same time (turn "instruments" on and off at will while the master vi continues to run).  Is there one design pattern (master/slave, producer/consumer, etc.) that works better than another for this type of master panel?  Are there other alternatives for this type of problem (VI Server, etc)?
    I was hoping that I could save a bunch of time if I could start on the right path right off the bat!
    Thanks,
    -Warren

    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

  • Design Pattern and ABAP Objects

    Hello Friends,
    I would like to know, if ABAP Objects can be used to do pattern oriented programming ?
    For example GANG of four has provided almost more then 30 design pattern ( MVC, singelton, Obserable, FACADE,,,etc) can we implement patterns using ABAP ??
    Many thanks
    Haider Syed

    Hi,
    Take a look at the following site:
    http://patternshare.org/
    It has all the basic patterns from the GOF and a lot more. I can recommend the ones from Martin Fowler but be sure you start with the ones from the GOF.
    All patterns are described by using UML so it's very easy to translate them into ABAP OO code.
    Regarding your other question. For the observer pattern I used an interface which the SAP had already created if_cm_observer and created my own abstract observable class. The observable class is nearly a 100% copy of the java.util. one
    regards
    Thomas

  • ABAP Object X Design Patterns X Extreme Program

    Hi Evebody,
    I’m postgraduate in Object Oriented Analysis and Programming.
    I’ve been working with ABAP procedural development for two years and I’ve started to work with ABAP Objects has few months.
    I’d like to get deeply knowledge in my development’s skills, could someone tell me if <b>ABAP Object X Designer Patterns X Extreme Program</b> is a good path to follow?
    I’d like to share material and guides about this topic.
    I’ve already bought these books to help me.
    <b>ABAP Objects</b> - H. Keller; Hardcover <i>(Pre-Order)</i>
    <b>Design Patterns Explained</b> - Alan Shalloway
    I’ll be very grateful with any help.

    > And do you think these themes are a great combination
    > for ABAP development?
    Design pattern are very abstract and can be used with any OO programming language. The implementations will differ but the core concepts are always the same.
    XP is an agile development process and can also be used with any programming language.
    Learning what design pattern are and how to use them is very important in my opinion. Most companies expect that you are familiar and have experience with them.
    Extreme Programming (XP) on the other side is different. When I began to explore XP it got me started on how software should be developed in general. Since the concepts behind XP are quite different, it should at least stimulate you to start thinking about how you develop software at the moment and if there might be better ways of doing it.
    If you have only time to study one subject go for the design pattern. You might also consider reading the following books if you want to improve your OO coding skills:
    <a href="http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672/ref=pd_bbs_sr_1/102-4989641-7820932?ie=UTF8&s=books&qid=1173448197&sr=8-1">Refactoring: Improving the Design of Existing Code (a true classic)</a>
    <a href="http://www.amazon.com/Refactoring-Patterns-Addison-Wesley-Signature-Kerievsky/dp/0321213351/ref=pd_bbs_sr_2/102-4989641-7820932?ie=UTF8&s=books&qid=1173448197&sr=8-2">Refactoring to Patterns (Shows how to improve code by introducing design pattern)</a>
    cheers
    Thomas

  • Observer Design Pattern: Looking for redesign ABAP OO code example

    Hello folks,
    I am looking for an example for ABAP OO code that has been redesigned by applying the Observer Design Pattern. I would be very interested in both the code before as well as the code after the pattern is being applied.
    Thanks in advance and kind regards, Alex

    Observer can be implemented using the EVENTS.
    I had recently implemented the observer at one of my client's place. I had screen with so many ALVs. One ALV was kind of editable and other were just showing the information of the current row as well as some total information. So, initially I started with the Main ALV and SUB(1 and 2) for other ALVs. Now, when I need to refresh my ALVs based on the main ALV data, I had to explicitly update the data of the each Sub ALV. The code was kind of static and requirement was not yet fixed.
    Later on we need to add one more ALV on the same screen. It was easy to change the existing method where I was doing the explicit refresh of each ALV. But I thought of using the Events.
    I created an event REFRESH_DETAILS for main ALV. so, when data gets changed (which I was catching by DATA_CHANGED event of ALV), I raise the event.
      RAISE EVENT REFRESH_DETAILS
        exporting new_data = it_Data.
    In Sub ALVs, I created the event handler method to handle the event REFRESH_DETAILS of the main ALV.
      methods: handle_refresh_details
          for event REFRESH_DETAILS of ZCL_MAIN_ALV.
    I also had to register the Handler.
      SET HANDLER me->handle_refresh_details FOR ALL INSTANCES.
    I'll soon write a post on my [ABAP Help blog|http://help-abap.zevolving.com/] with all the details.
    Regards,
    Naimesh Patel

  • 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

Maybe you are looking for

  • Problem with registering device in Sybase Control Center with SUP 2.2 SP04

    Hi, I have Sybase Unwired Platform SP04, and I am trying to register my Android device in Sybase Control Center. I registered application connection with HWC as a template. I also installed 2 Sybase apps from Google Play Store on my Android device -

  • JSObject missing in Forte 1.3

    Hello All, Very tired at the moment, so hoping someone can kickstart my brain, preferably with an answer to a problem that I'd probably be able to solve given 10 hours of sleep... Using the community version of Forte 1.3. Just built an applet (extend

  • Running Process Chains via abap

    Hi all, I have scenario in loading text file to cube via chains using abap, here the step: Start from abap code to check the file, if exist run the Process chains <b>Process Chains</b> a. <b>start</b> b. <b>load data</b>   c. <b>updt from PSA</b> d.

  • IPhone : Scale image in a memory efficient way?

    Greetings- I am trying to find the most efficient way to scale down an image captured with the camera and UIImagePickerController. As far as I can see with Allocations Instrument, any way I scale it down seems to shoot the memory footprint up 20mb (t

  • Displaying internal table horizontally using FM REUSE_ALV_GRID_DISPLAY

    Hi everyone,          I'm quite having difficulty deciphering on how I can display my internal table in ALV_GRID horizontally.  Example: my itab: lastname(15), firstname(20), minit(1). OUTPUT: LASTNAME             FIRSTNAME                MINIT Is th