Java Best Practices | Code for Interface Not for Implementation | PART-1

preview_player
Показать описание
Welcome to Java best practices series. In Part 1, we will learn how to code for interface, not for implementation with an example.

Always program for the interface and not for application; this will lead to flexible code that can work with any new implementation of the interface.

So use interface type on variables, return types of method or argument type of methods in Java.

#javabestpractices #javaguides #oops #java
Рекомендации по теме
Комментарии
Автор

Very useful and nicely explained. You always choose unique contents. You should deserve more subscribers.

javatechnology
Автор

Unable to see the code due to titles but valid information ...thanks

RajeshR-ypsy
Автор

what is the difference between "Shape rectangle = new Rectangle()" vs "Rectangle rectangle = new Rectangle?"
In both cases we create a Rectangle object.

cristimanolache
Автор

Think there are 2 class Vehicle and Car, Vehicle is abstract class, I am creating
Vehicle car = new Car(); --> is this also code for interface not for implementation? I am little bit confusing, in my case vehicle is not interface please help me to solve this issue.

lishannavishka