Use of factory pattern in java

37
October 22, 2019, at 10:10 PM

is it a valid use of the factory pattern to "convert" objects from a given string?
Example:
If I have a text file where the data presents values for my object for example a numeric string "00101292877882" and I want it to create an object which will recieve the data as an Integer Array... Do I use something like this objectFactory.createObjectFromString(fileContent) where createObjectFromString parses the string and returns an object which contains the int[] as member.

Answer 1

Factory pattern is the pattern from Build section. What if format of the string will change? String format belongs to Transport layer; I reccomend to do following:

  1. Convert String into another object with fields, it could be a Map<String, Object;
  2. Your factory method should accept this Map (it could be received from different sources) an build required object. This will be correct builder.
READ ALSO
How to capture log level Error and Warning both in Pyspark?

How to capture log level Error and Warning both in Pyspark?

I have tried to set log level as error or warn, but curious how to capture both ?

34
Inconsistent plotting behaviour with radial bar chart in matplotlib

Inconsistent plotting behaviour with radial bar chart in matplotlib

I'm trying to create a circular bar chart in Python/matplotlibI have the code working fine on my desktop (using Spyder), but the output of the program is completely different on different computers even in the same version of Python (3

49
Python built in function - Input

Python built in function - Input

I run this code as apy file which will bring up a command prompt from the built in Python function input

50
Why python has different types of bytes

Why python has different types of bytes

I have two variables, one is b_d, the other is b_test_d

44