After completing a computer science degree I've landed a job as a software developer (woo!). Through university I was heavily web programming orientated sticking to Javascript and PHP (in the procedural sense). I'm now jump into object oriented programming as well in Visual Basic .NET.
I want to start on the right foot with best practices and what not so I have a simple scenario I want to know what the best way to do it is.
Let's say I have a class called 'Config.vb' which in the and on creation the 'Sub Load' reads keys from the registry. Keys are: 'Fname', 'Lname', 'address1', 'address2', 'city', 'shoesize'.
So I want to stored these keys and their values accessible to my Main.vb.
First approach would be to declare 6 variables to stored the values so
Dim firstName = regKey("firstname").value
Dim lastName = regKey("lastname").value...
Then to have accessor methods to retrieve these values
Property ReadOnly getFirstname As String
Get
Return firstName
End Get
End Property
But writing out 6 get methods seems to be too lengthy. I could well be wrong, this is why I'm asking; is this the best way to access these variables?
Alternatively,
I was thinking maybe bunching all the keys and values in just the one Dictionary variable so it would contain all the keys with their values, then just having the one function to that accepts the key string and returns the value like:
Private Function getkey(key) As String
Return dictionary.Item(key)
End Function
This is probably how I would approach it.
Any guidance or let me know your way doing it will all help me and other to learn better!
Thanks.