Exforsys

Online Training

what pattern or policy to use.

This is a discussion on what pattern or policy to use. within the Software Patterns forums, part of the Testing category; This is the problem, the class diagram is C Impl IC EC SImpl HImpl Where IC and EC are derived ...


Go Back   Exforsys > Testing > Software Patterns

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-02-2004, 06:20 PM
sanjiv
Guest
 
Posts: n/a
what pattern or policy to use.

This is the problem,

the class diagram is


C Impl

IC EC SImpl HImpl

Where IC and EC are derived from C(Abstract) and SImpl and HImple are
derived from Impl(Abstract). C keeps a pointer to Impl.

If I have to invoke a function of SImpl then I can declare a virtual
function in Impl and do it, straight forward.
Question is, if I have to write a function which only makes sense for
SImpl and not for HImpl and this function is to be called from IC.
Then how should I do it using patterns or policy.
Any suggestion....
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-14-2004, 04:47 AM
Ken Loh
Guest
 
Posts: n/a
Re: what pattern or policy to use.

Here's my 2 cents worth:

class C {
private Impl impl;
protected setImpl(Impl impl) {
this.impl = impl;
}
public someMethod() {
Object ref = impl.anImplMethod();
....
}
}

public class IC extends C {
C(Impl impl) {
super();
setImpl(impl);
}
public void someMethod(){
assert impl instanceof SImpl;
Object ref = ((SImpl) impl).aSImplMethod();
....
}
}

Cheers

sanjrd@yahoo.com (sanjiv) wrote in message news:<8ad413cf.0411021420.7a33d889@posting.google.com>...
> This is the problem,
>
> the class diagram is
>
>
> C Impl
>
> IC EC SImpl HImpl
>
> Where IC and EC are derived from C(Abstract) and SImpl and HImple are
> derived from Impl(Abstract). C keeps a pointer to Impl.
>
> If I have to invoke a function of SImpl then I can declare a virtual
> function in Impl and do it, straight forward.
> Question is, if I have to write a function which only makes sense for
> SImpl and not for HImpl and this function is to be called from IC.
> Then how should I do it using patterns or policy.
> Any suggestion....
> Thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

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 On



All times are GMT -4. The time now is 02:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.