Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9f6030c

Browse files
template pattern
design with reactJS component concept
1 parent 1e4cd1e commit 9f6030c

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

‎design-pattern/template/Component.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package sdp.template;
2+
3+
/**
4+
*
5+
* @author rafiul islam
6+
*/
7+
public abstract class Component {
8+
protected abstract void onCreate();
9+
protected abstract void onStart();
10+
protected abstract void onDestroy();
11+
12+
public void render(){
13+
onCreate();
14+
onStart();
15+
System.out.println("component rendering...");
16+
onDestroy();
17+
System.out.println();
18+
}
19+
}

‎design-pattern/template/Main.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package sdp.template;
2+
3+
/**
4+
*
5+
* @author rafiul islam
6+
*/
7+
public class Main {
8+
public static void main(String[] args) {
9+
Component reactMessageBox = new MessageBox();
10+
reactMessageBox.render();
11+
12+
Component reactNotificationBox = new NotificationBox();
13+
reactNotificationBox.render();
14+
}
15+
}

‎design-pattern/template/MessageBox.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package sdp.template;
2+
3+
/**
4+
*
5+
* @author rafiul islam
6+
*/
7+
public class MessageBox extends Component{
8+
@Override
9+
public void onCreate(){
10+
System.out.println("onCreate: message component");
11+
}
12+
13+
@Override
14+
public void onStart(){
15+
System.out.println("onStart: message component");
16+
}
17+
18+
@Override
19+
public void onDestroy(){
20+
System.out.println("onDestroy: message component");
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package sdp.template;
2+
3+
/**
4+
*
5+
* @author rafiul islam
6+
*/
7+
public class NotificationBox extends Component{
8+
@Override
9+
public void onCreate(){
10+
System.out.println("onCreate: notification component");
11+
}
12+
13+
@Override
14+
public void onStart(){
15+
System.out.println("onStart: notification component");
16+
}
17+
18+
@Override
19+
public void onDestroy(){
20+
System.out.println("onDestroy: notification component");
21+
}
22+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /