?
Solved

Regarding class construction

Posted on 2004-08-31
12
Medium Priority
?
230 Views
Last Modified: 2010-03-31
Hello All,

I am I am facing a situation where I am failing to put common interface to  2 classes.

Class A is developed by me and Class B is developed by my US collegue.

Both are working models and giving correct results.

Now my problem is, these two solutions need to have common  interface. But the method implementation  of these two classes are entirely different.

So how can we develop the interface??

0
Comment
Question by:sudhakar_koundinya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11949216
why aren't you using a common interface?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 1000 total points
ID: 11949230
interface Common
{
   public void doSomething();
}

class AWrapper implements Common
{
   private A Wrapped;

   public void doSomething()
   {
      Wrapped.doSomethingTheAWay();
   }
}

class BWrapper implements Common
{
   private B Wrapped;

   public void doSomething()
   {
      Wrapped.doSomethingTheBWay();
   }
}
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 11949235
Because of lack of co-ordination we  have initially, we have developed the classes individually. :-(
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 92

Expert Comment

by:objects
ID: 11949252
> Because of lack of co-ordination we  have initially, we have developed the classes individually. :-(

tsk tsk :)

0
 
LVL 6

Expert Comment

by:expertmb
ID: 11949257
>>But the method implementation  of these two classes are entirely different.
tht is the good thing of interface.  you implement the method in your way and your colleague implement in his own way. if you carefully look at collection package you willcome to know how good these interface concept is.
0
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 11949262
you coould also add a new common interface to each of the classes to map to the differing interface.

interface Common
{
   public void doSomething();
}

class A implements Common
{
   public void doSomething()
   {
      doSomethingTheAWay();
   }

   public void doSomethingTheAWay()
   {
      ...
   }
}

class B implements Common
{
   public void doSomething()
   {
      doSomethingTheBWay();
   }

   public void doSomethingTheBWay()
   {
      ...
   }
}
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 11949294
sudhakar_koundinya, you ask a lot questions but the titles are unusable for retrieval.
Can you please title such that one knows what the essence of the question is from the outside?
I guess you want to search for older solutions too ....
Just look around.

;JOOP!
0
 
LVL 6

Expert Comment

by:expertmb
ID: 11949395
using common interface is better option, as suggested by objects.
0
 
LVL 3

Expert Comment

by:RuadRauFlessa
ID: 11949397
If you can perhaps give us a description of the methods that you would like to use in the interface? I take it that perhaps they take diffirent paramaters and such.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11950335
>>So how can we develop the interface??

Please post classes with empty methods in both cases
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 11950743
OK that model solved my problems :)
0
 
LVL 92

Expert Comment

by:objects
ID: 11950749
excellent :)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question