File tree Expand file tree Collapse file tree 5 files changed +89
-0
lines changed
Expand file tree Collapse file tree 5 files changed +89
-0
lines changed Original file line number Diff line number Diff line change 1+ package solid_principles .srp ;
2+
3+ public class Employee {
4+ private String empId ;
5+ private String empName ;
6+
7+ public String getEmpId () {
8+ return empId ;
9+ }
10+
11+ public void setEmpId (String empId ) {
12+ this .empId = empId ;
13+ }
14+
15+ public String getEmpName () {
16+ return empName ;
17+ }
18+
19+ public void setEmpName (String empName ) {
20+ this .empName = empName ;
21+ }
22+
23+ public void save () {
24+ // Saving employee to database
25+ // say mysql
26+ // in future if we want to change database
27+ // then we have to modify the employee code
28+ // so this can be moved
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ package solid_principles .srp ;
2+
3+ public class EmployeeRepository {
4+ public void save (EmployeeSRP employeeSRP ){
5+
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ package solid_principles .srp ;
2+
3+ public class EmployeeSRP {
4+ private String empId ;
5+ private String empName ;
6+
7+ public String getEmpId () {
8+ return empId ;
9+ }
10+
11+ public void setEmpId (String empId ) {
12+ this .empId = empId ;
13+ }
14+
15+ public String getEmpName () {
16+ return empName ;
17+ }
18+
19+ public void setEmpName (String empName ) {
20+ this .empName = empName ;
21+ }
22+
23+ public void save () {
24+ new EmployeeRepository ().save (this );
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ package solid_principles .srp ;
2+
3+ // SRP - Single Responsibility Principle
4+ // High Cohesion
5+ // Loose coupling
6+ public class Square {
7+ // Related to measurements
8+ public void calculateArea () {
9+
10+ }
11+
12+ public void calculatePerimeter () {
13+
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ package solid_principles .srp ;
2+
3+ public class SquareUI {
4+ public void rotate () {
5+
6+ }
7+
8+ public void draw () {
9+
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments