title: Private variables in swift
body: <p>When creating a class, what is the difference between these 2 implementations of creating a custom class in regards to security. They both work the exact same as far as I've used them, but have heard using private variables is the proper way to create classes  </p>
  
  <pre><code>class Person {
  
      var name:String
      var age:Int
  
      init(name: String, age: Int){
          self.name = name
          self.age = age
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>class Person {
  
      private var _name: String
      private var _age: Int
  
      var name: String {
          set {
              self._name = newValue
          } get {
              return _name
          }
      }
  
      var age: Int {
          set {
              self._age = newValue
          } get {
              return _age
          }
      }
  
      init(name: String, age: Int){
          self._name = name
          self._age = age
      }
  }
  </code></pre>