Applications containing a menubar typically do the following things:
Create a menubar
Add menus to the menubar
Set the frame's menubar
In good object-oriented fashion, we will encapsulate these tasks in a base class illustrated in Example 17-4. You can extend this class whenever you need a frame with a menubar.
Encapsulate Common Functionality in Base Classes
Encapsulating common functionality in a base class is one of the tenets of object-oriented development; it increases reuse and reduces reimplementation of reimplementing similar functionality in more than one class. Often, such code is not identified until two or more classes have reimplemented the same functionality. In such cases, it is well worth your while ...