I am trying to solve which design pattern I have to use for this problem:
I have classes Computer and Algorithm
1) There could be lot of instances of Computer
2) Every Computer can have exactly one instance of Algorithm
3) Algorithm is some kind of abstract, it should have one void “compute”
4) the concrete algorithm is in class ConcreteAlg1, ConcreteAlg2 etc. so there could be lot of different classes of concrete algorithm
My goal is to create an Computer instance where I create new ConcreteAlg235 instance without knowing that some class ConcreteAlg235 was added. So my goal is to easily create new algorithm classes and create its instances in instance of class Computer without editing code of class Computer.
Think about that like I want to do some proprietary software and give an opportunity to add new algorithms for users,and to have easy maintainability of source code for myself.
Thank you for any ideas
Strategy