#107 Improve JavaDoc and change main class name for Model-View-Presenter

example
This commit is contained in:
Ilkka Seppala 2015-08-20 22:29:44 +03:00
parent ef887e6003
commit e8c8e26c8b
6 changed files with 24 additions and 34 deletions

View File

@ -6,17 +6,21 @@ package com.iluwatar.model.view.presenter;
* called "The separation of concerns" principle. This is accomplished
* by separating the application's logic (Model), GUIs (View), and finally
* the way that the user's actions update the application's logic (Presenter).
*
* In the following example, The FileLoader class represents the app's logic,
* the FileSelectorJFrame is the GUI and the FileSelectorPresenter is
* <p>
* In the following example, The {@link FileLoader} class represents the app's logic,
* the {@link FileSelectorJFrame} is the GUI and the {@link FileSelectorPresenter} is
* responsible to respond to users' actions.
*
* <p>
* Finally, please notice the wiring between the Presenter and the View
* and between the Presenter and the Model.
*
*/
public class MainApp {
public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main(String[] args) {
FileLoader loader = new FileLoader();
FileSelectorJFrame jFrame = new FileSelectorJFrame();

View File

@ -7,7 +7,7 @@ import java.io.FileReader;
/**
* Every instance of this class represents the Model component in the
* Model-View-Presenter architectural pattern.
*
* <p>
* It is responsible for reading and loading the contents of a given file.
*/
public class FileLoader {
@ -51,9 +51,7 @@ public class FileLoader {
/**
* Sets the path of the file to be loaded, to the given value.
*
* @param fileName
* The path of the file to be loaded.
* @param fileName The path of the file to be loaded.
*/
public void setFileName(String fileName) {
this.fileName = fileName;

View File

@ -14,7 +14,7 @@ import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* This class is the GUI implementation of the View component In the
* This class is the GUI implementation of the View component in the
* Model-View-Presenter pattern.
*/
public class FileSelectorJFrame extends JFrame implements FileSelectorView,

View File

@ -3,7 +3,7 @@ package com.iluwatar.model.view.presenter;
/**
* Every instance of this class represents the Presenter component in the
* Model-View-Presenter architectural pattern.
*
* <p>
* It is responsible for reacting to the user's actions and update the View
* component.
*/
@ -21,19 +21,15 @@ public class FileSelectorPresenter {
/**
* Constructor
*
* @param view
* The view component that the presenter will interact with.
* @param view The view component that the presenter will interact with.
*/
public FileSelectorPresenter(FileSelectorView view) {
this.view = view;
}
/**
* Sets the FileLoader object, to the value given as parameter.
*
* @param loader
* The new FileLoader object(the Model component).
* Sets the {@link FileLoader} object, to the value given as parameter.
* @param loader The new {@link FileLoader} object(the Model component).
*/
public void setLoader(FileLoader loader) {
this.loader = loader;

View File

@ -3,10 +3,10 @@ package com.iluwatar.model.view.presenter;
/**
* Every instance of this class represents the Stub component in the
* Model-View-Presenter architectural pattern.
*
* <p>
* The stub implements the View interface and it is useful when we want the test
* the reaction to user events, such as mouse clicks.
*
* <p>
* Since we can not test the GUI directly, the MVP pattern provides this
* functionality through the View's dummy implementation, the Stub.
*/

View File

@ -23,9 +23,7 @@ public interface FileSelectorView {
/**
* Sets the presenter component, to the one given as parameter.
*
* @param presenter
* The new presenter component.
* @param presenter The new presenter component.
*/
public void setPresenter(FileSelectorPresenter presenter);
@ -36,9 +34,7 @@ public interface FileSelectorView {
/**
* Sets the file's name, to the value given as parameter.
*
* @param name
* The new name of the file.
* @param name The new name of the file.
*/
public void setFileName(String name);
@ -49,17 +45,13 @@ public interface FileSelectorView {
/**
* Displays a message to the users.
*
* @param message
* The message to be displayed.
* @param message The message to be displayed.
*/
public void showMessage(String message);
/**
* Displays the data to the view.
*
* @param data
* The data to be written.
* @param data The data to be written.
*/
public void displayData(String data);
}