Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

visual proxy

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone implemented Allen Holub's visual proxy concept (pattern)? I'm looking for a simple example other than the ones on his web site.
 
Sheriff
Posts: 15768
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't we write one? I was going to post a refactoring example related to another thread but I guess this thread will be fine. This will also be an example of refactoring.
To start: The following code is a possible Java implementation (in essence) of the sequence diagram discussed in the thread "IBM question - Sequence diagram" It needs a little refactoring because it is suffering from the "Feature Envy" code smell.
<pre>
class Person {
float totalAssets() {
float total = 0.0f;
for (Enumeration accounts = Account.getAccountsFor(this);
accounts.hasMoreElements();
/* EMPTY - no increment */)
{
total += (Account)(accounts.nextElement()).getBalance();
}
return total;
}
}
class Account {
static Enumeration getAccountsFor(Person person) {
Vector v = new Vector;
/* code to add person's accounts to v goes here
would probably be something like:

AccountDao dao = new AccountDao();
dao.getAccountsForPerson(person.primaryKey, v);

*/
return v.elements();
}
float getBalance() {
return _balance;
}
boolean isAssetAccount() {
return (_type == AccountType.ASSET);
}
AccountType _type;
float _balance;
}
/**
* Data Access Object proxy for Account class
*/
class AccountDao {
static void getAccountsForPerson(PrimaryKey pk, Vector v)
{
// access persistent data
// instantiate Accounts for Person and
// add them to the vector
}
}
</pre>
[This message has been edited by JUNILU LACAR (edited May 21, 2001).]
[This message has been edited by JUNILU LACAR (edited May 21, 2001).]
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic