The constructors that create a new ProjectInfo and ResourceInfo have radically different parameter lists.
ProjectInfo lists each parameter as a separate, strongly typed parameter.
ResourceInfo just accepts a SafeDataReader and parses things out inside the constructor.
Why the difference?
Is it just:
Thanks!
PS. I just put a junior programmer on the task of cranking out basic <thing>Info and <thing>InfoList classes. She's bopping right thru them with a 10 minute or less intro to each sample class we're using as a base, and a 10 minute or less walk-thru when she gets the first of each type done. Productivity is sweet!
ajj3085:I believe the difference is just to show you can use either method, because its internal to the business layer, and thus doesn't matter as much.
Which way do you prefer, and why?
I'm leaning towards the constructor with specific parameters. If I have to parse out the fields anyway, might as well make it easier for other classes to create it from their own source data.
It is to show multiple approaches.
Also, it is due to reviewer feedback during the writing process. I originally went with one approach (which was to do more work in the constructor, and not have a private Fetch() method for instance), but then my region scheme was confusing (because the constructor, which was doing the "fetch" was in the factory region, not the data access region).
The result was a flurry of emails between myself and the reviewers. The code in the book, then, shows the "wordy" way of doing it - where each region has proper code for the region, and the constructor calls a private Fetch(). There's no doubt in my mind that this is the most clear and "proper" way of doing it (though it took some convincing to get me there ). However, I thought it worthwhile to show other approaches too - at least in the code.
But the real point has already been made - it doesn't matter a lot because this is all hidden within the business layer. As long as you pick an approach and are consistent with it I really don't think it matters a lot.
Personally, I've been sticking with the factory->constructor->Fetch() approach.
Copyright (c) Marimer LLC