Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Spring with Hibernate Data-Driven Application Design Writing Your First DAO

Binyamin Friedman
Binyamin Friedman
14,615 Points

Why use an interface?

Why do we implement an interface instead of just using a normal class?

1 Answer

Dear Binyamin,

Using an interface has several advantages:

1) By separating the logic from the interface, you can keep working on your logic once the product has been launched,

2) It helps to re-use your code (must of the code you will re use will be in the "logic files"). (DRY --> Do not Repeat Yourself!)

3) It makes the use of the program on different platforms easier. The logic is the same for website, smartphone, tablet...the interface is not.

So is always better to maintain the "separation of concerns" and keep the interface separated from the logic!

Hope it helps!!!