title: When should I create factory or VM in angular
body: <p>This is how my angular app looks like.</p>
  
  <pre><code>(function () {
  "use strict";
  
  angular
      .module("app")
      .controller("custCtrl", custCtrl);
  
  custCtrl.$inject = ['dataService','custFactory'];
  
  /* @ngInject */
  function custCtrl(dataService, custFactory) {
      var vm = this;
      //line##
      vm.customer= custFactory.Create('customer');
  
      GetCustomers();
      function GetCustomers() {
  
          dataService.read().then(function (data) {
                  vm.customer = data.fields;
              }
          });
  
      }
  
      return vm;
  }
  })();
  </code></pre>
  
  <p>Factory Method </p>
  
  <pre><code>(function () {
  'use strict';
  
  angular
      .module('app.factory')
      .factory('custFactory', custFactory);
  
  custFactory.$inject = ['$q'];
  
  /* @ngInject */
  function custFactory($q) {
      var _create = function (type) {
  
          var obj = {};
  
          switch (type.toString().toLowerCase()) {
              case "customer":
                  obj = new Customer();
                  break;
              default:
                  obj = null;
          }
  
          return obj;
      }
  
      return {
          Create: _create
      };
  }
  })();
  </code></pre>
  
  <p>View Model<br/></p>
  
  <pre><code> function Customer()
   {
  
  var dto = this;
  
  dto.Customer = {
    "Name" : "",
    "Gender" : "", // &amp; so on
  }
  
   return dto;
  }
  </code></pre>
  
  <p>If you check my above <code>custCtrl</code> on //line##, I am calling factory method to instantiate customer object as below.</p>
  
  <pre><code>vm.customer= custFactory.Create('customer');
  </code></pre>
  
  <p>But if I <strong>don't</strong> create a customer VM &amp; factory and simple assign an empty string as below.</p>
  
  <pre><code>        vm.customer= {};
  </code></pre>
  
  <p>Still its working with no issue.</p>
  
  <blockquote>
    <p>So my question why should I create a VM &amp; factory?? What is its
    benefit??</p>
  </blockquote>