troubleshooting Question

Complex Classes Style question...

Avatar of LandyJ
LandyJFlag for United States of America asked on
XMLWCF
6 Comments1 Solution354 ViewsLast Modified:
(please forgive me if there are syntax errors. I just started typing, i hope you can get the gist of what I'm talking about)  Which style is the best/generally more accepted way of doing the following? I haven't dealt with creating REST services, so I'm curious...

Ex: I have an application where I have a user and two address: Too and Fro. Creating the classes and the WCF interface,  I come up with something like this.


<DataContract()> _
Public Class AThing
      Public User As User
      Public Fro As Fro
      Public Class Too
            Public Address As Address
      End Class
End Class

<DataContract()> _
Public Class Fro
      Inherits Address
End Class


<DataContract()> _
Public Class Address
      Private _Street As String = ""
      <DataMember()> _
      Public Property Street() As String
            Get
                  Return _Street
            End Get
            Set(ByVal value As String)
                  _Street = value
            End Set
      End Property

      Private _City As String = ""
      <DataMember()> _
      Public Property City() As String
            Get
                  Return _City
            End Get
            Set(ByVal value As String)
                  _City = value
            End Set
      End Property

      Private _State As String = ""
      <DataMember()> _
      Public Property State() As String
            Get
                  Return _State
            End Get
            Set(ByVal value As String)
                  _State = value
            End Set
      End Property

      Private _PostalCode As String = ""
      <DataMember()> _
      Public Property PostalCode() As String
            Get
                  Return _PostalCode
            End Get
            Set(ByVal value As String)
                  _PostalCode = value
            End Set
      End Property

End Class

And a XML string that looks like:
<?xml version="1.0"?>
<AThing>
      <User>
            <UserName>Me</UserName>
      </User>
      <Fro>
            <Street>123 Main St</Street>
            <City>Somewhere</City>
            <State>TX</State>
      </Fro>
      <Too>
            <Address>
                  <Street>987 Main St</Street>
                  <City>Somewhere Else</City>  
                  <State>FL</State>
            </Address>
      </Too>
</AThing>


When implementing a REST interface, which is the better way to do it? Or as a friend puts it: makes you look like you actually know what you're doing?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros