Interfaces and Performance

Discussions

Performance and scalability: Interfaces and Performance

  1. Interfaces and Performance (1 messages)

    I am working with a coworker who is very heavy on design as I am. But, one thing where we disagree on is his insistence that every class, even simple JavaBeans, have interfaces defined for them. I can't justify using an interface for a JavaBean in my head and I think it is over doing it because your implementation of getters and setters shouldn't change. And if you change properties you'll have to change the interface as well anyway. Anyway, I just went along with it as I didn't want to butt heads. But, I was wondering how much of a performance impact having all these interfaces would have on performance? From my standpoint, I think our app is taking more memory than it should and I'm wondering if something like this could be the reason. Any feedback on this?
  2. Interfaces and Performance[ Go to top ]

    I am working with a coworker who is very heavy on design as I am. But, one thing where we disagree on is his insistence that every class, even simple JavaBeans, have interfaces defined for them. I can't justify using an interface for a JavaBean in my head and I think it is over doing it because your implementation of getters and setters shouldn't change. And if you change properties you'll have to change the interface as well anyway. Anyway, I just went along with it as I didn't want to butt heads. But, I was wondering how much of a performance impact having all these interfaces would have on performance? From my standpoint, I think our app is taking more memory than it should and I'm wondering if something like this could be the reason. Any feedback on this?
    He is right. He probably wants to be able to switch the entire bean class for another one without having to recompile the dependant code. That is exclusively for polymorphism. You think the bean is just a data store, in which case setters/getters are behaviorless. But if it is not, or has more methods than setters/getters, than chances are those beans could be plugins, service providers, etc...

    As performance is concerned, The classes are not that big in memory. I used a simple rule: 4 x the byte code size. You got 500k of classes? you might be using less than 2 megs of ram for that. The only penalty is that code inlining by the JIT compiler may be reduced, since the method calls are always virtual since they are interface methods, no matter if the implementation class declared its method final. But that is speculation, and shouldn't show up in benchmarks.