It should be interface or class ?
Friends,
I have a major entity in my application. That entity is, u can say, heart of the what application does.
Actually, clients can open up a case with supplier and that case is my main entity.
Now that case can be of any type out of some 7 types. And all of them have some data common say around 40% data is common. and remaining varies from type to type.
Now, my problem is, this main entity class should have any interfact on the top to depict common methods ? I feel that, it should be an abstract class with these common methods being abstract methods. Well, we have abstract class also, but it is used to store only common variables, not methods. Moreover we have impl classes also.
What you guys say ? Is there any design principle, which makes this interface must ??
Thanks.
Make it both. Follow the lead of the java.util.List and java.util.AbstractList.
Similar Messages
-
Situation where you are interface & abstract class?
please let me know if any one knowns answer for the above question
But my doubt in which situation we r using interface
and abstarct classesWithout repeating the debates, you should use interfaces to define the contract for developers to use. This is usually done when nothing is known about the concrete implementation but the design is ready. This is also useful when you need to have multiple inheritance.
Abstract classes are useful when you want to force the implementation of some of the methods onto the developers, rather than everyone having their own implementations. This is preferred when there is some concrete idea of some of the methods in the class while the implementations of the remaining methods can vary with the specialization of the sub-classes.
You might want to read this:
http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html -
1>whats the basic difference between an interface and an abstract class?
when should one be using an interface or an abstract class?
2>whats the difference between method overriding and method overlaoding?
does both of them has any relation with the instance of te class implementing them?http://www.google.com/search?q=java+interface+%22abstract+class%22
http://www.google.com/search?q=java+method+overloading+overriding -
[svn] 4081: Remove @private from an interface and class
Revision: 4081
Author: [email protected]
Date: 2008-11-12 06:50:02 -0800 (Wed, 12 Nov 2008)
Log Message:
Remove @private from an interface and class
QE Notes: None
Doc Notes: None
Bugs:
Modified Paths:
flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/listClasses/ListBaseContentH older.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/messaging/messages/ISmallMessage.asSystem.arraycopy()
You're almost certainly better off with a List implementation, though. Whether you use LinkedList or ArrayList should depend on your usage specifics, but from the limited information provided it seems that LinkedList would be a better choice. -
For WebLogic 5.1, where should I put my class files for my JavaBeans?
With JBuilder4, I have built an application with JSP and a few Java Beans (Those JavaBeans are instantiated in those JSP files). There are no EJBs. The package name is called 'onlinetrade'. I have tested the application on JBuilder's web server, it works pretty well.
Now I am moving this application to WegLogic 5.1. I have encountered a problem with WebLogic 5.1
and do not know where I should place my JavaBean class files --
Originally, the JSP files for my application are in package path-- ..onlinetrade\jsp
and the class files for my beans are in the package path -- ..onlinetrade\jsp\bean\*.class
Now, with WebLogic 5.1,
1) I have put my JSP files in
C:\weblogic\myserver\public_html\onlinetrade\jsp
2) I have created subdirectory and put my bean class files in
C:\weblogic\myserver\classfiles\onlinetrade\jsp\bean
When I started weblogic and the first page - login.jsp page can be up and accessed. But when I login and forward to another JSP page called 'controller.jsp', where a bean is instantiated, I got the following error
Compilation of 'C:\weblogic\myserver\classfiles\jsp_servlet\_onlinetrade\_jsp\__controller.java' failed:
C:\weblogic\myserver\classfiles\jsp_servlet\_onlinetrade\_jsp\__controller.java:210: cannot access jsp_servlet._onlinetrade._jsp.registerBean
probably occurred due to an error in /onlinetrade/jsp/controller.jsp line 53:
registerBean registerBeanInstance = new registerBean();
I know the javac is working, and a java file is created upon the JSP page, but the problem is -- the bean class files cannot be found!!!
Where should I create the package path and put my bean class file so that my JSP pages can pick them up?
Any help is greatly appreciated!
Thanks.
--TimI have mine in WEB-INF/classes
-
In which directory should i keep java class files in oracle apps
hi
I have one problem, In which Top & directory should i keep java class files in oracle apps
krishnaHi
By itself its available in oracle\visappl\au\11.5.0\java\
thats were the location needs to be placed in the apps.zip.
Thanks
Riyas -
Use of events and interface in class
Dear All,
Could you please explain why we use events and interface in class.
Also please tell me the use of TRY and ENDTRY.
Regards,
AmarEvents may be a way of communication b/w classes. Imagine you want to call certain code from one class, you would need for that public method, but you don't want to expose it to external user. So you may use events for that. Also events are used to notify that certain state of class has changed (tiggering event). Then all handlers of this event executes and react accordingly.
Interfaces are a way of provide a service to class which implements it. Imagine that you have class office and hotel and gas station . They don't seems to have something in common. However, there can be some external energy provider which will be an interface. Each class which want to have a lease with this energy provided can implement it (the implementation can differ in some way), so he can provided energy to different classes. This way you will achieve polimorphism (meaning you call one interface method, but code behind it differs from class to class).
Interfaces are also means of multiple inheritance. One class can implement several service (interfaces). In contrary it can oly inherit from one class.
Try endtry are just new way of handling exceptions .
Try to search a litte bit you will find lots of info on the above.
Regards
Marcin -
About interface and class[Please read this]
I writing what I found out:
myinterface.java
interface myinterface
class A
A()
{System.out.println("A()
of interface");}
A.java
class A implements
myinterface
A(){System.out.println("A()
of A.java");}
public static void main
(String args[])
A a=new A();
//this calls A() of interface
//myinterface.java
//how come the output of
// this code is like thishow come this is possible?Well, it had to pick one or the other, since they
have the same symbol name. Why are you choosing to
make up goofy names that collide in the first place?
If you want to explicitly use one or the other, you
need to also choose a package name, and fully-qualify
the class name that you are trying to instantiate.For example:
package test;
interface MyInterface // renamed to follow standard naming convention
class A
A() { System.out.println("A() of interface"); }
class A implements MyInterface
A() {System.out.println("A() of A.java"); }
public static void main(String args[])
test.A a = new test.A(); // prints A() of A.java
MyInterface.A a1 = new MyInterface.A(); // prints the other one
} -
Why should we not declare Class with protected modifier ?
Why should we not declare Class with protected modifier ?
jwenting wrote:
georgemc wrote:
Why we not research our endless questions?how else could you reach 14000 posts in under 3 years, a true achievement :) Congratulations.Ah, that reminds me. It was a long time ago since I posted some stats:
Posts:
jverd 46427 2972 0,06
DrClap 36310 5222 0,14
jschell 32357 2583 0,08
CeciNEstPasUnProgrammeur 31500 1438 0,05
camickr 29870 4783 0,16
yawmark 28729 1803 0,06
kajbj 24180 1829 0,08
BalusC 22857 2875 0,13
warnerja 21886 2188 0,10
ejp 19929 3247 0,16
sabre150 17537 1913 0,11
paulcw 16005 1724 0,11
DrLaszloJamf 14857 1840 0,12
georgemc 14000 889 0,06
prometheuzz 13466 1180 0,09
cotton.m 13409 1308 0,10
ChuckBing 12667 1735 0,14
JosAH 11926 842 0,07
flounder 11607 1201 0,10
mlk 10795 886 0,08
Darryl.Burke 10564 1787 0,17
Encephalopathic 10203 1508 0,15
tjacobs01 9540 1658 0,17
BigDaddyLoveHandles 8980 763 0,08
dcminter 8081 533 0,07
tsith 8049 704 0,09
jwenting 7831 249 0,03
malcolmmc 7539 819 0,11
Michael_Dunn 7392 2088 0,28
PhHein 7360 1207 0,16
morgalr 7081 703 0,10
pbrockway2 6471 1208 0,19
BIJ001 6179 322 0,05
JoachimSauer 5824 604 0,10
abillconsl 5777 943 0,16
corlettk 5671 544 0,10
TuringPest 5651 444 0,08
masijade. 5396 434 0,08
YoGee 4695 530 0,11
gimbal2 3642 315 0,09
uncle_alice 3496 1009 0,29
bshannon 3427 614 0,18
tschodt 3236 280 0,09
sjasja 3193 459 0,14
SoulTech2012 3005 109 0,04
Peter__Lawrey 2847 254 0,09
Torgil 2175 358 0,16
Navy_Coder 2119 648 0,31
rukbat 1951 252 0,13
java_2006 1913 1123 0,59
baftos 1808 665 0,37
es5f2000 1718 192 0,11
AndrewThompson64 1716 973 0,57
YAT_Archivist 1713 230 0,13
Aknibbs 1693 86 0,05
drvijayy2k2 1574 266 0,17
StanislavL 1396 1117 0,80
stefan.schulz 1159 208 0,18
JayDS 1100 410 0,37
dannyyates 1094 211 0,19
Joerg22 1046 48 0,05
uj_ 1033 49 0,05 -
Interface or Class based on the Factory
Hi,
I want to write a Factory pattern to decide whether the passed parameter is an interface or class ?
If an interface is passed then validate whether it is an interface using reflection and do the respective operation similarly for the class as well.
Please provide your opinion on this.
Thanks.Thanks.
In the main class I am calling the below :-
mockInterface("com.test.InterfaceTest");
protected <T> T mockInterface(String className){
<T> T interfaceObject = null;
try {
Class clazz = Class.forName(className);
if (clazz.isInterface()) {
interfaceObject = EasyMock.createMock(className.getClass());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return interfaceObject;
Here when I use EasyMock.createMock(className.getClass()) I am getting the below error :-
"Type mismatch Error saying cannot convert capture#2 of ? extends String to T"
Here createMock takes class as a parameter as shown below:-
public static <T> T createMock(Class<T> toMock)
/* 46 */ return createControl().createMock(toMock);
What I am doing wrong here? Please clarify. -
Hi Experts,
I want to use Interface of Class object. But I'dont know how I use it (declaration,call,create etc.)
There are a lot of exam about using local interface. But I need from Global object.
Class : CL_TPDA_DIFF_STRUC
Interface: IF_TPDA_DIFF_SERVICE
Best regards.Firstly ; Your advice book tells the "General OO".
But I need "Only ABAP OO". The basic logic is the same. But syntax are different.
If there is a book about ABAP OO and syntax You can advice to me.
Secondly;
My code is below.
I created my interface success . But It give error at runtime. Error mesaage : 'Error during interprocess communication; Debugger will be closed . Message Number TPDA151'
DATA l_ref_diff TYPE REF TO CL_TPDA_DIFF_STRUC.
data : xyz TYPE REF TO IF_TPDA_DIFF_SERVICE.
data : p_var1 type TPDA_VAR_NAME,
p_var2 type TPDA_VAR_NAME,
lv_x type TPDA_DIFF_ATTR.
data : l_it_value_diff TYPE TPDA_DIFF_VALUE_DIFF_IT,
l_it_main_diff TYPE tpda_diff_main_diffs_it.
p_var1 = 'CLIENTDATA1'.
p_var2 = 'CLIENTDATA2'.
lv_x-maxhits = 100.
CREATE OBJECT l_ref_diff.
xyz ?= l_ref_diff.
xyz->init( ).
xyz->DIFF( EXPORTING p_var1 = p_var1
p_var2 = p_var2
p_diff_attr = lv_x
CHANGING p_it_value_diff_it = l_it_value_diff
p_it_main_diff_it = l_it_main_diff ).
Best Regards. -
Deleting interfaces from class
hi to all
I am trying to delete interfaces from class . But it showing that "You cannot perform this action in modification/enhancement mode". where is the problem.
thank youHi,
This error comes up when the object you are trying to edit has original system as something else. This is a protection given by the modification assistant, so that the changes to the objects are recorded. If you know what you are doing(modifying objects in non-original system), go to edit menu and select modifications and select "switch off modification assistant".
Regards,
Arun Prakash -
Where I should put the bean class?
Hello,
I am learning JSP. I want to know where I should put the bean class? Which directory should I put the bean class?
note that I am using Tomcat 4.1
johnwen
24-12-2005I can't tell if you've got everything you need or not, but what you've shown looks right so far. Let me run down the necessities:
In your JSP file:
<%@ page import="aos.*" %>
<%-- imports all of the classes in the "aos" package --%>
In your Java file:
package aos; // tells Java this is a package (you probably have this)
Then, of course, you put the class file into the directories that you mentioned, ie, $CATALINA_HOME/ROOT/WEB-INF/classes/aos (forgive me if I use Unix-styled slashes; old habit, and shouldn't make any difference.)
You may need to restart Tomcat. You have to restart it when you add certain directories, although I'm not sure exactly which ones. But it never hurts to just restart it anyway. -
Ordered & unordered arraylist with interface & abstract class
you can remove this
Edited by: Taco_John on Mar 9, 2008 7:38 PMhttp://www.google.com/search?q=java+interface+%22abstract+class%22
http://www.google.com/search?q=java+method+overloading+overriding -
When should I use abstract classes and when should I use interfaces?
Can any body tell me in which scenario we use /we go for Interface and which scenario we go for abstract class, because as per my knowledge what ever thing we can do by using Interface that thing can also done through abstract class i mean to say that the
behavior of the two class.
And other thing i also want to know that which concept comes first into the programming abstract class or Interface.
S.K NayakThe main differences between an abstract class and an interface:
Abstract
An abstract class can contain actual working code (default functionality), and can have either virtual or abstract method.
An abstract class must be sub-classed and only the sub-classes can be instantiated. Abstract methods must be implemented in the sub-class. Virtual methods may be overridden in the sub-class (although virtual methods typically contain code, you still may
need/want to override them). A good use for an abstract class is if you want to implement the majority of the functionality that a class will need, but individual sub-classes may need slightly different additional functioality.
Interface
An interface only contains the method signatures (method name and parameters), there is no code and it is not a class.
An interface must be implemented by a class. An interface is not a class and so it cannot be sub-classed. It can only be implemented by a class. When a class implements an interface, it must have code in it for each method in the interface's definition.
I have a blog post about interfaces:
http://geek-goddess-bonnie.blogspot.com/2010/06/program-to-interface.html
(sorry, I have no blog posts specific to abstract classes)
~~Bonnie DeWitt [C# MVP]
http://geek-goddess-bonnie.blogspot.com
Maybe you are looking for
-
Satellite L-50 can't play audio from multiple sources
I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube vi
-
ICloud Control Panel for Windows will not install on Win 7 64-bit
I already installed iTunes 10.5 and I downloaded the iCloud Control Panel for Windows and when I tried installing it I got the following error message: I cannot find a a 64-bit of iCloud (if that is what I need). The 64-bit iTunes installed ok. What
-
Why will Logic 9 not open some of the samplerinstruments?
I just recently bought Logic 9 from the appstore. I've downloaded the app plus all the additional content. Unfortunately many of the samplerinstruments wont open when I click on them in Logic. It's not just a few instruments but many!!! So far I'm up
-
Why can't I see the rendering loading in FCP X 10.0.6?
I´ve downloaded the update, but when I put export files, the rendering loading doesn´t appear in the progrman, itñs just stay in the same way and when passes a few minutes the quick time player open with the movie. It's not that I don't like this ver
-
Would like to change the setting under properties to Printing: Not allowed