Skip to main content
import java.util.List; public interface IEntityParam { public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } } 

Suppose IEntityParamIEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note :

Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

import java.util.List; public interface IEntityParam { public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } } 

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

import java.util.List; public interface IEntityParam { public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } } 

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation.

Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

added 4 characters in body
Source Link
Ori Marko
  • 59.3k
  • 26
  • 157
  • 259

import java.util.List;

import java.util.List; public interface IEntityParam { public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } } 

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

import java.util.List;

public interface IEntityParam { public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } } 

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

import java.util.List; public interface IEntityParam { public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } } 

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

added 34 characters in body
Source Link
Maurice Perry
  • 9.7k
  • 2
  • 15
  • 28

import java.util.List;

public interface IEntityParam {

public interface IEntityParam { public void validateParam(Object object);    public default void validateParam(Object object,List<String> Str){   validateParam(object);  } } 

}

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

import java.util.List;

public interface IEntityParam {

public void validateParam(Object object); public default void validateParam(Object object,List<String> Str){ validateParam(object); } 

}

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

import java.util.List;

public interface IEntityParam { public void validateParam(Object object);    public default void validateParam(Object object,List<String> Str){   validateParam(object);  } } 

Suppose IEntityParam is very old interface extended by many classes and I need new method in it. I have added a new method in with another parameter. But my default implementation doesn't use new parameter List in its default method. Technically, there is no problem. But is it correct use of default method? Or Should I keep this new method to specific class as I am not using second parameter in default implementation. Note : The list of String which is supplied here is used in just one implementation right now but can be used in other implementation in future. It is not very specific and can be used by other implementation as well.

Source Link
vineeshchauhan
  • 805
  • 2
  • 8
  • 15
Loading