473,503 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interface Delimma

We are in the process of design a new of classes which are essenially
E/R object for our db tables. Each would have the standard CRUD operations.
We plan to have a common interface that they all implement, basically:

interface MyInterface
{
Read(int id);
Update(int id);
Delete(int id);
}

The problem is.... How do we put "Create" into the interface, since
besides the key field, it would need as parameters, each field for the
object, which would be different for each class. Using "params object[]
args" was considered, but we'd rather have the compile-time type checking.

Any ideas?

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 17 '05 #1
2 1107
Possibly you can use something like AddField - see how it is done for
parameters in SqlCommand with SqlParametersCollection

HTH
Alex

"James Curran" <ja*********@mvps.org> wrote in message
news:Oq****************@TK2MSFTNGP14.phx.gbl...
We are in the process of design a new of classes which are essenially
E/R object for our db tables. Each would have the standard CRUD operations. We plan to have a common interface that they all implement, basically:

interface MyInterface
{
Read(int id);
Update(int id);
Delete(int id);
}

The problem is.... How do we put "Create" into the interface, since
besides the key field, it would need as parameters, each field for the
object, which would be different for each class. Using "params object[]
args" was considered, but we'd rather have the compile-time type checking.

Any ideas?

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

Nov 17 '05 #2
Hi James,
if you are trying to design in a layer of abstraction into your system,
you might need to use one more layer to get a generic interface like the one
you outlined below. This could possibly follow the Data Mapper Design
Pattern architecture

i.e.

interface IDBMapper
{
insert();
update();
delete();
}

class Person
{
public Person()
{
}

public int Id
{
//returns the id of the person record in the database
}
public string Name
{
//return the name of the person
}

public int Age
{
//return the age of the person
}
}
//object that lives inbetween the higher level object and the database

class PersonMapper : IDBMapper
{
private Person m_p;
public PersonMapper(Person p)
{
m_p = p;
}

public void Insert()
{
//insert into tblPerson new entry with m_p.Name, m_p.Age etc
}

public void Update()
{
//update tblPerson where id==m_p.Id, using
//m_p.Name, m_p.Age etc
}

public void Delete()
{
//delete from tblPerson where id == m_p.Id
}
}
In doing this you can now hold reference to IDBMapper without having to
worry what is the underlying concrete type and they all have the same
interface to the high level controller. You would have to have one data
mapper per object that maps to tables in your DB.

Not sure if this is the kind of thing you are looking at or not in your
design.

Mark


"James Curran" wrote:
We are in the process of design a new of classes which are essenially
E/R object for our db tables. Each would have the standard CRUD operations.
We plan to have a common interface that they all implement, basically:

interface MyInterface
{
Read(int id);
Update(int id);
Delete(int id);
}

The problem is.... How do we put "Create" into the interface, since
besides the key field, it would need as parameters, each field for the
object, which would be different for each class. Using "params object[]
args" was considered, but we'd rather have the compile-time type checking.

Any ideas?

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

Nov 17 '05 #3

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

Similar topics

4
8165
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
9
4617
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
2563
by: Doug | last post by:
I am working on an existing .NET (C Sharp) component that had a com interface that was used by a VB component. When it was originally written, it had the SSEAssemblyCom class below - minus the two...
3
4111
by: zlst | last post by:
Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability....
6
3004
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
20
4222
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the...
2
4977
by: Alex Sedow | last post by:
Why interface-event-declaration does not support multiple declarators like event-declaration? Grammar from C# spec: variable-declarators: variable-declarator variable-declarators ","...
0
2492
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
15
2770
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
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...
0
7462
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...
0
5578
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 projectplanning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.