473,320 Members | 1,993 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.

A question on interfaces

Hi everyone,

I am in the process of making a small application and in the process of
designing and implementing it, I have come accross a sort of general design
related question.

I'm using the fairly typical approach of dividing the application into three
layers - UI - Business Logic - Data Access.

At the moment I am trying to figure out the best wya to let the logic layer
interact with the DataAccess layer. At the moment I have all communications
between the two layers going through a single class called
PersistenceManager. I have two questions:

1. Is it wise to have a single point of communication between two layers. It
seems like it might make serve the purpose of keeping the design relatively
simple. But is there any reason why a single communication channel might be
a bad idea?

(The most important question)
2. Given that the PersistenceManager class acts as *the* interface to the
data access layer - is this the sort of class that should have an interface
made for it? Then as I understand it, I would have the clients of the
PersistenceManager classes actually *talk* in terms of the interface? For
example I wouldnt put:

PersistenceManager pm = new PersistenceManager()

I would put this instead:

IPersistenceManager pm = controller.getPersistenceManager();

I hope the question is relatively clear. I'm just wondering if most people
would create an interface for this sort of situation. Would it be good
practice to do so, or a waste of time?

Many thanks all

Simon
Nov 15 '05 #1
3 1408
Simon Harvey wrote:
IPersistenceManager pm = controller.getPersistenceManager();


Interfaces are best used for communication between objects whose type is
not known. Given that your data layer is by all means a known, I don't
think an interface is necessary. However, the singleton idea you
demonstrated above is probably a good idea.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2
Hi Simon
1. Is it wise to have a single point of communication between two layers. It seems like it might make serve the purpose of keeping the design relatively simple. But is there any reason why a single communication channel might be a bad idea?
No necesarilly.
(The most important question)
2. Given that the PersistenceManager class acts as *the* interface to the
data access layer - is this the sort of class that should have an interface made for it? Then as I understand it, I would have the clients of the
PersistenceManager classes actually *talk* in terms of the interface? For
example I wouldnt put:

PersistenceManager pm = new PersistenceManager()

I would put this instead:

IPersistenceManager pm = controller.getPersistenceManager();


As Frank said an interface here is not of much use, you could use a
singleton pattern or even better a class with static methods.

Merry X-mas,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 15 '05 #3
Thanks guys

Help greatly appreciated

Simon
Nov 15 '05 #4

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

Similar topics

1
by: baylor | last post by:
In C#, an interface cannot mark any method as static. i'm told the ILASM supports it but i've never tested that Two questions. First, why? OK, i've heard the reason about interfaces being...
30
by: Frank Rizzo | last post by:
We are having one of those religious debates at work: Interfaces vs Classes. My take is that Classes give you more flexibility. You can enforce a contract on the descendant classes by marking...
8
by: John | last post by:
What is the purpose / benefit of using an interface statement? It doesn't seem like anything more than a different way to make a class... (except you can't define any procedures in an interface...
9
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
18
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller...
22
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to...
18
by: Tony | last post by:
class Interface { public: virtual void DoItNow()=0; }; class A: public Interface { public: void DoItNow(); // satisfies interface explicitly
5
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I am actually a VB.Net guy, but I have worked somewhat with C++ and C#. I just want to ask about the relationship between Abstract Classes and Interfaces. My first question is if...
10
by: hyperboreean | last post by:
Hi, Probably it has been asked before, but I'll still ask. Why doesn't python provide interfaces trough its standard library? Or it was ever proposed to be included in the language? Zope's...
23
by: A.Gallus | last post by:
If I declare a function pure virtual: class A { virtual void myfunc() = 0; } and I derive a class from A: class B : public A
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.