خرید بک لینک

Vote count: -1

I am new to python and I have to design a Python API(version - 2.7) similar to an existing Java API

Python version - 2.7

The Java API is as follows

There is a Process interface

public interface Process<T> {

  Future<T> create(Client<T> client)

}

There are two implementations of Process . For simplicity I have shown the implementation of one 1) FirstProcess
2) SecondProcess

public class FirstProcess implements Process {

   Future<T> create(Client<T> client) {

   }
}

There is a ProcessFactory

public interface ProcessFactory {

  Process createProcess()
}

There are two implementations of ProcessFactory
1) FirstProcessFactory
2) SecondProcessFactory

For simplicity I have just shown the implementation of one

public class FirstProcessFactory implements ProcessFactory {

  Process createProcess() {

     retu new FirstProcess()
  }
}

There is a builder for the Process

ProcessBuilder

public class ProcessBuilder {

   // Has a lot of methods for config setup and validation

   public Process build() {

      //Based on the config uses the ProcessFactory to retu 
      // either FirstProcess or SecondProcess
   }
}

I have a few questions

1) I have already read about how I could use the named parameters instead of the Builder patte.

2) If I use the named parameters how I can implement the Factory Patte, how can I decide about instantiating FirstProcess or SecondProcess based on the config. The existing java logic is present in the build() method of ProcessBuilder and uses the ProcessFactory

3) Would it be a good python design if I have the same Java API design with both builder and the factory pattes ?

asked 55 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 6 تير 1395 ساعت: 4:20

صفحه بندی