473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to define an interface for use in multiple class files

I'm new to C# development, so here's a basic question.

I'm developing a code library (no UI) where several of the classes will
implement an IPersistable interface.
Each class lives in its own class file (within the same project) but all
classes are defined within the same namespace DaySpanLib.
Now here's my question: given that the interface I need to develop will be
implemented by several classes, each of which live in their own .cs file, in
which file do I create the interface? Do I create a separate General.cs file
that contains general stuff like this interface?
So far I created a "public interface IPersistable" in a separate General.cs
file (also in the namespace DaySpanLib), and it compiles fine.
However, I'm wondering what best practices are with respect to things like
general interfaces and enumerations... where do you put them?

Any input is greatly appreciated.

-- Hans De Schrijver
Nov 18 '05 #1
1 1517
"Hans De Schrijver" <ha**@punctualgraphics.com> wrote in message
news:Ya************@fe2.texas.rr.com...
I'm new to C# development, so here's a basic question.

I'm developing a code library (no UI) where several of the classes will
implement an IPersistable interface.
Each class lives in its own class file (within the same project) but all
classes are defined within the same namespace DaySpanLib.
Now here's my question: given that the interface I need to develop will be
implemented by several classes, each of which live in their own .cs file, in which file do I create the interface? Do I create a separate General.cs file that contains general stuff like this interface?
So far I created a "public interface IPersistable" in a separate General.cs file (also in the namespace DaySpanLib), and it compiles fine.
However, I'm wondering what best practices are with respect to things like
general interfaces and enumerations... where do you put them?


You could even put the interface in its own file: IPersistable.cs.

But you might get tired of little tiny files for things like interfaces and
enumerations. In which case, you could put all such things into a single
Types.cs file. But that file might get too large, so you might start using
multiple files, separating the types by some criterion.

In other words, it doesn't matter. Do whatever seems most appropriate at the
time and simply realize that "appropriate" may change as the application
matures.

One other suggestion, though: is the concept of being Persistable unique to
the DaySpanLib? If not, then you might want to create a separate solution
for common types and define IPersistable there.
--
John Saunders
johnwsaundersiii at hotmail

--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
4
by: Maneesh | last post by:
Maneesh Jun 2, 6:27 pm show options Newsgroups: comp.lang.java.programmer From: "Maneesh" <mmano...@gmail.com> - Find messages by this author Date: 2 Jun 2005 05:57:46 -0700 Local:...
4
by: christopher diggins | last post by:
A feature that I find signficantly missing in C# is the ability to write functions in interfaces that can call other functions of the interface. Given an interface ISomeInteface the only way we can...
6
by: David Young | last post by:
Hello all, I'm quite new to C# (< 6 months) but really love it and is my language of choice ..... but I have one question I've not been able to find out ..... In C++ a #define label in one...
18
by: Bradley | last post by:
I'm trying to determine if there's a general rule for when an Interface should used vs. an Abstract Class. Is there any design advantage to using one or the other? Brad
2
by: Kevin Frey | last post by:
Consider this simple example: interface IReader { bool Read( ); }; class MyReader : IReader { bool Read( ); // or should it be bool IReader.Read( ) ?
17
by: Zytan | last post by:
Aren't all classes interfaces? What constitutes an interface (and with it, the "I" prefix distinction)? Zytan
5
by: Damodhar | last post by:
When would you use an abstract class and when an interface? whats the abstract class.? please give me the sample .
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.