• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Minimizing Compile Time dependencies

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic