Spotting the MVC Pattern in the NetBeans Platform
By Geertjan on Jun 30, 2010
Why MVC, in particular? Because that's a pattern very familiar to (Java) programmers and it is a pattern used throughout the NetBeans Platform. The nice thing about MVC is that it enables you to relate three separate things together as a single unit. So where, before, you had three separate unrelated items, you now, with MVC, are able to relate them to each other and, by understanding one, you understand all of them, at the same time. Handy, right?
So, here are some places where MVC can be seen in the NetBeans Platform:
- FileObject (model), DataObject (controler), Node (view)
- Node (model), ExplorerManager (controler), explorer views (view)
Well, with the above two, we've actually covered the majority of the NetBeans Platform already. Note that the "Node" classes (Node, AbstractNode, BeanNode, DataNode) play two different roles, depending how you look at it, first as the view, but then also as the model. (And FilterNode is an example of the decorator pattern.) The "explorer views" in the second bullet is one of BeanTreeView, or OutlineView, or ListView, or one of the other explorer views. When, confronted by the plethora of new classes you're confronted with when starting with the NetBeans API, the above simple division of classes might help in understanding how different parts relate to each other.
Other parts of the NetBeans Platform, such as its Wizard framework, can also be understood in terms of MVC. However, the above are the central ones to get comfortable with quickly.
Once you're comfortable with the above ideas, consider listening/watching NetBeans API architect Jaroslav Tulach talk about MVC and DCI in the context of the NetBeans Platform.