title: Scala - why private member then
body: <p>I am start working on existing Scala and Akka project. I say Scala classes, some fields making them as private and providing getter and setter methods in different way. why like that you can make it as public also right.</p>
  
  <p>I say in my project</p>
  
  <p>Why this way:</p>
  
  <pre><code>class Person() {  
   // Private age variable, renamed to _age 
   private var _age = 0 
   var name = "" 
  
   // Getter 
   def age = _age 
  
   // Setter 
   def age_= (value:Int):Unit = _age = value 
  } 
  </code></pre>
  
  <p>So you can get same feeling like public:</p>
  
  <pre><code>person.age = 99  
  </code></pre>
  
  <p>Why not this simple way?</p>
  
  <pre><code>class Person() {  
   var name = "" 
   var age = 0 
  } 
  
  // Instantiate a person object 
  person = new Person() 
  
  // Print the object's age and name properties 
  println(person.age)  
  println(person.name) 
  
  
  // Set the properties to different values 
  person.age = 34  
  person.name = "Dustin Martin" 
  </code></pre>