Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > OO is not that great[2]: repeatedly passing the same member reference

Thread Tools

OO is not that great[2]: repeatedly passing the same member reference

Posts: n/a

I have several classes TellerA, TellerB, TellerC and BankAccount.
TellerA and TellerB and TellerC are working like in a chain. TellerA
does something to the bankaccount object and pass it to TellerB. TellerB
does something to the same bankaccount object and pass it to TellerC.
There is only one object of BankAccount class, which everybody works on
it. So TellerA, TellerB and TellerC all have a member reference to a
bankaccount and passing the object bankaccount is very deliberate and

public class TellerA
BankAccount myAccount = new BankAccount("1 million");

..// did something to myAccount

TellerB b = new TellerB(myAccount, parameter A, parameter B); //I feel
the parameter myAccount is so redundant


public class TellerB
private BankAccount ac = null;

public TellerB(BankAccount ac, parameter a, parameter b)
{ = ac;
...// do something to the bank account -- same account object
...//then pass it to TellerC who keeps working on it

As you see, both TellerA and TellerB are working with the same account
object. But the object has to be passed deliberately. In procedural
language, you can leave the object in the global place and let everybody
access it, modify it, like a chain in a factory.
Reply With Quote opalinski from opalpaweb
Posts: n/a

If you want to, you can have global data by using public static fields.

Opalinski Removed)

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
OO is not that great[2]: repeatedly passing the same object Shawn Java 5 09-25-2006 07:54 AM
TBird repeatedly dl'ing same messages Dan Firefox 18 09-15-2006 06:05 AM
Return focus to same pop-up window repeatedly Richard Shewmaker Javascript 13 03-03-2006 03:43 PM
Passing the value by reference is same as pointer by reference sam pal C++ 3 07-16-2003 09:14 PM