473,383 Members | 1,877 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,383 software developers and data experts.

design quandry ..


I've come full circle on a design here. Consider the case where I've
got two modes of operation, uni-cast or multi-cast.

In either mode you can transmit(send) and/or receive.

The distinction between the two modes amounts to a set of vendor APIs.
When transmitting, to estabilish a connection in uni-cast mode I'll do:

openConnection(/*stuff*/);
establishUConnection(/*stuff*/);
tearDownUConnection(/*stuff*/); <- destructor activity

In multi-cast mode I'll do:
openConnection(/*stuff*/);
establishMConnection(/*stuff*/);
tearDownMConnection(/*stuff*/); <- destructor activity

When receiving the mode of operation is irrelevant. ie. You'll perform
the same operation in _either_ mode. i.e
openConnection(/*stuff*/);
configureRxChannel(/*stuff*/); configure the receive channel
tearDownRxChannel( /* stuff */)

You're allowed to call openConnection once, independent of the mode.
For instance, if I desire to send and receive in multi-cast mode. I
call openConnection once. So now:
openConnection(/*stuff*/);
establishMConnection(/*stuff*/);
configureRxChannel(/*stuff*/); configure the receive channel
So the best I could come with is as follows:

struct Connections {}; // vendor stuff
struct Channels {}; // vendor stuff

class receiver()
{
public:
receiver(vector<Connections>& coVec,
vector<Channels>& chVec))
{
if (openConnection(coVec)) {}
if (configureRxChannel(chVec)) {}
}
~receiver() throw() { if ( tearDownRxChannel(/*stuff*/)) }
// miscellaneous functions for status info.
};

class uniC
{
receiver& ref
public:
//constructor for the case where you desire to send and receive
uniC (receiver& r)
: ref(r)
{}

// constructor for the case where i desire to send only.
uniC (vector<Connections>& coVec)
{ if (openConnection(coVec)) {} }

~uniC () throw() { if ( tearDownUConnection(/*stuff*/)){} }
bool establishUConnection(/*stuff*/) {}
};

class multiC
{
receiver ref;
public:
// for the case where you desire to send and receive
multiC(receiver& r)
: ref(r)
{}

// for the case where i desire to send only.
multiC(vector<Connections>& coVec)
{ if (openConnection(coVec)) {} }

~multiC() throw() { if ( tearDownMConnection(/*stuff*/)){} }
bool establishMConnection(/*stuff*/) {}
};

Just uncertain if I'm on the right track here. So I'd appreaciate some
feedback.

Thanks in advance.

Oct 26 '05 #1
2 1346
On 26 Oct 2005 09:00:42 -0700, fo*******@hotmail.com wrote:

I've come full circle on a design here. Consider the case where I've
got two modes of operation, uni-cast or multi-cast.

In either mode you can transmit(send) and/or receive.

The distinction between the two modes amounts to a set of vendor APIs.
When transmitting, to estabilish a connection in uni-cast mode I'll do:
....
Just uncertain if I'm on the right track here. So I'd appreaciate some
feedback.

Thanks in advance.


Your design entangles the receiver and transmitter in a way that the user
doesn't care about. In other words, constructing a receiver and then passing a
reference to it to the constructor of a transmitter is nonsensical, because:

- The transmitter object shouldn't care what receiver you're using
- A transmitter and receiver must be created together. What does it mean when
you construct a receiver but not a corresponding transmitter?

I would turn the design on its head and encapsulate the vendor-specific side
of things, and then offer up non vendor-specific interfaces to the
application, e.g.

class Receiver /* interface */
{
public:
virtual void Receive() = 0;
};

class Transmitter /* interface */
{
public:
virtual void Transmit() = 0;
};

class Connection
{
public:
virtual Receiver& getReceiver();
virtual Transmitter& getTransmitter();
protected:
Connection(); // Class must be inherited from
};

class MulticastConnection: public Connection
{
public:
/* ... */
};

class UnicastConnection: public Connection
{
public:
/* ... */
};
The user's code would look something like:

Connection* pConnection = new MulticastConnection();
Receiver& receiver = pConnection->getReceiver();
Transmitter& transmitter = pConnection->getTransmitter();

or

Connection* pConnection = new UnicastConnection();
Receiver& receiver = pConnection->getReceiver();
Transmitter& transmitter = pConnection->getTransmitter();

You can use lazy evaluation to allow the user to get a transmitter from a
connection, but not a receiver, or vice versa.

-dr
Oct 27 '05 #2

|| You can use lazy evaluation to allow the user to get a transmitter
from a
|| connection, but not a receiver, or vice versa.

Make sense.
Thanks

Oct 27 '05 #3

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

Similar topics

8
by: Jack Carter | last post by:
I have been delegated to produce a tool that has python embedded in it. The desire is to have a command line interface that inherits all the python scripting functionality so people can use the...
0
by: ma740988 | last post by:
I've provided a stripped down version - as best I could - to get us by. That said, I'm in a quandry with respect to a design here. Consider: // stream.h #ifndef STREAM_H #define STREAM_H #...
3
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....
4
by: Pete | last post by:
I'd like to add a basic chat application to my web site to get the members talking more, I've decided to limit the number of users to 30. There will be a seperate popup with a frame & three pages...
2
by: Hexman | last post by:
Off on another journey through vb.net. What I want to do now is have a tab-control with 1 to 8 tab-pages for categories. I've read where there is not a hide method so I guess I'll have to...
4
by: news.microsoft.com | last post by:
Hello, I've got a design problem that I can't figure out. I need to override a static method which happens to be referenced by methods inside nested classes. In the sample below, in the call...
3
by: PeterKellner | last post by:
I have a project where a html designer gives me a pile of html to wire up. I do that and it works fine of course. Then, the html designer makes a bunch of changes, give me back the revised aspx...
0
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...
19
by: neelsmail | last post by:
Hi, I have been working on C++ for some time now, and I think I have a flair for design (which just might be only my imagination over- stretched.. :) ). So, I tried to find a design...
1
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: 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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.