Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

Best way to develop in parallel

Thread view: 
Brian - 29 Jun 2005 00:41 GMT
Hi -

I have MyPossiblyFlawedClass and MyOtherPossibilyFlawedClass.
Both have exactly the same method signatures, constructors,
etc.

They solve a number crunching problem using two different
algorithms and they're being used to discover flaws in the
other.  How can I easily switch between the classes? I'm
doing it now with an import mypath.classA/classB statement.

But this is getting a bit out of control.  I'm constantly
switching four import statements many times a day.

Thanks for any ideas.
Brian
Alan Krueger - 29 Jun 2005 01:14 GMT
> I have MyPossiblyFlawedClass and MyOtherPossibilyFlawedClass.
> Both have exactly the same method signatures, constructors,
[quoted text clipped - 7 lines]
> But this is getting a bit out of control.  I'm constantly
> switching four import statements many times a day.

Move their common methods into an interface and have each of them
implement it.  Import them both.  Have the test code refer to the
interface and construct one or the other based on some condition.

    interface A
    {
        void foo();
    }

    class B implements A
    {
        void foo() { System.out.println( "B.foo" ); }
    }

    class C implements A
    {
        void foo() { System.out.println( "C.foo" ); }
    }

    void testA( A a ) { a.foo(); }
    void testB() { test( new B() ); }
    void testC() { test( new C() ); }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.