Hello again.
Apparently, I should get out more. I've pretty much been coding under a
rock for the last decade with pretty much no interaction with other
programmers at all. So, I'm pretty confident that some of the
programming practices that I've developed over time are a bit different
from others.
So anyway, lately I've been trying to explain some of my code to other
people and I've been drawing some confused looks.
var SelectedCustomer = OurData.Customer(SelectedCustomerID);
// At least I usually don't have to explain type-inferencing, I mean
"SelectedCustomer" is a "Customer", right?
string CustomerTradingName = SelectedCustomer.TradingName;
// Everybody gets this. I'm just reading a property off an object.
float ExchangeRate = SelectedCustomer.Country.Currency.ExchangeRate;
// Some people find this confusing.
Which brings me to the title of this post.
I could have written the last line as
Country CustomerCountry = SelectedCustomer.Country;
Currency CustomerCurrency = CustomerCurrency.ExchangeRate;
float ExchangeRate = CustomerCurrency.ExchangeRate;
Most people get that, although I have been asked why couldn't I write
CountryID = SelectedCustomer.CountryID;
CustomerCountry = OurData.Country(CountryID)
So... (ignoring the fact that I could probably have conflated the
concepts of "Country" and "Currency" with no real loss) ...
Run-on dereferencing - "SelectedCustomer.Country.Currency.ExchangeRate"
Is it normal? From what I've seen of other people's code, it's not all
that common. Users seem to want to spell out every step. But then,
I've spent a lot of time looking at Visual Basic and C# code and not
much of anything else.
When I'm coding in C++, I tend to spell things out more, but I put that
down to my lack of knowledge & experience.
Adelle.
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders