Facade pattern in the .NET BCL
The GoF facade pattern is used in scenarios where a lot of work happens in the background and the interfaces to those classes are exposed using a simple API. The XMLSeralizer
class in the .NET BCL does quite a bit of its work behind the scenes and access to those routines are given using a very simple interface. The following code snippets create a DataSet
to store a multiplication table for the number 42
(remember Douglas Adams!) and the XMLSeralizer
class persists the table to a text file:
class Program { private static DataSet CreateMultTable() { DataSet ds = new DataSet("CustomDataSet"); DataTable tbl = new DataTable("Multiplicationtable"); DataColumn column_1 = new DataColumn("Multiplicand"); DataColumn column_2 = new DataColumn("Multiplier"); DataColumn column_3 = new DataColumn("REsult"); tbl.Columns.Add(column_1); tbl...