Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Best practice for component Java backers? Interface only or implement it as well?

Art_Broussard
Level 2
Level 2

Currently each component gets a Java interface written. It also gets an impl class that uses annotations like @ValueMapValue and @getter in place of writing the actual getter and setters. We do this for everything regardless of how basic the component is.

 

I've seen some blog posts that suggest you only create an interface and use the annotations like @ValueMapValue in it. This removes the need to create the impl class as well as unit tests.

 

What would be considered the recommended/best practice in this case?

1 Accepted Solution
milind_bachani
Correct answer by
Level 6
Level 6

Hi @Art_Broussard ,

The recommended practice is to have a class for each of the component, since each component might have a business logic which is not very generic. Also, having Junit for all of them makes the code more reliable depending on the test suite developed.

However, if you have a project which has all the classes that does not have any business logic then you can implement a generic class implementing the generic interface with @ValueMapValue.

You can make the call of implementation based on the project requirement and future scope.

 

Thanks.

View solution in original post

1 Reply
milind_bachani
Correct answer by
Level 6
Level 6

Hi @Art_Broussard ,

The recommended practice is to have a class for each of the component, since each component might have a business logic which is not very generic. Also, having Junit for all of them makes the code more reliable depending on the test suite developed.

However, if you have a project which has all the classes that does not have any business logic then you can implement a generic class implementing the generic interface with @ValueMapValue.

You can make the call of implementation based on the project requirement and future scope.

 

Thanks.