Skip to content

“ACCESSORS AND MUTATORS in Asp.Net”

May 31, 2011
Accessors:-

1.	Read or obtain the value of private member variables.
	This must be done in a manner that maintains the integrity of the private member data.

2.	Display the value of private member variables.
	The displayed information should be user friendly, i.e., formatted in a fashion easily readable and understandably by the user.

3.	Print the value of private member variables.
	When an inappropriate attempt is made to change the value of a private data member, a properly written get function with good 		
        characteristics will be programmed to notify the user. User management should receive written notification of all inappropriate 		
        activity as soon as it occurs.



Mutators:-

1.	Modify the value of private data members.
	Public set functions set the value of private data members. However, set functions should not just change data. Set functions must be 
	programmed to make sure what they are being called to do is correct before they do it. Properly written set functions are the first 	
	line of	defense against, “garbage in, garbage out.”

2.	Validate the value of private data members.
	When an inappropriate attempt is made to change the value of a private data member, a properly written set function will be 	
        programmed to prevent the modification.

Example:-

using system;
public class Department
{
private string departname;
.......
// Accessor.
public string GetDepartname()
{
  return departname;
}
// Mutator.
public void SetDepartname( string a)
  {
    departname=a;
  }
}

From → .Net

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: