• Post Reply Bookmark Topic Watch Topic
  • New Topic

Minimizing Compile Time dependencies  RSS feed

 
Johny Valencia
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In C++ minimizing Compile Time dependencies is a fundamental physical design issue. The class designer tries to create as minimal dependencies to other classes using forward declarations and eliminating as many include directives he can, usually implementing the class details using an envelope � letter (pimpl) pattern.

Is a similar approach doable in Java ?

Please note that there are three types of changes :

1)Adding new methods
2)Modifying the body of a method
3)Modifying the signature of an existing method

For cases 1 and 2 compiling the class does not break existing clients of it (my understanding is that the VM is using Reflection to map method calls), which is fine.

BUT case 3 causes callers of the method to throw a RUNTIME exception. The only way around it is to recompile the client class.

If we use timestamp comparison to recompile we are going to end up recompiling even for cases 1 and 2.

I don�t know if the only way around it, is for the developer to enforce a coding rule not to modify the signature of a class unless he is willing to recompile his entire application�..

Any help will be greatly appreciated

Thanks

John
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Johny Valencia:
If we use timestamp comparison to recompile we are going to end up recompiling even for cases 1


Not if your code obeys the Interface Segregation Principle.

and 2.


Not if the client code only knows about the interface and the actual implementation class is only known at runtime, for example via a form of Dependency Injection.



I don�t know if the only way around it, is for the developer to enforce a coding rule not to modify the signature of a class unless he is willing to recompile his entire application�..


If you modify the signature of a method, of course any client of that method will need to be recompiled - there is no way around it, even in C++ as far as I know.

Following good OO design principles will minimize that impact and hold it from rippling through the whole application, though.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!