Datasheet
private string m_year;
public string Year
{
get { return m_year; }
set { m_year = value; }
}
private string m_month;
public string Month
{
get { return m_month; }
set { m_month = value; }
}
private string m_title;
public string Title
{
get { return m_title; }
set { m_title = value; }
}
private string m_content;
public string Content
{
get { return m_content; }
set { m_content = value; }
}
public Article(string year, string month, string title, string content)
{
Year = year;
Month = month;
Title = title;
Content = content;
}
}
Data in the Articles class is exposed through properties as its public interface, providing encapsulation.
This gives you the ability to change the underlying implementation as necessary, including adding busi-
ness rules and validation logic.
If I had used a datasource control other than the OjectDataSource control in my code,
adding business rules would not have been an option. I chose not to for the purpose
of simplifying the code in this example, but I still have a choice. Using the Object
DataSource control properly, you can design applications so they are flexible and
maintainable.
23
Hacks Revisited
04_597663 ch01.qxp 4/25/06 9:54 PM Page 23