X Tutup
Skip to content

Commit e8c8e26

Browse files
committed
iluwatar#107 Improve JavaDoc and change main class name for Model-View-Presenter
example
1 parent ef887e6 commit e8c8e26

File tree

6 files changed

+24
-34
lines changed

6 files changed

+24
-34
lines changed

model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/MainApp.java renamed to model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/App.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
*
55
* The Model-View-Presenter(MVP) architectural pattern, helps us achieve what is
66
* called "The separation of concerns" principle. This is accomplished
7-
* by separating the application's logic(Model), GUIs(View), and finally
8-
* the way that the user's actions update the application's logic(Presenter).
9-
*
10-
* In the following example, The FileLoader class represents the app's logic,
11-
* the FileSelectorJFrame is the GUI and the FileSelectorPresenter is
7+
* by separating the application's logic (Model), GUIs (View), and finally
8+
* the way that the user's actions update the application's logic (Presenter).
9+
* <p>
10+
* In the following example, The {@link FileLoader} class represents the app's logic,
11+
* the {@link FileSelectorJFrame} is the GUI and the {@link FileSelectorPresenter} is
1212
* responsible to respond to users' actions.
13-
*
13+
* <p>
1414
* Finally, please notice the wiring between the Presenter and the View
1515
* and between the Presenter and the Model.
1616
*
1717
*/
18-
public class MainApp {
18+
public class App {
1919

20+
/**
21+
* Program entry point
22+
* @param args command line args
23+
*/
2024
public static void main(String[] args) {
2125
FileLoader loader = new FileLoader();
2226
FileSelectorJFrame jFrame = new FileSelectorJFrame();

model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileLoader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Every instance of this class represents the Model component in the
99
* Model-View-Presenter architectural pattern.
10-
*
10+
* <p>
1111
* It is responsible for reading and loading the contents of a given file.
1212
*/
1313
public class FileLoader {
@@ -51,9 +51,7 @@ public String loadData() {
5151

5252
/**
5353
* Sets the path of the file to be loaded, to the given value.
54-
*
55-
* @param fileName
56-
* The path of the file to be loaded.
54+
* @param fileName The path of the file to be loaded.
5755
*/
5856
public void setFileName(String fileName) {
5957
this.fileName = fileName;

model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import javax.swing.JTextField;
1515

1616
/**
17-
* This class is the GUI implementation of the View component In the
17+
* This class is the GUI implementation of the View component in the
1818
* Model-View-Presenter pattern.
1919
*/
2020
public class FileSelectorJFrame extends JFrame implements FileSelectorView,

model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorPresenter.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Every instance of this class represents the Presenter component in the
55
* Model-View-Presenter architectural pattern.
6-
*
6+
* <p>
77
* It is responsible for reacting to the user's actions and update the View
88
* component.
99
*/
@@ -21,19 +21,15 @@ public class FileSelectorPresenter {
2121

2222
/**
2323
* Constructor
24-
*
25-
* @param view
26-
* The view component that the presenter will interact with.
24+
* @param view The view component that the presenter will interact with.
2725
*/
2826
public FileSelectorPresenter(FileSelectorView view) {
2927
this.view = view;
3028
}
3129

3230
/**
33-
* Sets the FileLoader object, to the value given as parameter.
34-
*
35-
* @param loader
36-
* The new FileLoader object(the Model component).
31+
* Sets the {@link FileLoader} object, to the value given as parameter.
32+
* @param loader The new {@link FileLoader} object(the Model component).
3733
*/
3834
public void setLoader(FileLoader loader) {
3935
this.loader = loader;

model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorStub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/**
44
* Every instance of this class represents the Stub component in the
55
* Model-View-Presenter architectural pattern.
6-
*
6+
* <p>
77
* The stub implements the View interface and it is useful when we want the test
88
* the reaction to user events, such as mouse clicks.
9-
*
9+
* <p>
1010
* Since we can not test the GUI directly, the MVP pattern provides this
1111
* functionality through the View's dummy implementation, the Stub.
1212
*/

model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorView.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public interface FileSelectorView {
2323

2424
/**
2525
* Sets the presenter component, to the one given as parameter.
26-
*
27-
* @param presenter
28-
* The new presenter component.
26+
* @param presenter The new presenter component.
2927
*/
3028
public void setPresenter(FileSelectorPresenter presenter);
3129

@@ -36,9 +34,7 @@ public interface FileSelectorView {
3634

3735
/**
3836
* Sets the file's name, to the value given as parameter.
39-
*
40-
* @param name
41-
* The new name of the file.
37+
* @param name The new name of the file.
4238
*/
4339
public void setFileName(String name);
4440

@@ -49,17 +45,13 @@ public interface FileSelectorView {
4945

5046
/**
5147
* Displays a message to the users.
52-
*
53-
* @param message
54-
* The message to be displayed.
48+
* @param message The message to be displayed.
5549
*/
5650
public void showMessage(String message);
5751

5852
/**
5953
* Displays the data to the view.
60-
*
61-
* @param data
62-
* The data to be written.
54+
* @param data The data to be written.
6355
*/
6456
public void displayData(String data);
6557
}

0 commit comments

Comments
 (0)
X Tutup