Single Responsibility
#Single Responsibility YouYou are doing a few things in main:
- Read srcPath and destPath from the properties file
- Understand which service is responsible for each path
- Find the relevant copy function
- Call the copy function
I suggest creating a method for each of the above bullets.
Polymorphism
You asked
Is there a better OOP way to solve this?
I guess you mean Polymorphism as it one of the key features of OOP.
One way is to write a function that returns the relevant function. Scala support functions types very well.
Another way is creating a trait and classes that implement it (as you did the question you deleted) and a function or factory object that return the relevant class. This way is more common in OOP. Also, it is better in terms of single responsibility:CopyFiles
do a lot of different types of copies.
Avoid Ifs
#Avoid Ifs InIn the question you deleted, you asked if you can rid of the ifs. when the input is the services names(and not the paths), I believe you can use pattern matching easily.
#Single Responsibility You are doing a few things in main:
- Read srcPath and destPath from the properties file
- Understand which service is responsible for each path
- Find the relevant copy function
- Call the copy function
I suggest creating a method for each of the above bullets.
Polymorphism
You asked
Is there a better OOP way to solve this?
I guess you mean Polymorphism as it one of the key features of OOP.
One way is to write a function that returns the relevant function. Scala support functions types very well.
Another way is creating a trait and classes that implement it (as you did the question you deleted) and a function or factory object that return the relevant class. This way is more common in OOP. Also, it is better in terms of single responsibility:CopyFiles
do a lot of different types of copies.
#Avoid Ifs In the question you deleted, you asked if you can rid of the ifs. when the input is the services names(and not the paths), I believe you can use pattern matching easily.
Single Responsibility
You are doing a few things in main:
- Read srcPath and destPath from the properties file
- Understand which service is responsible for each path
- Find the relevant copy function
- Call the copy function
I suggest creating a method for each of the above bullets.
Polymorphism
You asked
Is there a better OOP way to solve this?
I guess you mean Polymorphism as it one of the key features of OOP.
One way is to write a function that returns the relevant function. Scala support functions types very well.
Another way is creating a trait and classes that implement it (as you did the question you deleted) and a function or factory object that return the relevant class. This way is more common in OOP. Also, it is better in terms of single responsibility:CopyFiles
do a lot of different types of copies.
Avoid Ifs
In the question you deleted, you asked if you can rid of the ifs. when the input is the services names(and not the paths), I believe you can use pattern matching easily.
#Single Responsibility You are doing a few things in main:
- Read srcPath and destPath from the properties file
- Understand which service is responsible for each path
- Find the relevant copy function
- Call the copy function
I suggest creating a method for each of the above bullets.
Polymorphism
You asked
Is there a better OOP way to solve this?
I guess you mean Polymorphism as it one of the key features of OOP.
One way is to write a function that returns the relevant function. Scala support functions types very well.
Another way is creating a trait and classes that implement it (as you did the question you deleted) and a function or factory object that return the relevant class. This way is more common in OOP. Also, it is better in terms of single responsibility:CopyFiles
do a lot of different types of copies.
#Avoid Ifs In the question you deleted, you asked if you can rid of the ifs. when the input is the services names(and not the paths), I believe you can use pattern matching easily.