Most of the time, when considering the design rather than coding, the interface is truly clear and clearly shows its principles to you. For example, the computer's motherboard and video card have a Unified Agreement between them. As long as they comply with the PCI extension standard, your video card will certainly be able to be plugged into the motherboard, and can access information from the motherboard. This Convention is the interface. In most cases, in the field of software development, interface design should be a task of system analysts, that is, the task of Team Leader. The Team Leader designs the Schelable interface and Architecture as needed. The programmer codes, develops, tests, and so on based on his Architecture. In fact, you can implement the same or even more complete functions without using interfaces. However, with the interface, the entire design will become clear and clear. In terms of software scalability and reusability, the interface design is even more important. Therefore, understanding and understanding interfaces should be from the design perspective, rather than the encoding perspective.
Appendix: A Sample
Requirement: in an existing Table class, I want to display the following data:
1. Text: displays text.
2. Image Information: displays images.
3. video information: play the video
The design is as follows: interface IDisplayable
{
Void Display (Table table );
}
Public class Text: IDisplayable
{
Public void Display (Table table)
{
// Implements the text display method
}
}
Public class Picture: IDisplayable
{
Public void Disply (Table table)
{
// Implements picture display here
}
}
Public class Vedio: IDisplayable
{
Public void Disply (Table table)
{
// Implements vedio play
}
}
Public class Test
{
Text t = new Text ("Hello ");
Picture p = new Picture ("1.jpg ");
Vedio v = new Vedio ("sample. avi ");
Table table = new Table ();
Table. Add (t );
Table. Add (p );
Table. Add (v );
Table. Show ();
Foreach (IDisplayable disp in Table. Items)
{
Disp. Display (this. table );
}
}