Basic Design Problem: Using an interface as flag

My problem is pretty basic - i just want to know the best way to design that:
Imagine, you have an interface Example. There are two abstract classes implementing this - ExampleOne and ExampleTwo.
Now there may be dozens of classes that subclass one of these two. They provide certain things that may be cacheable or not. By default it should be, but if the class implements NonCacheableExample its results must not be cached.
I tried it by adding an attribute "cacheable = true" to the Example interface and "cacheable = false" to the NonCacheableExample. This doesn't work of course - when i try to retrieve the attribute from whatever class it is always "true", no matter if it implements NonCacheableExample or not. I guess the attribute inherited from the abstract class is "stronger" than the one from the interface.
The only easy way I could imagine would be to add an interface CacheableExample, so that a class needs to implement either Cacheable- or NonCacheableExample - however I'd like it to be cacheable by default.
Puh... I hope that was somehow understandable. Any ideas?

My problem is pretty basic - i just want to know the
best way to design that:
Imagine, you have an interface Example. There
are two abstract classes implementing this -
ExampleOne and ExampleTwo.
Now there may be dozens of classes that subclass one
of these two. They provide certain things that may be
cacheable or not. By default it should be, but if the
class implements NonCacheableExample its
results must not be cached.
I tried it by adding an attribute "cacheable = true"
to the Example interface and "cacheable =
false" to the NonCacheableExample. This
doesn't work of course - when i try to retrieve the
attribute from whatever class it is always "true", no
matter if it implements NonCacheableExample or not. I
guess the attribute inherited from the abstract class
is "stronger" than the one from the interface.Let's get one thing straight - there ARE no attributes associated with an interface. They're pure signatures, nothing else. You can have static data members, but no attributes.
If the abstract class appears "stronger", that's because it's the only one with attributes.
>
The only easy way I could imagine would be to add an
interface CacheableExample, so that a class
needs to implement either Cacheable- or
NonCacheableExample - however I'd like it to
be cacheable by default.
Puh... I hope that was somehow understandable. Any
ideas?You have have a Cacheable interface that includes addToCache() and removeFromCache() methods. The AbstractCacheable implementations of these methods can default to meaningful behavior. The AbstractNonCacheable can implement these methods in such a way that they're no-ops or throw the runtime exception that indicates OperationNotSupported.
Personally, I think this is a bad design. You don't want to build in cacheable or not into an object. If you look at what people are doing with POJO persistence, they go to a great deal of trouble not to have to build persistence into the objects. No marker interfaces like Persistable. I think you should follow this course, too.
Why would something NOT be cacheable? If you have a cache and an object, under what circumstances would you want to absolutely prohibit caching?
Better to stop spending so much time thinking about this and more time thinking about getting a good cache, preferrably not one that you have to write. EHCache and OSCache come to mind. Go get those and get on with it. Neither of them require anything like a Cacheable interface.
%

Similar Messages

  • Dreamweaver - Properties - Basic Design Problem

    I have been using Dreamweaver 8 for some time now with no
    problems but now when I opened a page in Dreamweaver last night it
    appears to have lost all of it's properties and gone back to basic
    design. When I try to change the properties like changing the font
    to bold or increasing the size of the font - It won't let me - It
    just says basic The links have also gone back to the basic blue
    rather then black which is the colour i set them to.
    I have obviously changed some kind of setting but don't know
    which one.
    I tried downlaoding my site from the server to the
    dreamweaver root folder to see if this would solve the problem but
    again it looks very basic.. When I preview the site in internet
    exploer it looks how it was originally designed.
    Help!!!

    Please keep this on the DW forum.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "mickeyboi79" <[email protected]> wrote in
    message
    news:em1av3$qev$[email protected]..
    >I have been using Dreamweaver 8 for some time now with no
    problems but now
    >when
    > I opened a page in Dreamweaver last night it appears to
    have lost all of
    > it's
    > properties and gone back to basic design. When I try to
    change the
    > properties
    > like changing the font to bold or increasing the size of
    the font - It
    > won't
    > let me - It just says basic The links have also gone
    back to the basic
    > blue
    > rather then black which is the colour i set them to.
    >
    > I have obviously changed some kind of setting but don't
    know which one.
    >
    > I tried downlaoding my site from the server to the
    dreamweaver root folder
    > to
    > see if this would solve the problem but again it looks
    very basic.. When I
    > preview the site in internet exploer it looks how it was
    originally
    > designed.
    >
    > Help!!!
    >

  • Problems using an interface with Logic

    I've just bought Logic for the first time and am trying to hear my guitar which is plugged into an iO/2 brand interface going into the computer via USB. The iO/2 is recognized when I create a new External Midi track but having tried everything, I cannot hear the guitar. It works with Garageband and I can hear it when plugging it directly into the computer with the Garageband cable and in audio preferences setting the device to 'Built in Input', when its set to 'iO/2' nothing can be heard. Do i need to use the Midi output on the interface instead of the USB? Also is it possible to hear a midi keyboard plugged directly in via USB as well as the guitar going through the interface at the same time?
    Many thanks

    It also says No In No Out in the status pane at the bottom of the screen.
    This is what you need to correct.
    It's implied but you did not mention specifically if the bottom I/O button is blank or shows Out 1-2. So I have to guess more at what you are seeing.
    Where "specifically" are you seeing no in no out?
    Here?
    If so, then are you saying if you select the input or output buttons there you do not have options to choose input 1 and output 1-2 similar to below?

  • Problems using math interface toolkit

    Hi! I'm trying to use the Labview Math Interface Toolkit to make a *.dll and a *.m file that will allow me to control a camera (via a PCI-1411 card) in either IDL or Matlab. When I used my *.m file in Matlab, I'm given this error message in Labview: IMAQ Vision: (Hex 0xBFF604A5) file not found. When I run the vi, everything works fine. Any suggestions on what I should change? Thank you.
    Attachments:
    Get_Pic.m ‏1 KB
    Snap_and_Save_to_File_MODIFIED_ICON.vi ‏91 KB

    Hello.
    The Math Interface Toolkit, as you know, simply turns the VI into a DLL, and then calls the LabVIEW DLL.
    This error that you are seeing is because the path that you are feeding the VI is not working. If you run this VI in the development environment and give it a valid path, then you will see the same error. Ensure that you are feeding a valid path to the VI (C:\Image)and you should see the error go away.
    Regards,
    Colin C.
    Applications Engineering
    Colin Christofferson
    Community Web Marketing
    Blog

  • Please explain Importance of Interfaces ....? [Basic Conceptual Problem..]

    Hi everyone..
    i am new to java..i want to know the importance of interfaces in java....
    interface A{
    public void print();
    class B implements A{
    public void print()
    System.out.println("Please explain me the importance of Interfaces");
    the class B can also be defined with out interface as the following...
    class B {
    public void print()
    System.out.println("Please explain me the importance of Interfaces");
    Both the classes have the same functionality ... then what the use of declaring an Interface and implementing it...?
    PLEASE EXPLAIN BASIC USE OF INTERFACES....?
    Note: Ignore any syntax errors in the code that i have written above
    thanks in advance

    In Java, mostly we use inheritance for code reuse.
    public class Toy{
    public class Ball extends Toy{
    }Suppose there is another class Type which doesn't related to Toy family.
    public class Tyre{
    }Now we know that Ball and Tyre are bouncable. So we will have to implement bounce() method in both class which behave differently.
    public class Ball extends Toy{
        public void bounce() {
    }Suppose there is another class Type which doesn't related to Toy family.
    public class Tyre{
        public void bounce() {
    }*If want to collect bouncable things into a single collection, then how can we do that?*
    There is way, we can use abstract class:-
    public abstract BouncingThings {
    public abstract void bounce();
    }Now things that are bouncable can extend BouncingThings class and the collection of bounce things will be
    BouncingThings [] bouncingThings;
    But there is one problem Java doesn't allow multiple class inheritance. So Ball can't extend both Toy and BouncingThings.
    We can use interface:-
    public interface Bouncable{
    void bounce();
    public class Ball extends Toy implements Bouncable{
    public void bounce(){
    public class Tyre implements Bouncable{
    public void bounce(){
    Bouncable[] bouncableThings = { new Ball().new Tyre() };Edited by: SandipGaikwad on Oct 16, 2007 12:23 PM

  • Problem in using ErrorHandler interface

    Hi ,
    I have a problem with Errorhandler interface.I use errorhandler class to handle the errors/warnings while parsing an XML file.Incase of an error,a JOptionPane pane is displayed to get user confirmation.If there is only one error while parsing my code is working fine. But if there are more then one error, it displays the JOptionPane for each error till the last error. I want the JOptionPane to be displayed only once.
    Can anyone help me to fix this?
    try {
              hErr = new MyErrorHandler1();
              DocumentBuilder builder = factory.newDocumentBuilder();
              // Set the Error handler
              builder.setErrorHandler(hErr);
              // Parse the XML Document
              document = builder.parse(f);
              if (Index.equals("T")){
              else{
    catch(){
    }If there is a Parsing error, then MyErrorHandler class is called
    class MyErrorHandler1 implements ErrorHandler{
            public void error(SAXParseException exception)
                 System.out.println("\n Error occured...."+ exception);
              try{
                     JOptionPane.showMessageDialog(null,"Parsing error occcured");
                     int response = JOptionPane.showConfirmDialog(null, "Do you want to continue?", "Confirm",     JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                                             if (response == JOptionPane.NO_OPTION)
                    System.out.println("No button clicked");
                     System.exit(0);
                                            else if (response == JOptionPane.YES_OPTION)
                    OrderFrame orderframe = new OrderFrame();
                                             else if (response == JOptionPane.CLOSED_OPTION)
                    System.out.println("JOptionPane closed");
              catch(Exception e){
                   System.out.println(e);
         public void warning(SAXParseException exception)
         public void fatalError(SAXParseException exception)
    }

    Rather than calling a dialog in your ErrorHandler, increment a counter. Then call a cleanup method. Example (this is pretty rough, but hopefully you get the idea):
    try {
              hErr = new MyErrorHandler1();
              DocumentBuilder builder = factory.newDocumentBuilder();
              // Set the Error handler
              builder.setErrorHandler(hErr);
              // Parse the XML Document
              document = builder.parse(f);
              hErr.finish(); // NEW CODE HERE
              if (Index.equals("T")){
              else{
    catch(){
    class MyErrorHandler1 implements ErrorHandler{
         private int errorCount=0;
            public void error(SAXParseException exception)
                 System.out.println("\n Error occured...."+ exception);
              try{
                   errorCount++;
              catch(Exception e){
                   System.out.println(e);
         public void warning(SAXParseException exception)
         public void fatalError(SAXParseException exception)
         public void finish() {
              if (errorCount > 0) {
                     JOptionPane.showMessageDialog(null, errorCount + "parsing error(s) occcured");
                     int response = JOptionPane.showConfirmDialog(null, "Do you want to continue?", "Confirm",     JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                                             if (response == JOptionPane.NO_OPTION)
                    System.out.println("No button clicked");
                     System.exit(0);
                                            else if (response == JOptionPane.YES_OPTION)
                    OrderFrame orderframe = new OrderFrame();
                                             else if (response == JOptionPane.CLOSED_OPTION)
                    System.out.println("JOptionPane closed");
         public void warning(SAXParseException exception)
         public void fatalError(SAXParseException exception)
    }Edited by: Hushpuppy on May 27, 2008 8:45 AM

  • What is the basic use of Interface Tables

    Hi there,
    We are trying to connect and send data to the EBS Oracle System.
    We are facing different scenarios and I don't know which one to use in which scenario?
    So if I add a vendor for instance, should I use the Interface tables or call a stored procedure?
    When using interface tables would I have a feedback? Success/Failure and if there is a failure would I have a detailed exception (Name too long, id mendatory...etc.)
    Same question for stored procedure
    A simple answer would be very helpful, and a link to any documentation would be great
    Thanks

    Hi,
    using interface tables is - normally - accompanied by a concurrent request, which does data validation, generation of a report and data import as well.
    So - if you are using correct data structures - using interface tables and running matching concurrent request might save you a lot of time.
    Most concurrent requests which are processing open interface tables are generating some detailled reports on records being processed or having
    failed validation. In addition you normally have some kind of status flag in open interface tables indicating processing state and sometimes error codes
    as well (see gl_interface table or ap_invoices_interface tables).
    When using api packages, you may have more flexibility (sometimes more features, when looking at the TCA apis), but you have to do some extra
    coding for validation, populating default values and so on.
    API Packages do always return a success/error state, which can be extracted in detail by using fnd_msg_pub package - but you have to code it by
    yourself.
    I would say open interface tables are a bit easier to handle whereas some of the api packages need more experience (e.g. when talking about TCA apis,
    there are some steps to do in the right order to get a customer created).
    Regards

  • I'm using ver 4.0.1.: every search yields only 4 rows (2 pages) of images. Is this a settings or design problem?

    I'm using version 4.0.1.: every search yields only 4 rows (2 pages) of images. Is this a settings or design problem? Its not a computer problem, as I get many screens of image rows when I use Internet Explorer.

    You may want to ask this in the Dreamweaver Extensions forum or the Extension Developer's own support forum. You will likely get faster answers there.
    Brad Lawryk
    Adobe Community Professional: Dreamweaver
    Northern British Columbia Adobe Usergroup: Manager
    Thompson Rivers University: Dreamweaver Instructor
    My Adobe Blog: http://blog.lawryk.com

  • Problem with local interfaces using oc4j 9.0.4 standalone

    I am not able to get oc4j 9.0.4 standalone to use local interfaces. I belive that my configurations and code are correct. I am receiving javax.naming.NameNotFoundException
    whenever I attempt to lookup a local ejb
    lookup code
    Context context = new InitialContext();
    ApplicationBMPLocalHome appBMPLocalHome = (ApplicationBMPLocalHome)context.lookup("java:comp/env/ejb/ApplicationBMPLocalHome");
    part of ejb-jar.xml
    <ejb-local-ref>
    <ejb-ref-name>ejb/ApplicationBMPLocal</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>JRun2.ApplicationBMPLocalHome</local-home>
    <local>JRun2.ApplicationBMPLocal</local>
    <ejb-link>ApplicationBMP</ejb-link>
    </ejb-local-ref>
    I know that local interfaces did not work in 9.0.3 oc4j, bu t I assume that this problem was fixed in 9.0.4. Correct me if that is not the case.

    In your code you look up ApplicationBMPLocalHome, but your <ejb-ref-name> is ApplicationBMPLocal.
    Try too change your lookup to
    (ApplicationBMPLocalHome)context.lookup("java:comp/env/ejb/ApplicationBMPLocal");
    /Fredrik

  • The new ibook app and ibook update is designed for iPhone 5 operating system.   When my iPhone4 recently updated the ibook app, it created many problems using the ibook to download and read my books.    Can I get the previous ibook app back on my phone.

    The new ibook app and ibook update is designed for iPhone 5 operating system.   When my iPhone4 recently updated the ibook app, it created many problems using the ibook to download and read my books.    Can I get the previous ibook app back on my phone.

    Check your trash can on the desktop. The old version is automatically moved to the trashcan. You should be able to move it from the trashcan back to the Apps folder within the iTunes folder. The update that was pushed out was for iBooks to work with iOS 7 not iPhone 5. iOS 7 was released today.

  • Design problem: RS232 communication

    Hi,
    I have a design problem for communication with a device via RS232. Since I'm normally a C++ programmer I might just look at the problem from a wrong angle and hope for some hints how to do it in LabVIEW.
    The scenario:
    A device is communicating with the PC via RS232. The device permanently sends data packets. At the same time, commands can be sent to the device and it returns replies. Data packets and reply packets are arbitrarily mixed, i.e. after sending a command there could be a couple of date packets before the reply comes back but the packets can be distinguished by an identifier.
    At least one, ideally several VIs should communicate with the device. Commands should be sent by pressing buttons and the incoming data should be parsed (the packets contain mutliple data streams) and shown on graphs or saved to files.
    My initial idea:
    Coming from C++ I wanted to build a class for the communication that permanently reads the incoming data and splits it to reply and data packets. This class would then have a function to send out a command and would return the reply or a timeout and it would be possible to register and unregister listeners (I wanted to use queues for this) for the various data streams.
    The problems I ran into:
    There were a couple but the two most pressing problems were: how could I communicate with the constantly running sample VI (e.g. to stop sampling) and how could I propagate changes to the class to it (e.g. new listeners). Since it is not returning I don't see a good way to implement it as in instance funcion (i.e. pass it the object). I could probably not let the sample function run continously but call it periodically from outside. However I planned to implement the class as a singleton, so it could be used parallely from different VIs.
    Is there a best practice for a case like this?
    I'm glad about any hints or ideas.
    Thanks,
    Tobias

    tfritz wrote:
    Hi,
    thanks. Since almost the same thing was suggested to me in a German forum I guess this is really common practice (using one VI with different methods controlled by a queue). It still seems a little "unnatural" for me but my biggest concern (bad interface description) was shattered by the suggestion in the link you sent me to wrap these functions with wrapper VIs, thus caller VIs won't have to deal with the call-by-queue-mechanism. This might also be easier to port to a different implementation later. However I still see the danger that the continously running VI could easily become bloated. 
    It also requires me to change the way I have looked at VIs until now. In our course they told us that VIs are basically functions. Using this design patterns, the VI becomes more of a module, really (Like a C module implemented in a C-Source file). But I will try it. It sounds as if it could work.
    I will still look into the OOP solutions a little more, though. Do I understand you correctly that you wouldn't recommend using LVOOP because it's still buggy? What about dqGOOP for example? This sounds like it could do what I need (however it doesn't seem to implement things like polymorphism, late binding and inheritance so I don't quite see what's so OOP about it. It seems more like programming with structures in C.)
    I don't know if LVOOP is buggy or not.  I think early on it was buggy and things have improved in recent versions. I have read that it doesn't have all the features that you would have in OOP like C.  I wouldn't recommend it only because I'm not familiar with it at all.  I can't recommend something that I'm not comfortable with.  If you go that route, plan on spending time in these forums and in LAVA to reading up on what others have done.  I haven't hard of dqGOOP.
    But back to your suggestion. I still have a couple of questions:
    - How do you return values from the module? Would you use a queue for that as well?
    - Where would the parameter queue be held (created and passed to the VI)
     I would store all of these in a functional global variable.  This is the VI that stores data in shift registers.  Ben's action engine nugget is an advancement on that.  This allows for both the calling VI and the parallel running subVI to get and set the data as needed.  It runs quickly so neither process should be forced to wait while the other  VI is doing its thing.
    - My VI has to be constantly sampling and this shouldn't be interrupted too long by other functions as adding a listener. However both functionalities have to access the same kind of data. Is there an easy way to parallelize this? Would the sampling be a case in the case diagram that's always used if no command was sent to the VI or would it somehow run parallely?   Yes.  There are a couple of ways of doing this.  One would be for the dequeue to have a timeout function.  In the event the dequeue times out, you run the code that is doing the acquisition.  I think a better method is that the code that does the acquisition enqueues its own command again to the end of the queue.  Let's say that is command A.  So when case A finishes, it enqueues A, which seeds itself to run again.  So if nothing else comes into the queue, it just executes A , A, A, A.  But let's say another section of code needs to do something such as command B.  It will slip B into the queue while A is executing.  So you would A, B, then A again, because A would get slipped back into the queue when the first A finishes, but B has already been put in while the first A was running.
    - Would it be possible to make the VI reentrant and in this way use it simultaneously on different COM ports (using different parameter queues as well)? I'm not sure if I will need this but it would be neat if it could work.
    I think you could do this.  It may be a case where the VI is saved as a template  (.vit) and you initiate it multiple times.  I haven't needed to do this before, so I'm afraid I can't provide any details or useful tips. 
    Well, I will fool around some more. Thanks so much for your help. This is kind of exciting since the concepts are quite new for me. Btw, is there something like an academic theory (computer science) for LabVIEW? I came across functional languages in university but data flow languages are still a new concept for me.
    Tobias
    tfritz wrote:
    Another question about the "dynamically starting" of the VI:
    How is the path handled? Is it guaranteed that it always takes the VI from the project or does it just search for the first VI by that name it finds in the file structure? Does this still work when building an .exe from the project? What happens if the VI is already running? Can you test for this?
    While I'm at it: is there a way to stop LabVIEW from searching for subVIs it can't find when openin a VI? This resulted in very unexpected behaviour sometimes where it would find the VI somewhere else (with the same name but maybe an older version).
    In my case, I just had the path hardcoded.  It is my only instance, I'm not planning on moving the VI's.  If you don't have the path, it will take a VI by that name if it's in memory.  If it isn't in memory, it starts searching relative to the calling VI's path.  One thing I know, if you are dealing with relative paths, a subVI has a different relative path in an .exe as opposed to the development environment.  The name of the .exe becomes a folder.  So in development, if your sub VI is mySubVI.vi.  In an executable, its path is MyExe.exe\MySubVI.vi
    For all of this, I recommend searching the forums to get more details.
    If it is searching for a VI, you can hit ignore.  But of course you'd have to do it before it finds it.  When you are dealing with versioning issues, I recommend making a backup copy of the entire directory structure elsewhere.  Some location where it shouldn't stumble across it.

  • Using empty interface -- is there a better way to do this?

    Hi,
    I have a set of classes in different projects that I'd like to be referenced together, although they have different methods depending on which project they're from. To do so, I've created an empty interface for each of these classes to implement, so I can return a similar type and then cast it however I need to based on which project I'm using.
    However, I feel the approach of creating an empty interface just isn't the best way to do this. I've looked into annotations, but I don't think they can solve my problem. I don't think I'm being too clear here, so let me give a brief example:
    Here is one of the interfaces I use:
    public interface IceClient {
         public IceOperations operations();
    }Here is the empty interface:
    public interface IceOperations {
    }I have a method which will return a type of IceOperations:
         public static synchronized IceOperations getOperations(String clientName) {
              if (clientMap.containsKey(clientName)) {
                   IceClient client = clientMap.get(clientName);
                   return client.operations();
              } else {
                   System.out.println("No client of that name is currently running.");
                   return null;
         }This is all fine and dandy. I need to instantiate a new IceOperations object in my client code as such, where operations is of type IceOperations:
    operations = new DiagOperations();And finally return it like this, where client.operations() returns a type of IceOperations:
         public DiagOperations operations() {
              return (DiagOperations)client.operations();
         }Anyway I hope that wasn't too confusing. I cannot think of a different way to do this. Is there some way I can do this with annotations? The only other thing I can think of is just returning Object, but that seems ... icky.
    If I need to be clearer, please let me know.
    Thanks

    JoachimSauer wrote:
    I didn't understand them to be trick questions, but rather serious invitations to question and verify your assumptions.
    It might be the fact that every current implementation implements Runnable for some reason (possibly because it starts a Thread on its own). But it's entirely possible that you can produce a completely different implementation that doesn't need the Runnable interface and still be conformant.
    If every implementation of X needs to implement Runnable, then it could be a sign of a slight design smell. Could you give an example where you think it's necessary?Every implementation of my "X" interface is basically a class that acts as a communicator/listener of sorts until it's stopped by the user, similar to a server socket. Sometimes, it has to sit there and wait for events, in which case it obviously must be in its own Thread. Other times it doesn't have to do this; however if I do not start it in its own Thread, I will have to continually stop and restart the communication to invoke operations on the server, which is inefficient.

  • Unusual use of interface defining static factory class with getInstance

    This question is prompted by a recent New to Java forum question ask about the differences between Interfaces and Abstract classes. Of course one of the standard things mentioned is that interfaces cannot actually implement a method.
    One of my past clients, one of the 500 group, uses interfaces as class factories. The interface defines a pubic static class with a public static method, getInstance, that is called to generate instances of a class that implements the interface.
    This architecture was very object-oriented, made good use of polymorphism and worked very well. But I haven't seen this architecture used anywhere else and it seemed a little convoluted.
    Here is a 'pseudo' version of the basic interface template and use
    -- interface that defines public static factory class and getInstance method
    public interface abc {
        public static class FactoryClass
            public static abc getInstance ()
                return (abc) FactoryGenerator(new abcImpl(), abc.class);
    -- call of interface factory to create an instance
    abc myABC = abc.Factory.getInstance();1. Each main functional area ('abc' in the above) has its own interface factory
    2. Each main functional area has its own implementation class for that interface
    3. There is one generator (FactoryGenerator) that uses the interface class ('abc.class') to determine which implementation class to instantiate and return. The generator class can be configured at startup to control the actual class to return for any given interface.
    I should mention that the people that designed this entire architecture were not novices. They wrote some very sophisticated multi-threaded code that rarely had problems, was high performance and was easy to extend to add new functionality (interfaces and implementing classes) - pretty much plug-n-play with few, if any, side-effects that affected existing modules.
    Is this a best-practices method of designing factory classes and methods? Please provide any comments about the use of an architecture like this.

    Thanks for the feedback.
    >
    I don't see how 'the generator class can be configured at startup to control the actual class to return for any given interface' can possibly be true given this pseudo-code.
    >
    I can see why that isn't clear just from what is posted.
    The way it was explained to me at the time is that the interface uses standard naming conventions and acts like a template to make it easy to clone for new modules: just change 'abc' to 'def' in three places and write a new 'defImpl' class that extends the interface and the new interface and class can just 'plug in' to the framework.
    The new 'defImpl' class established the baseline functionality that must be supported. This line
    return (abc) FactoryGenerator(new abcImpl(), abc.class);uses the initial version of the new class that was defined, 'abcImpl()', when calling the FactoryGenerator and it acted as a 'minimum version supported'. The generator class could use configuration information, if provided, to provide a newer class version that would extend this default class. Their reasoning was that this allowed the framework to use multiple versions of the class as needed when bugs got fixed or new functionality was introduced.
    So the initial objects would be an interface 'abc' and a class 'abcImpl'. Then the next version (bug fixes or enhancements) would be introduced by creating a new class, perhaps 'abcImpl_version2'. A configuration parameter could be passed giving 'abcImpl' as the base class to expect in the FactoryGenerator call and the generator would actually create an instance of 'abcImpl_version2' or any other class that extended 'abcImpl'.
    It certainly go the job done. You could use multiple versions of the class for different environments as you worked new functionality from DEV, TEST, QA and PRODUCTION environments without changing the basic framework.
    I've never seen any Java 'pattern' that looks like that or any pattern where an interface contained a class. It seemed really convoluted to me and seems like the 'versioning' aspect of it could have been accomplished in a more straightforward manner.
    Thanks for the feedback. If you wouldn't mind expanding a bit on one comment you made then I will mark this ANSWERED and put it to rest.
    >
    I don't mind interfaces containing classes per se when necessary
    >
    I have never seen this except at this one site. Would you relate any info about where you have seen or used this or when it might be necessary?

  • Design problem about repreatable entity relationships

    Hi all!
    As I design the data model (let's name it the ERD, no matter the name is quite unfashonable), I have found almost identical structures of entities and relationships between them, but playing completely different roles in the semantics of the model.
    It obviously makes no sense to implement all such entities separately as the Entity EJB as they are to share most of the fields and methods, but I found no "handsome" solution when trying to implement them as sets of classes and interfaces forming "the abstract EJBs", and then by putting the conrete classes and complementary interfaces at the final packages to create "concrete EJBs". The problem was about types returned by the createXXX and findXXX methods, because they had to return the "abstract" EJBs but the EJB programming contract forces them to return the "concrete" ones, that are unknown to me when defining the "abstract ones". So it cancels the sense for creating them this way. It was also unclear how to operate the relationships in such model.
    The idea was:
    1. I define BaseSthLocalHome extends EJBLocalHome
    2. I define BaseSthLocal extends EJBLocalObject
    3. I define BaseSthBean implements EntityBean
    ... this way I have the "abstract bean", and then I can create many:
    SthOneLocalHome extends BaseSthLocalHome,
    SthOneLocal extends BaseSthLocal,
    SthOneBean extends BaseSthBean ... to have the first "concrete" EJB,
    SthTwoLocalHome extends BaseSthLocalHome... and so on to create the second, third and all the next "concrete" EJBs.
    Anyway, it did not work fine as I defined createXXX and findXXX methods at the BaseSthLocalHome interface - it made sense, because those methods did not depend on the other entities.
    Has anyone some idea of how to solve the design problem? Currently we are at very beginning of the project, so we have some "case study" time, and I would appreciate any solution: redesign of the data model, extraction of new EJB modules or any use of the objective inheritance.
    Thanks in advance!
    Marcin Gawlik

    Again me - I now it is a bad idea to reply for own messages, but I have just checked a new idea:
    The problem was about re-using the same components in different roles. I tried to do that by creating subclasses of the EJB classes, but it did not work. So I tried to define multiple entity EJBs that have the same class.
    Considering the given example, it would look:
    1. public interface BaseSthLocalHome extends EJBLocalHome
    2. public interface BaseSthLocal extends EJBLocalObject
    3. public abstract class BaseSthBean implements EntityBean
    ... then I created the deployment descriptor that deploys this pack of class and interfaces as three separate CMP Entity Beans:
    1. deploy BaseSthBean as the SthOne CMP entity EJB
    2. deploy BaseSthBean as the SthTwo CMP entity EJB
    3. ... and so one
    The question is: IS THERE ANY CONTRA FOR THIS WAY OF DEPLOYING EJBS? Is there any reason for not to use the same class and its complementary interfaces many times to create many separate enity EJBs working within the same EJB module?
    Thanks in advance!
    Gaw

  • Design problem: Central MessagePool in WebDynpro App.

    Hi people,
    I have a design problem in my webdynpro application:
    I'm designing an application with different DC's. The architecture of the application is similar to the architecture described in the document "Web Dynpro Component
    Interface Defintions in Practice SAP NetWeaver ’04s": One root DC which manages the differnt child DC's, which contain the application content.
    Now I want to have a central MessagePool. Certain Messages in the child DCs are the same, and I don't want to have multiple MessagePool-entries for the same Message (each child DC has to define its own messages).  I can't  use the root DC as central MessagePool, because the Child DCs havn't access to the root-DC.
    Any idea, how to define and use a central MessagePool?
    Regards,
    Thomas

    Hi Thomas,
    Instead of the architecture what you are thinking try the architecture explained in the following link:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f4d79e59-0601-0010-0689-89670315bc6b">link</a>
    Dont forget to award points on helping answers
    Regards
    sid

Maybe you are looking for

  • Go to current song (command L) is not working in itunes 11

    Go to current song (command L) is not working in itunes 11, anyone having the same issue?

  • I am unable to sync my iPad Nano to my Computer, or to iTunes.  What do I need to do?

    I am unable to sync my iPod nano to my computer or iTunes, What am i missing?

  • Slow Loading

    Ok, Im a bit of a novice at this so I guess you guys are the best people to ask! Just ran a speed test and Im getting 632 Kbps download and 363 Kbps upload. Is that good? Anyway the problem I have is watching video over the internet, such as You Tube

  • How to manage my database?

    Hello, I'm thinking about how to structureproducts in my database. I want to set it up as efficient as possible at the start so this will save me time in the future. How I'm thinking about setting it up: In my industrie (strollers) there are often ma

  • Can't search on iOS 6 appstore

    This just started today. Using iOS6 iPhone4 No app restrictions on the iPhone When searching on the AppStore app the circle spins but I get no results. No Message. The screen is white with the search bar on the top. I can see and install apps using t