Overview: Good coding style separates a program's computation (aka its Model), its user-interface (aka its View), and its control code (aka its Controller), because doing so maximizes the amount of reuseable code in the application. Software engineers know this as the MVC (Model-View-Controller) pattern, which is often structured as follows:
In this assignment, we will apply this pattern to our hostinfo program.
Details.
This project is to rewrite your hostinfo program in a more object-oriented fashion. The trick is to write it in such a way that a maximal amount of your code is reuseable. To gauge this, you are to build two user interfaces:
To accomplish this goal, you are to isolate hostinfo's core functionality in a separate Model class. You should also build a class for each different View or user interface (e.g., CommandLineSwitchInterface, and a Controller class for each View. These Controller classes can then
Your driver program hostinfo.cpp should be fairly simple:
If you find yourself writing redundant coding for any of these classes, store the redundant coding in a superclass, and derive your classes from this superclass. In a "worst case scenario", your design might look something like this:
Plan of Action.
1. Review your solution to Assignment 1. Identify what parts of your code contribute to the user-interface (the View), what parts control the execution (the Controller), and what parts are the core of the the "hostinfo" computation (the Model).
2. Decide which user interfaces you are going to provide, and design them to perform their task. Design each user interface class to get the information from the user, providing methods whereby the Controller can retrieve the information from the View.
3. Implement the Model, Controller, and View classes, as well as any superclasses needed to consolidate code these classes have in common.
5. Rewrite your host driver so that it checks the first command-line switch (if any), creates the appropriate Controller, and then sends it the run() message.
When your program is working, compare the results it produces to those of your previous version. (There should not be a significant difference.)
You are encouraged to recruit one or more people from outside of this class to serve as user-testers to evaluate your user-interface. If a "newby" cannot use your program, then your user-interface should be revised.
As before, you are free to talk to your classmates about algorithmic details, and general approaches you use in this project, provided you give proper credit in your documentation to ideas that are not your own. You are not to look at anyone else's code, for any reason.
Honors: Build all three interfaces (console-command-line, console-menu, GUI), each supporting the ability to request and retrieve information about the host.
Turn in: The project grade sheet, attached to a script file, in which you do the following: