473,563 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1526
"Hans De Schrijver" <ha**@punctualg raphics.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 "appropriat e" 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
johnwsaundersii i at hotmail

--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #2

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

Similar topics

0
2701
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 to obtain SHIP_wrap.cpp and SHIP.py; the latter contains the line "import _SHIP". I compile SHIP_wrap.cpp and a bunch of files into a DLL which I...
9
4629
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
1592
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: Thurs,Jun 2 2005 6:27 pm Subject: How to define common interface between C and Java modules. Reply | Reply to Author | Forward | Print | Individual...
4
2090
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 write a general purpose function to operate on all objects which implement that interface is through the following style of declaration (in the...
6
9192
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 file can be referanced in other *.cpp files, however in C# if I have say #define SPEED it only refers to the class(es) in that *.cs file. Is there...
18
3765
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
1613
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
2267
by: Zytan | last post by:
Aren't all classes interfaces? What constitutes an interface (and with it, the "I" prefix distinction)? Zytan
5
12810
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
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.