Hi!
I have a class Bank and a Class BankAccount. A Bank can contains multiple
BankAccounts (logical, isn't it?). The central Bank object contains a
datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the datatable
in Bank, but I don't want to expose the datatable as a public property.
Since C# does not support friend classes, what is the best solutuion for
this problem?
--
cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk 8 1257
"codymanix" <do*********************@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi!
I have a class Bank and a Class BankAccount. A Bank can contains multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the datatable in Bank, but I don't want to expose the datatable as a public property.
Since C# does not support friend classes, what is the best solutuion for this problem?
Personally, instead of having Bank hold all data for accounts, I'd break the
data down and store it in each BankAccount class. However, to answer your
question as posed I'd just pass the data reference into the account at
construction. Is it one row per account? If so then just pass the
appropriate row into the constructor. If its multiple rows pass in a
DataView.
-- cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
"codymanix" <do*********************@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi!
I have a class Bank and a Class BankAccount. A Bank can contains multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the datatable in Bank, but I don't want to expose the datatable as a public property.
Since C# does not support friend classes, what is the best solutuion for this problem?
Yeah.
They are just called "internal" isntead of friend. Ok, not exactly the same,
but VERY close.
--
Regards
Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
---
Still waiting for ObjectSpaces? Try the EntityBroker today - more versatile,
more powerfull.
And something in use NOW. for the projects you have to deliver - NOW.
> > I have a class Bank and a Class BankAccount. A Bank can contains
multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the
datatable in Bank, but I don't want to expose the datatable as a public property.
Since C# does not support friend classes, what is the best solutuion for this problem? Yeah.
They are just called "internal" isntead of friend. Ok, not exactly the
same, but VERY close.
When my application is only one Assembly (which in it is in most cases),
then declaring something internal is the same as making it public.
--
cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
> > I have a class Bank and a Class BankAccount. A Bank can contains
multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the
datatable in Bank, but I don't want to expose the datatable as a public property.
Since C# does not support friend classes, what is the best solutuion for this problem?
Personally, instead of having Bank hold all data for accounts, I'd break
the data down and store it in each BankAccount class. However, to answer your question as posed I'd just pass the data reference into the account at construction. Is it one row per account? If so then just pass the appropriate row into the constructor. If its multiple rows pass in a DataView.
This seems the best Idea to me. But the constructor of the BankAccount is
still public.
Ideally it would only be visible to the Bank itself. Do you think putting
the BankAccount
class into the Bank as a local class would solve that problem?
--
cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
"Thomas Tomiczek [MVP]" <t.********@thona-consulting.com> wrote in message
news:OO**************@tk2msftngp13.phx.gbl... "codymanix" <do*********************@gmx.de> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Hi!
I have a class Bank and a Class BankAccount. A Bank can contains
multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the
datatable in Bank, but I don't want to expose the datatable as a public property.
Since C# does not support friend classes, what is the best solutuion for this problem? Yeah.
They are just called "internal" isntead of friend. Ok, not exactly the
same, but VERY close.
Internal restricts access to the classes in an assembly. An assembly usually
contains many classes. Friend, at least as defined in C++, restricts access
to a single class, a single member of that class, or a single non
member.
/Magnus Lidbom
"codymanix" <do*********************@gmx.de> wrote in message
news:OE**************@TK2MSFTNGP09.phx.gbl... I have a class Bank and a Class BankAccount. A Bank can contains multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all bankaccounts.
This means, the class BankAccount must have access rights to the datatable in Bank, but I don't want to expose the datatable as a public
property. Since C# does not support friend classes, what is the best solutuion
for this problem?
Personally, instead of having Bank hold all data for accounts, I'd break the data down and store it in each BankAccount class. However, to answer
your question as posed I'd just pass the data reference into the account at construction. Is it one row per account? If so then just pass the appropriate row into the constructor. If its multiple rows pass in a DataView.
This seems the best Idea to me. But the constructor of the BankAccount is still public. Ideally it would only be visible to the Bank itself. Do you think putting the BankAccount class into the Bank as a local class would solve that problem?
A contained class would work. Its a bit harder to work with(The type name is
Namespace.Bank.BankAccount now) but it should be sufficent. Just use a
private constructor(that is, unless my head is fooling with me today). -- cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
> > > > I have a class Bank and a Class BankAccount. A Bank can contains multiple > BankAccounts (logical, isn't it?). The central Bank object contains
a > datatable which holds the data of all bankaccounts. > > This means, the class BankAccount must have access rights to the datatable > in Bank, but I don't want to expose the datatable as a public property. > > Since C# does not support friend classes, what is the best solutuion for > this problem? >
Personally, instead of having Bank hold all data for accounts, I'd
break the data down and store it in each BankAccount class. However, to answer your question as posed I'd just pass the data reference into the account at construction. Is it one row per account? If so then just pass the appropriate row into the constructor. If its multiple rows pass in a DataView.
This seems the best Idea to me. But the constructor of the BankAccount
is still public. Ideally it would only be visible to the Bank itself. Do you think
putting the BankAccount class into the Bank as a local class would solve that problem? A contained class would work. Its a bit harder to work with(The type name
is Namespace.Bank.BankAccount now) but it should be sufficent. Just use a private constructor(that is, unless my head is fooling with me today).
If the ctor would be private, nobody but the BankAccount itself can
instantiate a BankAccount.
--
cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
"cody" <do*********************@gmx.de> wrote in message
news:bv************@ID-176797.news.uni-berlin.de... > > I have a class Bank and a Class BankAccount. A Bank can contains multiple > > BankAccounts (logical, isn't it?). The central Bank object
contains a > > datatable which holds the data of all bankaccounts. > > > > This means, the class BankAccount must have access rights to the datatable > > in Bank, but I don't want to expose the datatable as a public property. > > > > Since C# does not support friend classes, what is the best
solutuion for > > this problem? > > > > Personally, instead of having Bank hold all data for accounts, I'd break the > data down and store it in each BankAccount class. However, to answer
your > question as posed I'd just pass the data reference into the account
at > construction. Is it one row per account? If so then just pass the > appropriate row into the constructor. If its multiple rows pass in a > DataView.
This seems the best Idea to me. But the constructor of the BankAccount
is still public. Ideally it would only be visible to the Bank itself. Do you think putting the BankAccount class into the Bank as a local class would solve that problem? A contained class would work. Its a bit harder to work with(The type
name is Namespace.Bank.BankAccount now) but it should be sufficent. Just use a private constructor(that is, unless my head is fooling with me today).
If the ctor would be private, nobody but the BankAccount itself can instantiate a BankAccount.
Ya, I had scoping rules turned upside down, thats what happens when you try
to respond to stuff too early, ;).
In your case, you are simply going to have to be responsible with internal. -- cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Don Vaillancourt |
last post by:
Hello all,
Over the years as I design more database schemas the more I come up with
patterns in database design. The more patterns I recognize the more I
want to try to design some kind of...
|
by: sk |
last post by:
I have an applicaton in which I collect data for different parameters
for a set of devices. The data are entered into a single table, each
set of name, value pairs time-stamped and associated with...
|
by: Test User |
last post by:
Hi all, (please excuse the crosspost as I'm trying to reach as many people
as possible)
I am somewhat familiar with Access 2000, but my latest project has me
stumped. So, I defer to you...
|
by: rodchar |
last post by:
Hey all,
I'm trying to understand Master/Detail concepts in VB.NET. If I do a data
adapter fill for both customer and orders from Northwind where should that
dataset live?
What client is...
|
by: tshad |
last post by:
Many (if not most) have said that code-behind is best if working in teams -
which does seem logical.
How do you deal with the flow of the work?
I have someone who is good at designing, but...
|
by: roN |
last post by:
Hi,
I'm creating a Website with divs and i do have some troubles, to make it
looking the same way in Firefox and IE (tested with IE7). I checked it with
the e3c validator and it says: "
This...
|
by: JoeC |
last post by:
I have a question about designing objects and programming. What is the
best way to design objects? Create objects debug them and later if you
need some new features just use inhereitance. Often...
|
by: |
last post by:
I have a question about spawning and displaying subordinate list controls
within a list control. I'm also interested in feedback about the design of
my search application. Lots of code is at the...
|
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...
|
by: indrawati.yahya |
last post by:
In a recent job interview, the interviewer asked me how I'd design
classes for the following problem: let's consider a hypothetical
firewall, which filters network packets by either IP address,...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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)...
|
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...
|
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
|
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: 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...
| |