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

Similar Messages

  • J2EE Decorating Filter Design Pattern

    I have been reading a little bit about J2EE patterns on Sun's web site
              (URL at bottom). The design pattern called "Decorating Filter" involves
              creating servlets that are always executed before and/or after all
              servlets.These always-executed servlets do things such as request
              logging and security.
              The idea sounds really nice to me. You can do a lot, without putting
              code for logging or security in the servlet that people actually
              requested. So, you could request a servlet, but these other servlets are
              executed before/after it automatically.
              Is there a way to do this in WebLogic? Is this "servlet chaining"?
              Thanks,
              Mike
              

    Mike,
              Checkout 6.1 it has filters implemented as part of servlet2.3 spec.
              http://e-docs.bea.com/wls/docs61///////webapp/filters.html
              Kumar.
              Michael Olivieri wrote:
              > I have been reading a little bit about J2EE patterns on Sun's web site
              > (URL at bottom). The design pattern called "Decorating Filter" involves
              > creating servlets that are always executed before and/or after all
              > servlets.These always-executed servlets do things such as request
              > logging and security.
              >
              > The idea sounds really nice to me. You can do a lot, without putting
              > code for logging or security in the servlet that people actually
              > requested. So, you could request a servlet, but these other servlets are
              > executed before/after it automatically.
              >
              > Is there a way to do this in WebLogic? Is this "servlet chaining"?
              >
              > Thanks,
              > Mike
              

  • Design patterns concern

    i am designing a graph api. i have defined interfaces for a node, arc, and graph. there are multiple interfaces defined (using inheritance) defined for each of these three interfaces.
    all my implementations of these interfaces have not considered fields relevant to display on a x-y coordinate graph. now that i have coded the implementations, i am ready to display these objects.
    the problem is that i have many implementations, but they now have to extend another interface for display. i find that i have to create a new class to implement the existing one and implement the new interface for each implementation.
    to illustrate, i have a Node interface. there are only two methods i.e. String getId() and void setId(String id). i have two additional interfaces that extends this Node interface i.e. SimpleNode and ComplexNode (these have their own pertinent methods, not listed). I have implemented the Node interface with NodeImpl, and implemented the other 2 interfaces with SimpleNodeImpl and ComplexNodeImpl, both of which extends NodeImpl and each implementing SimpleNode and ComplexNode interfaces, respectively. at this point, i define another node interface for the purpose of drawing i.e. DrawableNode (which extends the Node interface and has getters/setters for x and y coordinate.
    my problem is, how do i get SimpleNodeImpl and ComplexNodeImpl to implement the DrawableNode interface? i have considered the following approaches:
    1. have SimpleNodeImpl and ComplexNodeImpl implement DrawableNode as well as what they are already implementing (i.e. SimpleNode and ComplexNode).
    2. extend SimpleNodeImpl and implement DrawableNode interface i.e. DrawableSimpleNodeImpl (and likewise with ComplexNodeImpl).
    3. create an implementation of DrawableNode, DrawableNodeImpl, and use composition to place type Node as a field member.
    i find option #1 problematic because that means i have to define getters/setters for x and y in SimleNodeImpl and ComplexNodeImpl. this would NOT take advantage of inheritance.
    i find option #2 problematic because this would mean i would have to extends all my node implementations just to have them drawable. (i actually have more than 2 extensions of nodes that i want to draw). moreover, i would also run into the problem in option #1, where i have to define getters/setters for x and y in each of these subclasses.
    i am currently leaning towards option #3, but i find the relationship clumsy and even counterintuitive to myself; i plan to use the MVC design pattern, and i have calculated that this approach will result in a web of event/listener complications.
    i am sure there are more options, but these are the ones that i have thought of. the goals are to keep the inheritance simple, implementations to a bare minimum, and have something that will fit nicely in with the MVC design pattern.
    the general question may be: how do i design the relationships so that they will operate in the business logic layer and then be displayable on some GUI layer? is inheritance the way? or is composition the way? or is there yet another way that i have overlooked?

    really long questions dont usually get answered here.

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

  • Resizing button Decorator design pattern

    I am having the problem in doing the resizing of a button using the Decorator Design Pattern. Plz anyone who is having idea about this please send me the source code for me. I am having very less time to submit.plese replay me as early as possible

    Ever heard of Google?

  • Decorator Design Pattern

    Hi all,
    Have anybody a example of how to utilize the Decorator Design Pattern?
    Whats the functionallity of this pattern?
    Thanks.

    Check this url:
    http://www.castle-cadenza.demon.co.uk/decorate.htm
    It gives you a pretty good insight on the Decorator pattern.

  • 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

  • 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

  • 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&#65292;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

  • Could Buffer replace the Queue in Producer/Consumer Design Pattern

    Hello,
    I have a question that the task of Buffer is to store the data and the queue is also of the same so could we use the Buffer inplace of queue in a Producer/Consumer Design Pattern.
    Solved!
    Go to Solution.

    No, those buffer examples are not nearly equal to a queue and will never ever "replace" queues in producer/consumer.
    The most important advantage of queues for producer/consumer (which none of the other buffer mechanics share) is that it works eventbased to notify the reader that data is available. So if you would simply replace the queue by overly elaborate buffer mechanics as you attached to your last post, you will lose a great deal of the the purpose using producer/consumer.
    So, to compare both mechanics:
    - Queue works eventbased, whereas the buffer example does not.
    - Queue has to allocate memory during runtime if more elements are written to the queue than dequeued. This is also true for the buffer (it has to be resized).
    - Since the buffer is effectively simply an array with overhead, memory management is getting slow and messy with increasing memory fragmentation. Queues perform way better here (but have their limits there too).
    - The overhead for the buffer (array handling) has to be implemented manually. Queue functions encapsulate all necessary functionality you will ever need. So queues do have a simple API, whereas the buffer has not.
    - Since the buffer is simply an array, you will have a hard time sharing the content in two parallel running loops. You will need to either implement additional overhead using data value references to manage the buffer or waste lots of memory by using mechanics like variables. In addition to wasting memory, you will presumably run into race conditions so do not even think about this.
    So this leads to four '+' for the queue and only one point where "buffer" equals the queue.
    i hope, this clears things up a bit.
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Design pattern -- using the correct one...?

    I'm in need of some advice regarding design patterns in general.
    I have a prototype whereby Objects B, C and D observe Object A's attribute (let's call it theAttribute -- imaginative, eh? )
    In my system, every time theAttribute is changed, I've implemented the Gang's Observer pattern so that the observer objects are notified (...and do something with the information that Object A has changed in some way... they basically update a theTimestamp attribute when the subject's updated... but that really is beside the point right now).
    However, only ONE observer will ever be created for each observable subject.
    To my dismay, I've just been reading on the IBM Research site that the memory implications of this are horrendous (that for potentially a great many subjects only having a few observers each is bad practice) -- d'oh.
    I've looked at other ways I could achieve what I need to without the above practice, but the only things I can come up with are the Mediator pattern or the State pattern, neither of which I'm sure are ideal (the former because of I'm worried that it'd be total overkill, the latter because I don't really need dynamic reclassification if the truth's told, I think).
    Anyone got any thoughts on this? (I've considered referencing observers with their observables using a hash table but don't really wish to go down that route unless absolutely neccesary... it seems a bit like putting electrical tape over a sparking wire :) I'd rather just do it properly).
    Sarah.

    However, only ONE observer will ever be created for each observable subject.If you can absolutely, positively, definitely, mathematically, logically, legally
    and morally prove that fact, indeed, you're wasting some resources here,
    a couple of hundred bytes mayhap ...
    In the mean time, keep your Observer/Observable pattern/implementation
    or have a look at the PropertyChangeSupport class ...
    kind regards,
    Jos

  • The drawback of design patterns

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

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

  • [BOOK] What's the best book about DESIGN PATTERN

    Hi Guys,
    by experience, what's the best book for you concerning the Design Pattern in Abap. I mean :
    Quality,
    Comprehensiveness,
    Clearness,
    Amount of chapter,
    etc.
    Thank for advices.
    Rachid.

    Dear Rachid,
    This is rank 1 book, but u have learn online also. So many websites are there. example search: OO Design patterns ZEVOLVING.
    Regards,
    Abbas.

  • Name of the design pattern

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

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

Maybe you are looking for

  • [WinXP/Lab​View7.0]Re​ading parallel port is too slow...

    Hi, First I would like to apologize for my English. I'm from Switzerland.... I'm trying to read out a 16Bit A/D in 1us steps. Serial Communication over a PIC is too slow, so I was looking for a faster option. I found out there is possibility to read

  • Wireless accesspoint needs to be reset every morning

    We do have 2 airport extreme stations that needs to be reset every morning before users can connect to it. We connected the airports to a UPS to see if the problem disappeared but it is still there. One of the lights of the airport extreme is off (le

  • Ipod will not charge or register USB! Please Help

    Ok I have had problems with my IPod 3G but now I have no idea how to fix this one. Everytime I plug it into charge if flashes the Apple screen for a few seconds then shuts down and repeats. To add to the problem I cannot reset it because my macbook w

  • Technical problem with starting a PLM workflow!

    Hey! I am trying to start a workflow with a document, but get this message with a red light. Doc:10000000438-PDC-00-000,Table SWWWIHEAD cannot be written Anyone how now what can be wrong? I am quit sure that this is a technical problem. Thanks

  • Problems with SSID broadcast

    Hi, I have an Cisco Aironet AP1141N en have some problems with the SSID broacasting. When turn my laptop on i see the SSID en everything works great. (working 6 meters of the AP) When i turn on the desktop PC with integrated PCI wifi card sometime it