C++促进类定义和类实现的分离,但不是 JAVA
我有一个作业,我需要根据 GRASP 评估哪种方法更好。
我发现这个链接回答了我的部分疑问:为什么有标题C++ 中的文件和 .cpp 文件?
但是,我想知道 C++ 的工作方式在可扩展性和代码重用方面比 JAVA 更好,因为所有内容都是在联合文件中定义的?
感谢您的帮助!
编辑:只是为了确保这不是一场争论,我想知道为什么 JAVA 不像 C 那样做并促进类定义和类实现之间的分离。这种工作方式或程序有什么优点吗?
I have a homework and I need to evaluate which approach is better according to GRASP.
I found this link that answers part of my questioning: Why have header files and .cpp files in C++?
However, what I want to know is how much c++ way of working is better for extensibility and for code reuse than JAVA because everything is defined in a conjoint file ?
Thanks for the help !
Edit: Just to make sure that this is not a debate, I want to know why does JAVA does not do like in C and promotes the separation between class definitions and class implementations. Are there any advantages with that way of working or proceding ?
This question was moved to https://softwareengineering.stackexchange.com/questions/118574/does-java-promote-a-separation-between-class-definitions-and-implementations-as
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
java 中的等价物是您声明类接口,该接口确实用于无实现声明的目的。实现与接口的绑定确实在运行时发生,
从可扩展性的角度来看,两者是完全等效的。两种语言之间的差异不在于可扩展能力本身,而在于它们的性能方法。 Java 和 C# 的语法更统一,也更简洁,而某些 C++ 对于初学者来说读起来可能会很痛苦。 C++ 广泛关注通过模板进行编译时类型绑定,而 java 和 C# 传统上更关注运行时绑定和反射。尽管对于某些应用程序领域(主要是高性能计算)来说,垃圾收集等良好的语言功能对于 Java 和 C# 等语言来说仍然是一个很高的进入门槛,但这种差异在过去几年中已经有所减弱。
the equivalent in java is that you declare class interfaces that does serve the purpose of a implementation-less declaration. The binding of the implementation to the interface does happen at runtime
in the sense of extensibility both are entirely equivalent. The differences between both languages do not lie in the extensibility capabilities themselves, but in their performance approaches. Java and C# are more uniform in their syntax and more terse, while certain C++ can be a pain to read for the beginner. C++ has extensive focus in compile-time type binding through templates, while java and C# have traditionally more focus on run-time binding and reflection. This difference has softened in the last years, although for some application domain niches (mainly high performance computing) nice language features like garbage collection are still a high barrier of entry for the likes of Java and C#