6 Replies Latest reply: Nov 10, 2010 4:51 AM by jwenting RSS

    Data Transfer Objects

    269490
      Is it safe to assume that Data Transfer Objects should be populated by Business Objects that are local to entity beans or whatever is being used to populate them?
        • 1. Re: Data Transfer Objects
          jschellSomeoneStoleMyAlias
          DTOs are used by whatever uses them. The data in a DTO is allowed to be modified whatever modifies it.

          Business logic (as defined by the needs of the application not a specific application layer) define how and where that occurs.

          Other than that "safe" doesn't have much to do with DTOs themselves.
          • 2. Re: Data Transfer Objects
            269490
            jschell wrote:
            DTOs are used by whatever uses them. The data in a DTO is allowed to be modified whatever modifies it.

            Business logic (as defined by the needs of the application not a specific application layer) define how and where that occurs.

            Other than that "safe" doesn't have much to do with DTOs themselves.
            So if the point of DTOs is to reduce network traffic, why would you initially populate them using a remote object? Wouldn't that just defeat the purpose of them?

            Edited by: ttb999 on 5-Nov-2010 1:01 PM
            • 3. Re: Data Transfer Objects
              jschellSomeoneStoleMyAlias
              So if the point of DTOs is to reduce network traffic, why would you initially populate them using a remote object?
              That doesn't have anything to do with what I said.
              • 4. Re: Data Transfer Objects
                269490
                jschell wrote:
                So if the point of DTOs is to reduce network traffic, why would you initially populate them using a remote object?
                That doesn't have anything to do with what I said.
                Well that was the jist of my question.
                • 5. Re: Data Transfer Objects
                  jschellSomeoneStoleMyAlias
                  ttb999 wrote:
                  jschell wrote:
                  So if the point of DTOs is to reduce network traffic, why would you initially populate them using a remote object?
                  That doesn't have anything to do with what I said.
                  Well that was the jist of my question.
                  Your statement has a historical perspective which probably doesn't mean much in current DTO usage.

                  Originally RMI was promoted as a a 'method' interface. As such you would have had the equivalent of a DTO with setter/getter for each attribute. Each setter/getter would invoke a remote procedure call to the server.

                  Thus a data object with 5 attributes would cause 5 network calls to 'populate' the attributes.

                  That was vastly inefficient.

                  Consequently the first DTO type (which was not called a DTO) was promoted as a way to avoid that.

                  If you want you can look up "Remote Procedure Call" (RPC) which would have been the origin of where the 'method' idiom originated.
                  • 6. Re: Data Transfer Objects
                    jwenting
                    jschell wrote:
                    ttb999 wrote:
                    jschell wrote:
                    So if the point of DTOs is to reduce network traffic, why would you initially populate them using a remote object?
                    That doesn't have anything to do with what I said.
                    Well that was the jist of my question.
                    Your statement has a historical perspective which probably doesn't mean much in current DTO usage.

                    Originally RMI was promoted as a a 'method' interface. As such you would have had the equivalent of a DTO with setter/getter for each attribute. Each setter/getter would invoke a remote procedure call to the server.

                    Thus a data object with 5 attributes would cause 5 network calls to 'populate' the attributes.

                    That was vastly inefficient.

                    Consequently the first DTO type (which was not called a DTO) was promoted as a way to avoid that.

                    If you want you can look up "Remote Procedure Call" (RPC) which would have been the origin of where the 'method' idiom originated.
                    And quite apart from performance, populating a local object from the remote prevents disruption of the local data in case the network connection is (temporarilly) lost.