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
|
|