Because all of the elements within an API implement a
similar interface, a common interface can be used. This makes development of
the interface a lot easier.
Listing 1
public abstract class UIElement
{
private string _name = string.Empty;
private string _title = "Untitled";
private bool _visible = true;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public string Title
{
get
{
return _title;
}
set
{
_title = value;
}
}
public bool Visible
{
get
{
return _visible;
}
set
{
_visible = value;
}
}
}
Each object can be visible or invisible, and can have a
name/title. These are the core features that can be incorporated. In
addition, the next level of abstraction is for a window. A window is either a
document or tool window that contains a user interface.
Listing 2
public abstract class BaseWindow: UIElement
{
private object _uiInterface = null;
public object UIInterface
{
get
{
return _uiInterface;
}
set
{
_uiInterface = value;
}
}
}
If in the future, any window-based object needed additional
features could easily incorporate them in the base class.