Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Move this "xxTypexx" member and its use to a DAO class.
-
Highlighting:
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Targeted languages:Java
-
Remediation Function:Constant/Issue
-
Constant Cost:20min
-
Analysis Scope:Main Sources
Description
A cleanly coded web application will have a clear separation of concerns, with business logic in the @Service layer, and communication with other systems in the data access layer.
To help enforce such a separation of concerns, this rule raises an issue when a @Service class has RestTemplate, JmsTemplate, WebServiceTemplate, JdbcTemplate, or DataSource member.
Noncompliant Code Example
@Service ("greetingmanager") public class GreetingManagerImpl implements GreetingManager { @Autowired DataSource ds; // Noncompliant
Compliant Solution
@Service ("greetingmanager") public class GreetingManagerImpl implements GreetingManager { @Autowired GreetingDao gdao; // DataSource and its use have been moved here