Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

How to avoid changes in interface effect project

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

if we develop a project implementing a interface from a jar file from some x.
if x says he wants to change the interface and want to send a new jar file.

What is best thing to do or how to avoid this case..

Thank You
 
Marshal
Posts: 73738
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Download the jar file, say thank you, and quietly delete it while he isn't watching ??
 
Ram ank
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats Funny

but i cant be funny in interview

what should i do in that case
 
Rancher
Posts: 436
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can

1) Negotiate with the creator not to change the interface.
2) Use an old version of the Jar.
3) Refactor your code.
4) Write proxy classes that abstract their code from yours.

If #1 is out of question (like a public library where you are one user of plenty) then #3 is the way to go typically.
 
Ram ank
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You

can we avoid such situations

is interface injection possible

like using frameworks for IOC


just curious
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are talking about Java interfaces, not interfaces in general or different interface definition languages (like WSDL)?

For Java interfaces: No. That's why changing an interface is expensive. Some use even version numbers in interface names (Eclipse project, IIRC; or java.awt.LayoutManager which got a new version with java.awt.LayoutManager2).

In the latter case you eventually can generate the Java classes automatically from the IDL. Then it is a little bit easier.
 
Campbell Ritchie
Marshal
Posts: 73738
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct about version numbers; once a Java™ interface has been released onto an unsuspecting world, it ought never to be changed for fear of breaking old code.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(A)Suppose your question is about Java Interface:
thus,
1) you have many subclasses that implement the Java Interface provided in jar file
2) you are using coding to interface (e.g. InterfaceABC abc = new ClassMyImpl(); )
3) so polymorphism happening around all your client code


Suppose some x only change the Java Interface name , and method name left unchanged
Old Java Interface name: InterfaceABC
so your implementation classes name: ClassMyImpl implements InterfaceABC

now some x change the Interface name to: InterfaceXYZ

you create a new Interface with name: InterfaceABC extends InterfaceXYZ
you don't need to change your implementation classes name and all the client code that using polymorphism.
(BUT this will break polymorphism which calling method of implementation classes in jar file, because different class hierarchy)



(B)Suppose your question is about interface (means method definition) instead of the Java Interface:
Solution: use Design Pattern "Adapter Pattern"
 
A feeble attempt to tell you about our stuff that makes us money
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic