As part of DotNetDoc's new "Ask the Doc" format, we are starting our journey by taking a page from the Zen Master himself Scott Hanselman. We will be walking through his list of questions posted in his, "What Great .NET Developers Ought To Know" post. We will not only try to answer the questions but give each a "deep dive" so that we not only can answer the question, but so that we UNDERSTAND the answer. We will go one question at a time until we reach the end. I hope you enjoy, and thanks Scott for the thought provoking questions.
.Net Ought To Know #6 : Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family?
The answer to the question is not that tough so I thought we would go a little deeper and talk about Components, Controls, and Containers Oh My!! (Sorry I couldn't resist). In the .Net Framework, simply put, a component is a class that implements the System.ComponentModel.IComponent interface or derives from a class that does. A component is something that can be reused. C# is considered a component-oriented language. Re-use is everything in component-oriented design. Putting together pre-tested parts is faster and cheaper then coding it yourself. So to summertime, a component is any class that directly or indirectly implements the IComponent Interface. A component can be added to the toolbox and dragged and dropped onto a form.
A control on the other hand is a component that provides a UI. To do this you need to implement System.Windows.Forms.Control OR System.Web.UI.Control. So a control is basically a component that has visual properties.
This finally leads us to the answer to this question. You need a place to hold your components and controls. This is done in a Container. A Container is a class that implements the System.ComponentModel.IContainer interface (directly or indirectly). Since this container holds your controls, it is easy to access the controls dynamically.
9 Private Class ControlWalker
10 Private mContainer As Object
11 Public Sub New(ByVal Container As Object)
12 Dim cControl As Control
13 If Container.haschildren Then
14 For Each cControl In Container.controls
15 'add this control to the controls collection
17 If cControl.HasChildren Then
18 'This control has children, create another
19 'ControlWalk go visit each of them
20 Dim cWalker As New ControlWalker(cControl)
21 End If
22 Next cControl
23 End If
24 End Sub
25 End Class
So you tell me now, this should be easy. What are 3 containers in then Windows Server Family?