> > I'm afraid I'm somewhat lost at this point as to what you're trying to
> > do...
[quoted text clipped - 42 lines]
>
> presenter.PrepAndShowView
So both the loader and the comparer have the same members in both
cases?
Sounds like you need a single interface, and then just two properties
on the Presenter: "Comparer" and "Loader". Your code above then
becomes:
// Excel clicked
presenter.Loader = new cExcel() ;
presenter.Comparer = new cOracle() ;
presenter.PrepAndShowView();
// SQL Server clicked
presenter.Loader = new cSqlServer() ;
presenter.Comparer = new cOracle() ;
presenter.PrepAndShowView();
> First advantage of this solution: As loader and comparer are
> instantiated outside the two click events they are valid throughout
> the module.
Without understanding a lot more about the solution, it's hard to know
whether that's necessarily valid. I don't know about the lifetime of
the various instances, for example.
> Second advantage: Simplification of the code as the button clicks
> routines.
The above has simplified it quite a lot, I reckon :)
<snip>
> How need the loader and the comparer class have to look like? Please
> keep in mind, that cSQLServer, cOracle and cExcel already have all the
> same layout.
In my solution outlined above, you don't need extra classes - just an
extra interface, along the lines of:
interface ILoaderComparer
{
Header[] GetHeaderVals();
string Title { get; }
string[] Formats { get; }
}
(I'm completely guessing at the return values here, by the way.)
Make cExcel, cOracle and cSqlServer all implement the interface, and
it sounds like you'll be away.
Jon
stocki - 28 Mar 2008 11:50 GMT
Hi Jon,
I totally agree that your solution is even better!!!
Just allow me one last question please and this stupid german chap is
gone ;-)
presenter.Loader = new cExcel() ;
presenter.Loader = new cSqlServer() ;
The last piece which is missing is the definition of "Loader" in the
presenter. Here I am completly lost. Would you mind to shed some
light on that please?
I would like to thank you to share your knowledge with me! I have
really learned a lot in the last couple of days!
Cheers
Andreas
Jon Skeet [C# MVP] - 28 Mar 2008 11:54 GMT
> I totally agree that your solution is even better!!!
>
[quoted text clipped - 7 lines]
> presenter. Here I am completly lost. Would you mind to shed some
> light on that please?
It would be a settable property of type IComparerLoader (or whatever
you call the interface). The interface would need to encapsulate
everything that the presenter needs in order to get data from the
loader.
> I would like to thank you to share your knowledge with me! I have
> really learned a lot in the last couple of days!
My pleasure.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
stocki - 28 Mar 2008 12:15 GMT
Hi Jon,
this breaks the wall! Now I have somthing to do on the weekend. Keep
fingers crossed, that the weather is not too good!
Thank you for all your help and have a nice one!
Cheers
Andreas