value class convention

Dan Howard sproket at videotron.ca
Mon Dec 22 20:00:12 UTC 2014


Question what does the following C# code output:

class  Program
     {
         static  void  Main(string[] args)
         {
  
             Account  account =new  Account();
             account.AcccountNumber ="1234";
             account.Name ="Savings";
             account.Balance = 10;
  
             Console.WriteLine("BEFORE: "  + account);
  
             adjustAccountBalance(account, 10);
  
             Console.WriteLine("AFTER: "  + account);
  
             Console.ReadLine();
         }
  
         static  void  adjustAccountBalance(Account  account,float  balance)
         {
             account.Balance += balance;
         }
     }

Answer: *unknown.* Since we don't know if an Account is a *class *or a 
*struct*.

One way would could help avoid this situation in Java would be to use 
lower case/underscore convention for value types - to give same 
indication as primitives.

Here we'd have:

account  account =new  account();

or

point  p =new  point();

etc..

What do you think?



---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com



More information about the valhalla-dev mailing list