File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes why interfaces are light weight when working on spring fram work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "why interfaces are light weight when working on spring fram work" Watch "why interfaces are light weight when working on spring fram work" New topic
Author

why interfaces are light weight when working on spring fram work

ehsan ulhaq dar
Greenhorn

Joined: Jun 04, 2008
Posts: 17
While using spring it is said that while write your classes it is good to use interfaces whether it is model class, or it is controller class or it is service class because when we use interface the application will be light weight. Can anybody explain why application is light weight when using interfaces.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

ehsan ulhaq dar wrote:While using spring it is said that while write your classes it is good to use interfaces whether it is model class, or it is controller class or it is service class because when we use interface the application will be light weight. Can anybody explain why application is light weight when using interfaces.


Not really lightweight as code has no physical weight in LBS. ;)

Anyway, coding to an interface has so many advantages regardless of whether it is in the context of Spring. With coding to an interface you can easily swap out any implementation without having to change code. You just write another implementation and use it instead. Coding to an interface helps make your code looser coupled which is a big thing when you have to change things. Everything always changes, so if you are tightly coupled, it makes changes really difficult and makes you take more time to code to do those changes. Also with interfaces help with Unit Testing so you can mock or stub out a dependency via its interface.

Interfaces also allows for DynamicProxies to be created in which you can add so much more functionality to your code without changing your code itself. AOP uses this.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why interfaces are light weight when working on spring fram work