• 0

Spacing in C language


  

14 members have voted

  1. 1. Spacing in C language

    • Example 1
      9
    • Example 2
      3
    • Example 3
      0
    • Other (Show example below)
      2


Question

Just a follow up on Mouton's thread, what kinds of white space do you use when programming in a C-syntax language (C, C++, Java, PHP, C#)?

Pick from these examples:

public class Test()
{
   private string _Name;
   private DateTime _DateOfBirth;

   public Test()
   {
   }

   public string Name
   {
      get { return _Name; }
      set { _Name = value; }
   }

   public DateOfBirth Age
   {
      get { return _DateOfBirth; }
      set { _DateOfBirth = value; }
   }

   public virtual void ThisIsAFunction()
   {
      // Blah!
   }
}

public class Test()
{
   private string _Name;
   private DateTime _DateOfBirth;
   public Test()
   {
   }
   public string Name
   {
      get { return _Name; }
      set { _Name = value; }
   }
   public DateOfBirth Age
   {
      get { return _DateOfBirth; }
      set { _DateOfBirth = value; }
   }
   public virtual void ThisIsAFunction()
   {
      // Blah!
   }
}

public class Test()
{


   private string _Name;
   private DateTime _DateOfBirth;


   public Test()
   {
   }


   public string Name
   {
      get { return _Name; }
      set { _Name = value; }
   }


   public DateOfBirth Age
   {
      get { return _DateOfBirth; }
      set { _DateOfBirth = value; }
   }


   public virtual void ThisIsAFunction()
   {
      // Blah!
   }


}

I'm a "Example 1" type person. I have a new line between each "block" of code. I think it separates the different areas very nicely. What about you?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

namespace STV
{
public class Test()
  {
  private string name;
 ?private DateTime dateOfBirth;

  public Test()
 ? ?{
 ? ?}//end of default constructor

  public string Name
 ? ?{
 ? ?get { return name; }
 ? ?set { name = value; }
 ? ?}//end of property

  public DateTime DateOfBirth
 ? ?{
 ? ?get { return dateOfBirth; }
 ? ?set { dateOfBirth = value; }
 ? ?}//end of property

 ?public void ThisIsAFunction()
    {
 ? ?// Blah!
    }//end of ThisIsAFunction()
  }//end of class
}//end of namespace

STV

Link to comment
Share on other sites

  • 0

always #1, you should have included the

if(1=1) {
   something
}

type spacing with the brackets because I see tons of code written that way, even though I personally hate it.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.