title: Side inputs vs normal constructor parameters in Apache Beam
body: <p>I have a general question on side inputs and broadcasting in the context of <code>Apache Beam</code>. Does any additional variables, lists, maps that are need for computation during <code>processElement</code>, need to be passed as side input? Is it ok if they are passed as normal constructor arguments for the <code>DoFn</code> ? For example, what if I have some fixed (not computed) values variables (constants, like start date, end date) that I want to make use of during the per element computation of <code>processElement</code>. Now, I can make singleton <code>PCollectionView</code>s out of each of those variables separately and pass them to the <code>DoFn</code> constructor as side input. However, instead of doing that, can I not just pass each of those constants as normal constructor arguments to the <code>DoFn</code>? Am I missing anything subtle here?</p>
  
  <p>In terms of code, when should I do:</p>
  
  <pre class="lang-java prettyprint-override"><code>public static class MyFilter extends DoFn&lt;KV&lt;String, Iterable&lt;MyData&gt;&gt; {
    // these are singleton views
    private final PCollectionView&lt;LocalDateTime&gt; dateStartView;
    private final PCollectionView&lt;LocalDateTime&gt; dateEndView;
  
    public MyFilter(PCollectionView&lt;LocalDateTime&gt; dateStartView,
                         PCollectionView&lt;LocalDateTime&gt; dateEndView){
  
        this.dateStartView = dateStartView;
        this.dateEndView = dateEndView;
    }
  
    @ProcessElement
    public void processElement(ProcessContext c) throws Exception{
    // extract date values from the singleton views here and use them
  </code></pre>
  
  <p>As opposed to :</p>
  
  <pre class="lang-java prettyprint-override"><code>public static class MyFilter extends DoFn&lt;KV&lt;String, Iterable&lt;MyData&gt;&gt; {
    private final LocalDateTime dateStart;
    private final LocalDateTime dateEnd;
  
    public MyFilter(LocalDateTime dateStart,
                         LocalDateTime dateEnd){
  
      this.dateStart = dateStart;
      this.dateEnd = dateEnd;
    }
  
    @ProcessElement
    public void processElement(ProcessContext c) throws Exception{
    // use the passed in date values directly here
  </code></pre>
  
  <p>Notice that in these examples, <code>startDate</code> and <code>endDate</code> are fixed values and not the dynamic results of any previous computation of the pipeline.</p>