I made this small location class so that I can better handle address information which I am going to be sending off in requests to the Google Maps API. One thing I have left to do is some validation to make sure that the address has enough information to return a result back.
For the application, the level of accuracy should be as loose as a single City (meaning that it should work as long as a zip code or city/state is provided since it will find the geographic center of that area automatically in Google Maps).
So things like:
- Address1, Address2, City, State, ZIP
- Address1, City, State, ZIP
- Address1, City, ZIP
- Address1, ZIP
- City, State
Should all work, while something like
- Address1, Address2, State
- State
- City
- Address1
- Address2
- Address1, Address2
Would not work because it would either return potentially numerous results or would put the geographic center outside my desired scope of precision.
NOTE I am sure I could list dozens of other combinations that work and do not work, but I hope I gave enough examples to properly outline the "scope of precision" here.
Public Class Location
Private _Address1 As String
Private _Address2 As String
Private _City As String
Private _State As String
Private _ZIP As String
Public Function isValid() As Boolean
'Insert validation code here'
End Function
End Class
I know that you can make this using a whole gaggle of If
statements checking if something exists and if something else exists, and if something else does not exist, on and on, but I feel as if that would be a huge chunk of logic code.
Is there a more efficient/elegant way of making sure I have a valid Location before I send it out in the request?