Is programming against interfaces in Java the same concept as using header files in C/C++? -


the java code i'm working on @ moment has structure like

file controller.java:

interface controller {...} 

file controllerimpl.java:

class controllerimpl implements controller {...} 

but every interface there 1 implementation. isn't same using header files in c/c++ have code split files

controller.hpp controller.cpp 

from know, header files in c/c++ have been introduced compiler, not necessary anymore in java. header files should readability of code, having modern ide folding , outline view not necessity anymore.

so why people again introduce header files in java through door programming against interfaces?

no. in c++, files (headers) not same classes.

programming against interfaces in java can done in c++, too, programming against abstract base classes.

however, java term of "interface" quite restricted. basically, function declaration interface:

void call_me(int times);  

as are, of course, classes , other types.

in c++, group such things in headers, interface can consist of 1 header. however, might consist of multiple headers.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -