I really like being able to organization my objects like this where Source is it’s own object inside the Document object.
METHOD #1
Dim doc As New Process.Document()
doc.Source.Type = "URL"
doc.Source.Data = "http://myOtherDomain/MyOtherPage.htm"
However, is it a better practice to do something like this?
METHOD #2
Dim doc As New Process.Document()
doc.SourceType = "URL"
doc.SourceData = "http://myOtherDomain/MyOtherPage.htm"
The reason I ask is because it gets a little confusing with the first method because You get this:
Process.Document.DocumentSource and doc.Source
I think that in method #1, Process.Document.DocumentSource is redundant having Document twice and wish there was a way to hide that object from being selectable in the intellisense dropdown list by the user of the assembly.
But on the flip-side, if you have a LOT of properties, it seems better to be able to group them into sub-objects like method #1 does so you don’t have a hundred properties all listed in the Intellisense dropdown list.
The Law of Demeter says Method #2 is the way to go, given just those two options.
A third method could be providing the
Sourceobject instead of settingdoc.Source.XYZ.A fourth method would effectively be constructor injection if the
Sourceis required.