Good name (or maybe a pattern) for a client-side data accessor

Hello,
I am building a client/server app, the client is a Swing application.
The client needs to read/write information to the server. I have a set of "DAO" classes that encapsulate remote acces:
package myapp.client;
public class OrderDAO {
    public OrderDTO getDaylyOrders();
    public void saveOrder(OrderDTO order);
}The implementing class connects to an RMI server which exposes an OrderService interface with more technical methods (getOrdersForDate(Date), getPendingOrders(),...).
I just feel the name DAO is misleading on the client side, because traditionnally it is a server-side pattern, and indeed in the myapp.server package, I have a set of classes named OrderDAO as well, which do what I think is the usual work of DAOs (mask the usage of the DB to the server logic).
I'm wondering whether my client-side "DAO" actually follows the intent of the DAO pattern. Otherwise what is it, or how should it be named?
Isn't it a BusinessDelegate instead, as it encapsulates the usage of the OrderService?
Note that it is not just a Proxy to the server-side DAO class, because there is a bit of sever-side business logic (filtering and aggregation by the OrderService) between what the server side DAO returns (essentially Lists of entities mapped from the database tables) and what the client-side "DAO" returns.

It has been a while for me, but when I designed
applications I favored using some part of a design
patttern name for the main class of the pattern. For
Business Delegate objects, using the "Delegate" part
is helpful if there will ever be other software
develoeprs working with the code. Even if not, it
will help you remember the design when/if you return
to it in a few years or so.I see where you are coming from here but I think that this doesn't really hold up under scrutiny and from my paast experience. First of all, it's not feasible to rely the design with class names. You'll end up with something similar to Hungarian notation if you try. This means that you must have external design documents. It's tempting to think that classnames and JavaDocs will be enough but they aren't. They are necessary but not sufficient.
When I talk about the 'users of the class' I'm talking about other developers. The 'users of the application' don't see the classes. My experience is that naming classes or anything else with notes about it's internal implementation seems like it would be helpful but is of limited usefulness to maintenance developers. For most work the developer is only going to care what the class does (e.g. retreieve business objects) not how it does it. If the developer need to know that, they can easily open the class documentation and even the source (assuming that's available.
If you do end up doing this, you also need to think about what will happen if you change the design under the hood of the class. Do you change the name of the class? You really should, if it's name is based on the design. What I've seen happen too often is that it does not happen and the class is named as it if does one thing but acutally does something else entirely.
OrderServiceDelegate would be an informative
name because it would imply that the actual code for
implementing the "order service" is in another class
and that this class is for "delegating" only.That's easily determined by looking at the class documentation and like I said above, doesn't usually matter to other classes using it. That's one of the main tenets of OO design. Separation of concerns. The classes that use this shouldn't need to know how it does it's job (althought, this is not always feasible IMO.) If the classes depend on a BusinessDelegate, then what do you do if you move the class to an environment where they use the Facade directly, for example. You are in effect coupling related classes to a pattern. If I have a FooRetriever, I might want one that's a business delegate, one that's a DAO and one that is a stub. The idea of coupling an interface to a pattern is strange to me.
For implementations of the Abstract Factory pattern,
I typically would include the term "Factory" in the
class name. Same goes for Facade and Proxy. Factory classes are the most likely misnamed. Often implementations of factories (I know that's not a GoF pattern) or abstract factories are named FooBarSingleton. So, if anything, don't name Singleton classes with the word Singleton.

Similar Messages

  • Looking for a client side JAXP-RPC HandlerChain example

    I would like to add a handler to the client side of a RPC call using 7.0.1. I
    can’t find any examples to follow for this logic in WebLogic or at Sun’s site.
    Does anyone know of some sample code I can browse to?
    I believe I want to add some files as attachments to a RPC call. To add them
    to the message, it looks like I should add them as an attachment in the handler.
    I see how this is done in the handler. However, I can’t find any useful documentation
    on setting the HandlerChain. I attempted this by following the Javadocs (HandlerRegistry,
    QName, HandlerInfo), but I must have left something out.
    Any suggestions for examples to follow?
    Thanks,
    Dave

    An example attached:
    regards,
    -manoj
    "Dave Lyons" <[email protected]> wrote in message
    news:3d9b508f$[email protected]..
    >
    >
    I would like to add a handler to the client side of a RPC call using7.0.1. I
    can't find any examples to follow for this logic in WebLogic or at Sun'ssite.
    Does anyone know of some sample code I can browse to?
    I believe I want to add some files as attachments to a RPC call. To addthem
    to the message, it looks like I should add them as an attachment in thehandler.
    I see how this is done in the handler. However, I can't find any usefuldocumentation
    on setting the HandlerChain. I attempted this by following the Javadocs(HandlerRegistry,
    QName, HandlerInfo), but I must have left something out.
    Any suggestions for examples to follow?
    Thanks,
    Dave
    [filetransfer.jar]

  • Using scan name in tns file not working at client side...

    Hi All,
    I have installed 2 node RAC -11gR2 on ORACLE VM Server 2.2.1.
    now, I want to give tnsentry to dev team to use this RACDB.
    I am using scan name in tnsnames.ora file. Also I have make scan name entry in /etc/hosts not in the DNS.
    I have below entry in RACDB server...
    RACDB =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = RWCORA-cluster-scan)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = racdb)
    == now in dev user side, If I give the same above tns entry and make entry of this scan name and two VIPs in /etc/hosts file of dev user then SQL*Plus is successfully connected but not JDBC like SQL*Developer.
    I have make below entry in dev user's /etc/hosts file:
    10.40.0.51     RWCORARAC1-vip
    10.40.0.52 RWCORARAC2-vip
    10.40.0.50     RWCORA-cluster-scan
    Is this correct way or suggest me perfect link through which I canconnect all OCI, JDBC connection from client side.
    Thanks...

    you can use JDBC thin URL in SQL developer.
    Choose NEW/DATABASE CONNECTION, then put the connection type "Advanced" and then place the jdbc url as :
    jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RWCORA-cluster-scan)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=racdb)(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=180)(DELAY=5))))

  • Design Pattern for multithreaded client server program

    I asked this question in another post, but with other stuff, so I'll distill this one.
    I am creating a multi-threaded client server program (just for learning - a chat program at this point). I built the server and client in swing, and I'm wondering what the best design pattern is for this setup. Right now all the swing stuff is in the MyServer class. In that class I have a loop accepting client connections to the serverSocket and creating a new MyServerThread (threaded client connection).
    The problem is that all the work of creating input streams, interacting with the server, all that stuff is done in the MyServerThread class, but I want that text to be written up to the Swing objects - which is in the MyServer class. So right now in the MyServerThread class I pass the MyServer object into it, but I'm not sure if that is really the most robust thing to do. Does anybody have any suggestions as to how this should be done. If somebody has an article they'd like to point to I'll check it out too. But if it's just the run-of-the-mill multithreaded client-server article, I've read alot and most don't specifically address my question.

    Thanks for the reply Kaj, and I think I'll keep my design for now, since it's just quick and dirty. I've read the MVC concept a while ago and I'll revisit it again when I get more serious. But I have a question, why should I be using a callback interface, why an interface at all? And then make MyServer implement that interface...why not just pass MyServer to the thread object? Or is there something down the line that I did not forsee?

  • Design Patterns for java swing application front a J2EE server

    Hi,
    i dont nkow that i stay in the correct forum. I am development a java swing client application, no web, and i dont know that if there are any patterns for a client of this type.
    I have readed http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
    but after of Buissnes Delegate pattern, the others one, over ejb tier, are applicated only for web clients, using servlets and jsp pages.
    If i have a swing client application, what patterns i must folow for implement the client logic of my swing application??
    thanks

    MVC pattern is one of the most used
    http://en.wikipedia.org/wiki/MVC
    http://csis.pace.edu/~bergin/mvc/mvcgui.html
    ...

  • Client-side transient model for storing temporary data

    We've been using the ODataModel in our UI5 application for retrieving data from Gateway and now we have a requirement to store temporary (session based) client-side data.  Ideally it would be stored in such a way that it can be shared across views and controllers and can be bound from UI components via property bindings.  The data in most cases will be OData entities.  As an example a user would view a list of PO's (from the ODataModel) in the first view, then select a subset of POs and move onto the next view to "work" on those POs.  We'd want to store this subset of POs in a client model so the second view can bind to the model and display them.
    My first thought is to create another model separate from our ODataModel in which we could add transient client-side data (OData entities and custom data) and make it available to all views and controllers in the app.  I realize we could probably also just store such data in global JS variables, however a client-side model seems like a cleaner approach to me.
    I'd appreciate any suggestions on how this can be achieved.

    Hi Derek,
    why don't you just use sap.ui.core.Core.setModel? You can store multiple models and access them in your entire SAPUI5 app.
    Except for SAPUI5-apps, these requirements are often realized with HTML5 Web Storage JavaScript API. As you can see in the following blog post, you can easily store even complex entities and access your items in the entire web-application: Client-side Session Management.
    I can't recommend the approach with global variables. A lot of developers had negative experiences with this design pattern. At least, use namespacing techniques to store your functions and variables in one central scope. I've written a simple example on jsFiddle to show you this. As you can see, you could also handle your transient model as an additional variable of your own namespace.
    Regards Michael

  • Books about MVVM, architecture, design patterns for Windows Phone 8.1

    Hi,
    I'm looking for a book or books (or other resources) that explain how to develop an app with a proper architecture. I mean what each layer (bussines layer, data layer, network access) should do and how should it look like. I'm also looking for a book about
    MVVM.
    Right now I'm struggling with how to create a layer for network communication - how to separate classes for requests and responses, how to manage requests and create some queue of requests and also to provide some way to cancel them when they are no longer
    needed, how to work with servers that use some level of security (cookies, certificates etc.).
    Another thing is caching - how to design a short-term cache or a persistant cache (database), what technologies I can use etc.
    Last thing that I'm struggling with is also naming. How to name classes in those layers, e.g. to distinguish between classes mapping data from some ORM database, for mapping on JSON in network communication. etc.
    I hope you got the idea :)
    Thanks.

    Currently, I don't find a book about MVVM pattern for Windows Phone 8.1, but I think MSDN and some blogs have some useful samples and conceptions: http://msdn.microsoft.com/en-us/library/windows/apps/jj883732.aspx
    http://channel9.msdn.com/Series/Windows-Phone-8-1-Development-for-Absolute-Beginners
    And I think your question includes too much scopes, maybe you need to split it into some blocks and get help in the related forum
    Best Regards,
    Please remember to mark the replies as answers if they help

  • 'Design Patterns' for Application User Interfaces

    I'm currently trying to unstick an architectural mess centred around a relatively simple user interface. The problem is thus:
    The application has a number of toolbar buttons and menus, some of which require a specific frame or class of frame to be enabled. Some conditions are quite simple, others more complicated.
    (Without going into any more detail, it should be possible to appreciate that this is a fairly common problem.)
    For this application, I've created a large listener that accepts events from all over the program, converting them into state changes for UI controls. It feels messy, and (although it isn't finished) I suspect it'll be rather fragile.
    JBuilder 4 does it by constant querying of application state - but this results in excessive CPU usage and apparant lag.
    TogetherJ does it for menus by checking state immediately before showing the menu. This seemed like a good plan, but it's unsuitable for the Action/Button/MenuItem lashup I like to use.
    My question is this:
    In your opinion, how should an application be structured to reliably maintain the correct UI state at all times?

    Check out the mediator pattern. It is pretty close to what you are describing, maybe the details you dig up on it will give you some new ideas?

  • Design pattern for unprotecting and reprotecting sheets with VBA?

    Many macros can't run when a worksheet is protected, so when I develop an Excel workbook that has protected worksheets, I have to unprotect worksheets when macros are called and then reprotect the worksheets once the macro has completed.
    The current design pattern I use for this is the following:
    I look at each procedure individually and consider which sheets need to be unprotected for it to run. Then in each procedure I write:
    Sub Test()
    Dim bSheet1Protected as boolean
    Dim bSheet2Protected as boolean
    bSheet1Protected = Sheet1.ProtectContents
    bSheet2Protected = Sheet1.ProtectContents
    bSheet1Protected.Unprotect
    bSheet2Protected.Unprotect
    '''The rest of my code
    if bSheet1Protected then Sheet1.Protect
    if bSheet2Protected then Sheet2.Protect
    End Sub
    But I imagine that maybe there are better ways of doing this. What is your preferred design pattern for unprotecting and reprotecting sheets with VBA?

    Hi JP3O,
    I think it is a good practice to unprotect the worksheet before execute some code and protect it back after the code execute finished.
    >>But I imagine that maybe there are better ways of doing this. What is your preferred design pattern for unprotecting and reprotecting sheets with VBA?<<
    I am not able to find a better way since we always need to unproect the worksheet if some code didn't not executed successful when the worksheet is proected.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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

  • Different url-patterns for same servlet running in 2 different environments

    Hi All,
    I have a question about url mappings in my web.xml file and I hope somebody can help. The situation is that I�m putting together a web app using a combination of JSPs and servlets. I can�t develop on the machine that it will be hosted on, so I�m working and testing on my own machine and will transfer to the host machine when finished. However, the host machine is set up to map serlvets to http://�/servlet/MyServlet but the copy of tomcat I have installed locally maps to http://�/MySerlvet. My question is, when I get ready to transfer my application do I have to go through all my code and find serlvet references and insert the �servlet/� path info required by the hosting service, or can I just change the url patterns for the servlet mappings of the web.xml file on the host machine ? In other words:
    Local install of Tomcat where servlets are accessed at http://�/MyServlet
    <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/MyServlet </url-pattern>
    </servlet-mapping>
    Host machine install of Tomcat where servlets are accessed at http://�/servlet/MyServlet
    <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/servlet/MyServlet </url-pattern>
    </servlet-mapping>
    I guess my thinking is that it would be better/easier to have a remote and local version of the web.xml file that reflects the environment each one resides in and have only one codebase rather than 2 codebases and 1 web.xml file. Am I thinking about this in the right way, or have I misunderstood something?
    Thanks,
    Peter

    What you�re suggesting is logical, but won�t that
    effect all the other stuff I�ve got running on my
    local Tomcat install that expects servlets to be
    accessed at http://.../ServletName ?
    in web.xml, you decide of your mapping, so you could use the /servlet/ServletName pattern for your application that needs to be remote, and /ServletName for the rest of your stuff. You can even define more than one mapping for a servlet...
    In fact, you should probably put your whole application that is going to be on a remote server in it's own context, and to be ahead of dufymo :-) , learn to put it a war file for deployment.

  • Want detailed sample code(value list handler pattern) for my case

    I am trying to write a Session Facade Bean with getAllUsers() method which get Collection pased from my UserBean(entity), to get all my users info.and I have a helper class called UserInfo
    public class UserInfo implements java.io.Serializable
    public String userid;
    public String username;
    public String password;
         public UserInfo()
         public void setUserInfo(String userid,String username,String password)
              this.userid=userid;
              this.username=username;
              this.password=password;
    I dont' know How my ejb client(jsp maybe) to use value list handler pattern to implement getting all users shown.
    I found http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html the sample code is to complex.
    any one could help me figure out ...
    what helper class do i need .or maybe interface
    what is the best practice?
    thanks in advanced.

    Hi,
    For a J2EE system with session facades, I've implemented that pattern based on the DTO pattern.
    The idea is based on Sun's blueprint Pet Store implementation.
    For that' I've created a DTO called "ListChunk", which holds a chunk of the complete list. In the Pet Store
    application v1.3.2 it's called "Page".
    So, those facade methods that would possibly return a huge list (such as getAllXXX and findXXX)
    return a ListChunk. As arguments, those methods take start index and the maximum size.
    If you want a value-list handler to control the iteration on your client side, you code such a class that
    uses the facade method.
    Here's some code:
    public class ListChunk implements Serializable {
         private List list;
         private int startIndex;     // starts on '0'
         private int totalSize;
         public ListChunk(List list, int startIndex, int totalSize)  {
              this.list = list;
              this.startIndex = startIndex;
              this.totalSize = totalSize;
         public List getList()  {
              return list;
         public int size()  {
              return list.size();
         public boolean hasNext()  {
              return totalSize > (startIndex + list.size());
         public boolean hasPrevious()  {
              return startIndex > 0;
         public int getTotalSize()  {
              return totalSize;
    }And a method in the facade could look like this:
         public ListChunk getAllCoWorkers(int startIndex, int maxSize, CoWorkerSortBy sortBy) {...}

  • Do I use the Brdige pattern for this problem ?

    Hello
    I'm making a music mixer for mobile phones. For the canvas, i divided it up in tiles, to fill
    up with .png images if you want to place a sample in that specific tile. But if you have a phone with no colors and your screen is not big enough, the image is almost all black. So I want to create a different class, to only show a letter or a simple symbol if you can't handle the .png well.
    I read about the bridge pattern, where you encapsulate the implementation in an abstract class and seperate it from the base class with the abstractions. Should I use this pattern for my problem ? I have some doubt because I have multiple implementations (color vs non-color) but I don't have multiple abstractions (a tile to fill up with a symbol or picture).
    Are there other patterns that are more suited for my problem ?
    What about the implementation? Should I see the implementation as only producing the image or symbol, or should i see it as the whole canvas, with the tile system?
    For example, now the tiling looks good on most of the targeted phones. But what if the next generation of mobile phones has a screen with very different dimensions. Wouldn't it be better to incorporate this also in the implementation ?
    Thanks

    What are you trying to do when you say "When I put the password for my apple ID into icloud- it keeps reverting to another password"?
    Where are you doing when you try to enter your password?

  • Design patterns for keypad...

    Hi All,
    what design patterns should I use If I need to program a front panel(
    keypad+display) for a phone which is going to have a lot of many different commads?
    are there any good examples ?
    thanks.

    . What design patterns can be used for data access to
    ensure that only a minimum amount of data is
    maintained in sessionThat's not a design pattern, that's business logic.
    Your application has to determine what "minimum" means.
    Martin Fowler has lots of patterns for data access in his "Patterns of Enterprise Application Architecture". Check them out.

  • I have garageband 11 and need to know how to make a good deep bass drum that thumps for a rap type song - thanks

    I have garageband 11 and need to know how to make a good deep bass drum that thumps for a rap type song - thanks
    just getting started so I would appreciate some assistance
    Mike

    Quit Mail. Force quit if necessary.
    Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Mail/V2/MailData
    Copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
              Go ▹ Go to Folder
    from the menu bar. Paste into the box that opens by pressing command-V, then press return.
    A folder window will open. Inside it there should be files with names as follows:
              Envelope Index
              ExternalUpdates.storedata
    Move those files to the Desktop, leaving the window open. Other files in the folder may have longer names that begin as above. Move those files, if any, to the Trash.
    Relaunch Mail. It should prompt you to re-import your messages. You may get a warning that the index is damaged and that Mail has to quit. Click OK. Typically, the process takes a few minutes, but it may take hours if you have gigantic mailboxes. In that case, you may be able to speed things up by temporarily adding your home folder to the Privacy list in the Spotlight preference pane. Remove it when Mail has finished importing.
    Test. If Mail now works as expected, you can delete the files you moved to the Desktop. Otherwise, post your results.

Maybe you are looking for