C#: Should an ILog interface be or have an IEnumerable<Message>? -


We say this is the interface:

  public interface ILog {void Add (message message ); }  

Surely there should be a way to access those additional messages too. But what do you think is more natural and right? Does that apply to the ILlog IEnumerable property? Or maybe both? Or will both be a weird and strange bit? Or should it be an IEnumerator instead of IEnumerable? (Or is it completely wrong? The difference between them is not quite understood ...)

  Public Interface Yell: IEnumerable & lt; Message & gt; {Add zero (message message); } Public Interface ILog {IEnumerable & lt; Message & gt; Message {receive; } Add zero (message message); } Public Interface ILog: IEnumerable & lt; Message & gt; {IEnumerable & lt; Message & gt; Message {receive; } Add zero (message message); }  

This is definitely a bit subjective, but I want to hear the opinions of others. I do not really know, nor do I want to ask someone else: p

I suggest I do not have a calculator with iLog - there is no need to compute the logging code through all the messages.

The key is that one class can apply multiple interfaces - so that you (and should ) focus on each particular interface on a particular use.

Therefore, I have a second interface (e.g., ILogStore ) that implements a calculator of messages:

  Public Interface ILogStore {IEnumerable & Lt; LogMessage & gt; GetMessages (); }  

I can make this a member function to allow future future surcharges. Say, you want to get all the log messages from a particular subsystem:

  Public Interface ILogStore {IEnumerable & lt; LogMessage & gt; GetMessages (); IEnumerable & LT; LogMessage & gt; GetMessagesBySubsystem (String Subsystem); }  

and so on.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -