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 trialBinyamin Friedman
14,615 PointsWhy use an interface?
Why do we implement an interface instead of just using a normal class?
1 Answer
Ricardo Sala
16,212 PointsDear 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!!!