#107 Improve JavaDoc and change main class name for Model-View-Presenter
example
This commit is contained in:
parent
ef887e6003
commit
e8c8e26c8b
@ -4,19 +4,23 @@ package com.iluwatar.model.view.presenter;
|
|||||||
*
|
*
|
||||||
* The Model-View-Presenter(MVP) architectural pattern, helps us achieve what is
|
* The Model-View-Presenter(MVP) architectural pattern, helps us achieve what is
|
||||||
* called "The separation of concerns" principle. This is accomplished
|
* called "The separation of concerns" principle. This is accomplished
|
||||||
* by separating the application's logic(Model), GUIs(View), and finally
|
* by separating the application's logic (Model), GUIs (View), and finally
|
||||||
* the way that the user's actions update the application's logic(Presenter).
|
* the way that the user's actions update the application's logic (Presenter).
|
||||||
*
|
* <p>
|
||||||
* In the following example, The FileLoader class represents the app's logic,
|
* In the following example, The {@link FileLoader} class represents the app's logic,
|
||||||
* the FileSelectorJFrame is the GUI and the FileSelectorPresenter is
|
* the {@link FileSelectorJFrame} is the GUI and the {@link FileSelectorPresenter} is
|
||||||
* responsible to respond to users' actions.
|
* responsible to respond to users' actions.
|
||||||
*
|
* <p>
|
||||||
* Finally, please notice the wiring between the Presenter and the View
|
* Finally, please notice the wiring between the Presenter and the View
|
||||||
* and between the Presenter and the Model.
|
* 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) {
|
public static void main(String[] args) {
|
||||||
FileLoader loader = new FileLoader();
|
FileLoader loader = new FileLoader();
|
||||||
FileSelectorJFrame jFrame = new FileSelectorJFrame();
|
FileSelectorJFrame jFrame = new FileSelectorJFrame();
|
@ -7,7 +7,7 @@ import java.io.FileReader;
|
|||||||
/**
|
/**
|
||||||
* Every instance of this class represents the Model component in the
|
* Every instance of this class represents the Model component in the
|
||||||
* Model-View-Presenter architectural pattern.
|
* Model-View-Presenter architectural pattern.
|
||||||
*
|
* <p>
|
||||||
* It is responsible for reading and loading the contents of a given file.
|
* It is responsible for reading and loading the contents of a given file.
|
||||||
*/
|
*/
|
||||||
public class FileLoader {
|
public class FileLoader {
|
||||||
@ -51,9 +51,7 @@ public class FileLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the path of the file to be loaded, to the given value.
|
* 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) {
|
public void setFileName(String fileName) {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
|
@ -14,7 +14,7 @@ import javax.swing.JTextArea;
|
|||||||
import javax.swing.JTextField;
|
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.
|
* Model-View-Presenter pattern.
|
||||||
*/
|
*/
|
||||||
public class FileSelectorJFrame extends JFrame implements FileSelectorView,
|
public class FileSelectorJFrame extends JFrame implements FileSelectorView,
|
||||||
|
@ -3,7 +3,7 @@ package com.iluwatar.model.view.presenter;
|
|||||||
/**
|
/**
|
||||||
* Every instance of this class represents the Presenter component in the
|
* Every instance of this class represents the Presenter component in the
|
||||||
* Model-View-Presenter architectural pattern.
|
* Model-View-Presenter architectural pattern.
|
||||||
*
|
* <p>
|
||||||
* It is responsible for reacting to the user's actions and update the View
|
* It is responsible for reacting to the user's actions and update the View
|
||||||
* component.
|
* component.
|
||||||
*/
|
*/
|
||||||
@ -21,19 +21,15 @@ public class FileSelectorPresenter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* 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) {
|
public FileSelectorPresenter(FileSelectorView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the FileLoader object, to the value given as parameter.
|
* Sets the {@link FileLoader} object, to the value given as parameter.
|
||||||
*
|
* @param loader The new {@link FileLoader} object(the Model component).
|
||||||
* @param loader
|
|
||||||
* The new FileLoader object(the Model component).
|
|
||||||
*/
|
*/
|
||||||
public void setLoader(FileLoader loader) {
|
public void setLoader(FileLoader loader) {
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
|
@ -3,10 +3,10 @@ package com.iluwatar.model.view.presenter;
|
|||||||
/**
|
/**
|
||||||
* Every instance of this class represents the Stub component in the
|
* Every instance of this class represents the Stub component in the
|
||||||
* Model-View-Presenter architectural pattern.
|
* Model-View-Presenter architectural pattern.
|
||||||
*
|
* <p>
|
||||||
* The stub implements the View interface and it is useful when we want the test
|
* The stub implements the View interface and it is useful when we want the test
|
||||||
* the reaction to user events, such as mouse clicks.
|
* the reaction to user events, such as mouse clicks.
|
||||||
*
|
* <p>
|
||||||
* Since we can not test the GUI directly, the MVP pattern provides this
|
* Since we can not test the GUI directly, the MVP pattern provides this
|
||||||
* functionality through the View's dummy implementation, the Stub.
|
* functionality through the View's dummy implementation, the Stub.
|
||||||
*/
|
*/
|
||||||
|
@ -23,9 +23,7 @@ public interface FileSelectorView {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the presenter component, to the one given as parameter.
|
* 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);
|
public void setPresenter(FileSelectorPresenter presenter);
|
||||||
|
|
||||||
@ -36,9 +34,7 @@ public interface FileSelectorView {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the file's name, to the value given as parameter.
|
* 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);
|
public void setFileName(String name);
|
||||||
|
|
||||||
@ -49,17 +45,13 @@ public interface FileSelectorView {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a message to the users.
|
* 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);
|
public void showMessage(String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the data to the view.
|
* 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);
|
public void displayData(String data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user