Peter, I completely agree - upon reading my last post it lacked a critical component to actually bring some value to the conversation which you mentioned. The USING keyword is key, perhaps as Robert mentioned it may not be in the best of lights given the context of the example but that is indeed how it should be used in the .NET framework.
Perhaps the documentation for Lucene.NET can include examples that demonstrate the use of some of the expensive classes implemented as Singletons - perhaps even code that up for the client as part of the library itself (or in code examples). Clumsy coders would then not be able to "mess up" the performance of Lucene.NET as much as they could given their broad control over some of these objects and their lifetime. Karell Ste-Marie C.I.O. - BrainBank Inc -----Original Message----- From: Peter Mateja [mailto:[email protected]] Sent: Tuesday, January 04, 2011 12:15 PM To: [email protected] Subject: Re: Proposal Stage: Net Idiomatic Api Version Robert... good points all. I especially agree that basing initial idiomatic work on 3.0+ makes sense (indeed, I believe this is what Lucere.Net had agreed to do.) Use of IDisposable can certainly lead to worst practices concerning IndexReader / IndexWriter objects. However, the IDisposable pattern (if implemented correctly... see http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx, http://www.codeproject.com/KB/dotnet/idisposable.aspx and Framework Design Patterns book mentioned earlier), really is the best way (in .Net) to ensure proper handling of both unmanaged resources, and stateful managed resources. I think a good combination of documentation and examples could do much to discourage worst practices. In some cases, the sample 'using' code you refer to might be appropriate... though in most the lifetime of an IndexWriter object might be controlled at a higher context (AppDomain, etc.) Let's ensure that Lucene.Net users know the how and why for each approach. Peter Mateja [email protected]
