Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
Many platforms and API's expose the highest level of detail to the user. Sometimes this detail, although flexible may confuse the user or make it difficult to use. A facade usually wrapps this detail into an easy to use object -- usually agregating the inner API into friendlier and more meaningful outer API.
There are no boundaries to where a facade pattern can implemented. The many classes in the .NET framework for example could be considered facades as they encapsulate the tricky win32 api into easy to use classes.
Additionally, occasionally you may want to even restrict the API further specifically for your application. Your application for example may require the interaction of classrooms and each classroom must have certain distribution of male and female students. Of course, you can create instances for each classroom and then create instances of each student and add them to the classroom, however you can simply create a constructor that will do this automatically for you.
public class Classroom
{
private Student[] _Students;
//a constructor which creates a classroom of students automatically
public Classroom( int numberOfStudents, int numberOfMales )
{
_Students = new Student[ numberOfStudents ];
for( int i = 0; i < numberOfMales; i++ )
_Students = new Student( true );
for( int b = i; b < numberOfStudents; b++ )
_Students = new Student( false );
}
...
}
public class Student
{
protected bool _IsMale;
public Student( bool isMale )
{
_IsMale = isMale;
}
...
}