Using one remote object and multiple destinations

606 views Asked by At

In my Flex app, I use one remote object and multiple destinations. Is that a bad idea? It seems to be working just fine except for the one or two fringe cases:

  1. It's bad design, but we use the same method name on two different destinations and they seem to conflict when they're called at the same time.
  2. Logging errors show a method assigned to one destination as being associated with another.
1

There are 1 answers

2
Ian T On BEST ANSWER

As you've guessed. This is bad design for a multitude of reasons:

  • Confusing - you may understand your convention of one object/two destinations but this will present problems should anyone else attempt to contribute or maintain your work.
  • Logging/Debugging Issues - Should a problem arise down the road, having the logger reporting incorrect information could seriously overcomplicate bug tracking
  • Unnecessary - I am not familar with your code but in my experience with Remote Objects it is trivial to use a few different ones

My suggestion would be to wrap two remote objects into a single parent object. You can pass this single object/class around and still have access to both destinations.

OR

If you're anticipating adding multiple features, create a singleton class with methods for handling remoting logic. This will keep Remoting access consistent across your application and leaves the destination logic contained in one place.