由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - qeustion about separation of interface and implementation in java
相关主题
问个弱问题,C++为什么把interface和implementation分开?Interface segregation principle似乎没啥意义啊
这次Go丢人有点大呀现在学LLVM有没有前途
为什么我的visual C++ 找不到 "Stdafx.h" ?java 的interface是相当于ruby的module吗?
说某种语言是解释性语言的全是文科生 (转载)其实微软是个做语言的公司
Question about COMinterface是oo feature吗
有懂obj-c 的吗?问一个JAVA Interface Design的问题
static polymorphism一问请教matlab转C++
想写个简单的 JVM- 用C++还是Javaeffective C++里的memory pool 一问:
相关话题的讨论汇总
话题: java话题: c++话题: interface话题: separation
进入Programming版参与讨论
1 (共1页)
f*****d
发帖数: 2726
1
Sorry I can not type chinese right now.
I don't know Java, but have beening using C++ for a while. One thing I don't
understand is that why Java does not separate interface and implementation
for a class.
When I got some java code from my colleague, all the definition and
declarations are mixed together in one file. My colleague told me that
compilation was not an issue for java so separation is not necessary. Is
that true?
I learned that there are a lot of benefits other than compilation when d
X****r
发帖数: 3557
2
There is the separation but not at the source level.
For example, when you use third-party libraries, you get the
documentation, which is usually generated by JavaDoc from the
source code, and the binary .jar compiled from the source code.
These are all you need to use the library. The implementation
details are hidden.
Personally I think this is superior than the C/C++ model of dual
header/source. In C/C++, not only you get to modify both places
when making a change, a mismatch would be harder

【在 f*****d 的大作中提到】
: Sorry I can not type chinese right now.
: I don't know Java, but have beening using C++ for a while. One thing I don't
: understand is that why Java does not separate interface and implementation
: for a class.
: When I got some java code from my colleague, all the definition and
: declarations are mixed together in one file. My colleague told me that
: compilation was not an issue for java so separation is not necessary. Is
: that true?
: I learned that there are a lot of benefits other than compilation when d

f*****d
发帖数: 2726
3
Thank you. Now it makes sense to me.

【在 X****r 的大作中提到】
: There is the separation but not at the source level.
: For example, when you use third-party libraries, you get the
: documentation, which is usually generated by JavaDoc from the
: source code, and the binary .jar compiled from the source code.
: These are all you need to use the library. The implementation
: details are hidden.
: Personally I think this is superior than the C/C++ model of dual
: header/source. In C/C++, not only you get to modify both places
: when making a change, a mismatch would be harder

g*****g
发帖数: 34805
4
Not sure what you are talking about there.
Java has explicit interface and class type, while C++ only
has class.
If you are talking about the header file C++ has, that's not
necessary for Java. There's no macro for java, and all functions
are virtual by default, class files have a defined hierarchy. It
all makes compiler's job much simpler.

't
implementation
doing

【在 f*****d 的大作中提到】
: Sorry I can not type chinese right now.
: I don't know Java, but have beening using C++ for a while. One thing I don't
: understand is that why Java does not separate interface and implementation
: for a class.
: When I got some java code from my colleague, all the definition and
: declarations are mixed together in one file. My colleague told me that
: compilation was not an issue for java so separation is not necessary. Is
: that true?
: I learned that there are a lot of benefits other than compilation when d

l******e
发帖数: 12192
5
感觉你是要问declaration和definition。
C++这样做(其实是继承C的传统),主要是方便发布api,一般都要提供头文件和binar
y的库;而java, c#这些都有虚拟机,编译成bytecode后,类声明都是可见的。

't
implementation
doing

【在 f*****d 的大作中提到】
: Sorry I can not type chinese right now.
: I don't know Java, but have beening using C++ for a while. One thing I don't
: understand is that why Java does not separate interface and implementation
: for a class.
: When I got some java code from my colleague, all the definition and
: declarations are mixed together in one file. My colleague told me that
: compilation was not an issue for java so separation is not necessary. Is
: that true?
: I learned that there are a lot of benefits other than compilation when d

l******e
发帖数: 12192
6
如果要改implementation保持interface不变的话,c/c++多半只用该defintions。

【在 X****r 的大作中提到】
: There is the separation but not at the source level.
: For example, when you use third-party libraries, you get the
: documentation, which is usually generated by JavaDoc from the
: source code, and the binary .jar compiled from the source code.
: These are all you need to use the library. The implementation
: details are hidden.
: Personally I think this is superior than the C/C++ model of dual
: header/source. In C/C++, not only you get to modify both places
: when making a change, a mismatch would be harder

w***g
发帖数: 5958
7
如果C++像java那样写,所有的东西都inline到头文件里,会有什么坏处?
我老写C++懒得把一个东西分两处写,这么干已经很久了。这样的code被别人看到会不会
不利于找工作?

't
implementation
doing

【在 f*****d 的大作中提到】
: Sorry I can not type chinese right now.
: I don't know Java, but have beening using C++ for a while. One thing I don't
: understand is that why Java does not separate interface and implementation
: for a class.
: When I got some java code from my colleague, all the definition and
: declarations are mixed together in one file. My colleague told me that
: compilation was not an issue for java so separation is not necessary. Is
: that true?
: I learned that there are a lot of benefits other than compilation when d

g*****g
发帖数: 34805
8
You can declare interface and let class implements interface
if that's what you try to achieve.

【在 l******e 的大作中提到】
: 如果要改implementation保持interface不变的话,c/c++多半只用该defintions。
l******e
发帖数: 12192
9
如果是template很多,很正常

不会

【在 w***g 的大作中提到】
: 如果C++像java那样写,所有的东西都inline到头文件里,会有什么坏处?
: 我老写C++懒得把一个东西分两处写,这么干已经很久了。这样的code被别人看到会不会
: 不利于找工作?
:
: 't
: implementation
: doing

1 (共1页)
进入Programming版参与讨论
相关主题
effective C++里的memory pool 一问:Question about COM
Re: 110道C++面试题目,你会做多少? (转载)有懂obj-c 的吗?
问一个C++ template的问题static polymorphism一问
求助: 关于用VC做user interface想写个简单的 JVM- 用C++还是Java
问个弱问题,C++为什么把interface和implementation分开?Interface segregation principle似乎没啥意义啊
这次Go丢人有点大呀现在学LLVM有没有前途
为什么我的visual C++ 找不到 "Stdafx.h" ?java 的interface是相当于ruby的module吗?
说某种语言是解释性语言的全是文科生 (转载)其实微软是个做语言的公司
相关话题的讨论汇总
话题: java话题: c++话题: interface话题: separation