0
OCM Java
Developer
美商甲骨文
授權教育訓練中心
講師
張益裕
OCM Java 開發⼈人員認證
與
設計模式
Sun Java Certification
Advanced

Specialty

Sun Certified Enterprise Architect (SCEA)

Sun Certified
Java Developer
(SCJD)
...
Oracle Certification Program Categories

Oracle
Certified
Associate

Oracle
Certified
Professional

Oracle
Certified
Master...
Oracle Java Certification
Java SE 6 Developer
Java EE 6 Web
Component Developer

Java SE 5 Programmer
Java SE 6 Programmer
...
Oracle Certified Master

Java SE 6 Developer
Certification Path
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM
Get Certified Step 1
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM

Oracle Ce...
Get Certified Step 2
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM

Complete ...
Get Certified Step 3
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM

1Z0-855
J...
Get Certified Step 4
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM

1Z0-856
J...
Get Certified Step 5
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM

Complete ...
Oracle Certified Master
Prior Certification
Complete Training
Complete Assignment

Complete Essay
Complete Form
OCM
Step 3 - Assignment
•

Exam Number: 1Z0-855

•

Duration: 6 months from assignment purchase

•

BOTH assignment and essay ...
Assignment Exam Topics
•

A graphical user interface demonstrating good
principles of design

•

A network connection, usi...
Step 4 - Essay
•

Exam Number: 1Z0-856

•

Duration: 120 minutes

•

BOTH assignment and essay must be submitted
within 6 ...
Essay Exam Topics
•

List some of the major choices you must make
during the implementation of the above.

•

List some of...
Assignment Implementation
Command
Factory Method Decorator
Strategy Observer Composite
Model-View-Controller
Singleton DAO
Breakfast Shop
Domain Object

Breakfast
{abstract}
#name:String
+getName():String
+price():double

Hamburger

Sandwich

EggCake

+price()...
Breakfast and Sandwich
public abstract class Breakfast {
protected String name = "Unknown";

!

!

public String getName()...
Too Much Subclass
Breakfast
{abstract}
#name:String
+getName():String
+price():double

Hamburger

Sandwich

EggCake

+pric...
Move to Super Class
public abstract class Breakfast {
protected String name = "Unknown";

Breakfast
{abstract}
#name:Strin...
Move to Super Class
Breakfast
{abstract}
#name:String
#egg:boolean
#ham:boolean
#corn:boolean
#lettuce:boolean
+getName():...
老老闆,我要㆒㈠㊀一個㆔㈢㊂三明治,
加兩兩個蛋,㆔㈢㊂三片㈫㊋火腿,兩兩
份生菜,這樣要多少錢?

...
老老闆

客㆟人
Move to Super Class

Breakfast
{abstract}
...
#chocolateSauce:boolean
#peanutSauce:boolean
#cream:boolean
...

Waffle
+pri...
java.io
Chaining Stream Together

Reader reader =
new BufferedReader(
new InputStreamReader(
new FileInputStream("Decorator.txt"))...
Chaining Stream Together

read()

read()

read()
FileInputStream

InputStreamReader
BufferedReader
APP

APP

Hello! Simon!

Intranet

APP
@^*#%!*&

Internet
Java I/O API

InputStream
{abstract}

FileInputStream

FilterInputStream

BufferedInputStream

MyInputStream
Chaining Stream Together
public class MyInputStream extends FilterInputStream {
public MyInputStream(InputStream is) {
sup...
Chaining Stream Together
InputStream is =
new BufferedInputStream(
new FileInputStream("readme.txt"));
!
// send to intran...
Chaining Stream Together

read()

read()

read()
FileInputStream

MyInputStream
BufferedInputStream
Back to Breakfast Shop
Java I/O and Breakfast
Breakfast
InputStream
{abstract}

Sandwich...

FileInputStream

FilterInputStream

BufferedInputStr...
Breakfast Structure
Breakfast
{abstract}
#name:String
+getName():String
+price():double

Hamburger

Sandwich

+price():dou...
Breakfast

public abstract class Breakfast {
!
protected String name = "Unknown";
!
public String getName() {
return name;...
Sandwich

public class Sandwich extends Breakfast {
public Sandwich() {
name = "三明治";
}
!
public int price() {
return 15;
...
Ingredient

public abstract class Ingredient extends Breakfast {
!
public abstract String getName();
!
}
Breakfast and Ingredient
public abstract class Breakfast {
!
protected String name = "Unknown";
!
public String getName() ...
Ingredient - Egg
public class Egg extends Ingredient {
Breakfast breakfast;
!
public Egg(Breakfast breakfast) {
this.break...
Ingredient - Ham
public class Ham extends Ingredient {
Breakfast breakfast;
!
public Ham(Breakfast breakfast) {
this.break...
Chaining Breakfast Together

+

Breakfast breakfast = new Sandwich();
breakfast = new Ham(breakfast);

+

breakfast = new ...
Chaining Breakfast Together

getPrice()

getPrice()

getPrice()
Sandwich

Ham
Egg
老老闆,我要㆒㈠㊀一個㆔㈢㊂三明治,
加兩兩個蛋,㆔㈢㊂三片㈫㊋火腿,兩兩
份生菜,這樣要多少錢?

ok!這樣
是110元

老老闆

客㆟人
A Sandwich with many Ingredients

X2
X3
X2

Breakfast
!
!
breakfast
breakfast
!
breakfast
breakfast
breakfast
!
breakfast
...
Decorator Pattern
•

⺫⽬目的!
•

•

別名!
•

•

提供附加的功能給物件,不⽤用修改原來的程式碼就可以增加功能

Wrapper

時機!
•
•

希望增加物件的功能時,仍然可以保留物件原來的特性

•

不...
Decorator Pattern
Component
{abstract}
operation()

ConcreteComponent
+operation()

Decorator
{abstract}
+operation()

Con...
Note
* Design pattern好像不不是那麼難
* 如果因為物件會㈲㊒有許多不不同的樣子而讓繼承架構太大的話,就

可以試試Decorator
ast
Breakf act}
{abstr

* 套用Decorator
1. 先不不...
macdidi5@gmail.com

張益裕
JCD 2013 OCM Java Developer
JCD 2013 OCM Java Developer
Upcoming SlideShare
Loading in...5
×

JCD 2013 OCM Java Developer

152

Published on

OCM Java Developer認證長久以來被技術人員忽略,可能因為它是一個需要實作應用程式的考試,不像其它認證都是採用選擇題的考試方式,所以Oracle把它歸類在大師的等級。應考人員依照考題的規定實作一個應用程式,從分析、設計到實作,需要把基本的設計模式套用在這個專題,這對一個比較沒有經驗的開發人員來說,會是比較困難一些的。所以在這個專題演講中,也會針對基本的設計模式的應用,使用清楚與容易的方式,讓大家可以輕鬆的進入設計模式的世界。

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
152
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "JCD 2013 OCM Java Developer"

  1. 1. OCM Java Developer 美商甲骨文 授權教育訓練中心 講師 張益裕
  2. 2. OCM Java 開發⼈人員認證 與 設計模式
  3. 3. Sun Java Certification Advanced Specialty Sun Certified Enterprise Architect (SCEA) Sun Certified Java Developer (SCJD) Sun Certified Web Component Developer (SCWCD) Sun Certified Business Component Developer (SCBCD) Sun Certified Developer for Java Web Service (SCDJWS) Foundation Sun Certified Java Programmer (SCJP) Entry Level Sun Certified Mobile Application Developer (SCMAD) Sun Certified Java Associate (SCJA) Java SE Java EE Java ME
  4. 4. Oracle Certification Program Categories Oracle Certified Associate Oracle Certified Professional Oracle Certified Master Oracle Certified Expert Oracle Certified Specialist
  5. 5. Oracle Java Certification Java SE 6 Developer Java EE 6 Web Component Developer Java SE 5 Programmer Java SE 6 Programmer Java SE 7 Programmer Java SE 7 Programmer Oracle Certified Associate Oracle Certified Professional Oracle Certified Master Oracle Certified Expert
  6. 6. Oracle Certified Master Java SE 6 Developer
  7. 7. Certification Path Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM
  8. 8. Get Certified Step 1 Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM Oracle Certified Professional Java SE 5, 6, 7 Programmer ! Sun Certified Java Programmer Any Edition
  9. 9. Get Certified Step 2 Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM Complete one of approved courses Instructor-led in class, Recorded courses (LWC, LVC, Training On-Demand)
  10. 10. Get Certified Step 3 Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM 1Z0-855 Java SE 6 Developer Certified Master Assignment
  11. 11. Get Certified Step 4 Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM 1Z0-856 Java SE 6 Developer Certified Master Essay Exam
  12. 12. Get Certified Step 5 Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM Complete the Course Submission Form
  13. 13. Oracle Certified Master Prior Certification Complete Training Complete Assignment Complete Essay Complete Form OCM
  14. 14. Step 3 - Assignment • Exam Number: 1Z0-855 • Duration: 6 months from assignment purchase • BOTH assignment and essay must be submitted within 6 months of assignment purchase date. No exceptions • Assignment must be submitted before you can register for the essay
  15. 15. Assignment Exam Topics • A graphical user interface demonstrating good principles of design • A network connection, using a specified protocol, to connect to an information server • A network server, which connects to a previously specified Java technology database • A database, created by extending the functionality of a previously written piece of code, for which only limited documentation is available
  16. 16. Step 4 - Essay • Exam Number: 1Z0-856 • Duration: 120 minutes • BOTH assignment and essay must be submitted within 6 months of assignment purchase date. No exceptions • Assignment must be submitted before you can register for the essay
  17. 17. Essay Exam Topics • List some of the major choices you must make during the implementation of the above. • List some of the main advantages and disadvantages of each of your choices. • Briefly justify your choices in terms of the comparison of design and implementation objectives with the advantages and disadvantages of each
  18. 18. Assignment Implementation Command Factory Method Decorator Strategy Observer Composite Model-View-Controller Singleton DAO
  19. 19. Breakfast Shop
  20. 20. Domain Object Breakfast {abstract} #name:String +getName():String +price():double Hamburger Sandwich EggCake +price():double +price():double +price():double
  21. 21. Breakfast and Sandwich public abstract class Breakfast { protected String name = "Unknown"; ! ! public String getName() { return name; } public abstract int price(); } public class Sandwich extends Breakfast { public Sandwich() { name = "三明治"; } ! @Override public int price() { return 15; } }
  22. 22. Too Much Subclass Breakfast {abstract} #name:String +getName():String +price():double Hamburger Sandwich EggCake +price():double +price():double +price():double SandwichWithCorn HamburgerWithEgg +price():double +price():double HamburgerWithLettuce +price():double HamburgerWithHam +price():double EggCakeWithHam +price():double EggCakeWithLettuce SandwichWithEgg +price():double +price():double SandwichWithHam SandwichWithLettuce +price():double +price():double
  23. 23. Move to Super Class public abstract class Breakfast { protected String name = "Unknown"; Breakfast {abstract} #name:String #egg:boolean #ham:boolean #corn:boolean #lettuce:boolean +getName():String +price():double ! ! ! protected protected protected protected boolean boolean boolean boolean ... public int price() { int result = 0; if (egg) { result += 10; } else if (ham) { result += 15; } else if (corn) { result += 10; } else if (lettuce) { result += 20; } ! return result; } } egg; ham; corn; lettuce;
  24. 24. Move to Super Class Breakfast {abstract} #name:String #egg:boolean #ham:boolean #corn:boolean #lettuce:boolean +getName():String +price():double Sandwich +price():double public class Sandwich extends Breakfast { public Sandwich() { name = "三明治"; } ! @Override public int price() { return super.price() + 15; } }
  25. 25. 老老闆,我要㆒㈠㊀一個㆔㈢㊂三明治, 加兩兩個蛋,㆔㈢㊂三片㈫㊋火腿,兩兩 份生菜,這樣要多少錢? ... 老老闆 客㆟人
  26. 26. Move to Super Class Breakfast {abstract} ... #chocolateSauce:boolean #peanutSauce:boolean #cream:boolean ... Waffle +price():double EggCake +price():double
  27. 27. java.io
  28. 28. Chaining Stream Together Reader reader = new BufferedReader( new InputStreamReader( new FileInputStream("Decorator.txt"))); ! int c; ! while ((c = reader.read()) != -1) { System.out.print((char)c); }
  29. 29. Chaining Stream Together read() read() read() FileInputStream InputStreamReader BufferedReader
  30. 30. APP APP Hello! Simon! Intranet APP @^*#%!*& Internet
  31. 31. Java I/O API InputStream {abstract} FileInputStream FilterInputStream BufferedInputStream MyInputStream
  32. 32. Chaining Stream Together public class MyInputStream extends FilterInputStream { public MyInputStream(InputStream is) { super(is); } ! @Override public int read() throws IOException { int data = super.read(); if (data != -1) { data = data + myMagicCode(); } return data; } } ...
  33. 33. Chaining Stream Together InputStream is = new BufferedInputStream( new FileInputStream("readme.txt")); ! // send to intranet InputStream is = new BufferedInputStream( new MyInputStream( new FileInputStream("readme.txt"))); ! // send to internet
  34. 34. Chaining Stream Together read() read() read() FileInputStream MyInputStream BufferedInputStream
  35. 35. Back to Breakfast Shop
  36. 36. Java I/O and Breakfast Breakfast InputStream {abstract} Sandwich... FileInputStream FilterInputStream BufferedInputStream Ham Ingredient MyInputStream Egg
  37. 37. Breakfast Structure Breakfast {abstract} #name:String +getName():String +price():double Hamburger Sandwich +price():double +price():double Ingredient +getName():String Ham -breakfast:Breakfast +getName():String +price():double Egg -breakfast:Breakfast +getName():String +price():double
  38. 38. Breakfast public abstract class Breakfast { ! protected String name = "Unknown"; ! public String getName() { return name; } ! public abstract int price(); }
  39. 39. Sandwich public class Sandwich extends Breakfast { public Sandwich() { name = "三明治"; } ! public int price() { return 15; } }
  40. 40. Ingredient public abstract class Ingredient extends Breakfast { ! public abstract String getName(); ! }
  41. 41. Breakfast and Ingredient public abstract class Breakfast { ! protected String name = "Unknown"; ! public String getName() { return name; } ! public abstract int price(); } public abstract class Ingredient extends Breakfast { ! public abstract String getName(); ! }
  42. 42. Ingredient - Egg public class Egg extends Ingredient { Breakfast breakfast; ! public Egg(Breakfast breakfast) { this.breakfast = breakfast; } ! public String getName() { return breakfast.getName() + "加蛋"; } ! public int price() { return 10 + breakfast.price(); } }
  43. 43. Ingredient - Ham public class Ham extends Ingredient { Breakfast breakfast; ! public Ham(Breakfast breakfast) { this.breakfast = breakfast; } ! public String getName() { return "⽕火腿" + breakfast.getName(); } ! public int price() { return 15 + breakfast.price(); } }
  44. 44. Chaining Breakfast Together + Breakfast breakfast = new Sandwich(); breakfast = new Ham(breakfast); + breakfast = new Egg(breakfast);
  45. 45. Chaining Breakfast Together getPrice() getPrice() getPrice() Sandwich Ham Egg
  46. 46. 老老闆,我要㆒㈠㊀一個㆔㈢㊂三明治, 加兩兩個蛋,㆔㈢㊂三片㈫㊋火腿,兩兩 份生菜,這樣要多少錢? ok!這樣 是110元 老老闆 客㆟人
  47. 47. A Sandwich with many Ingredients X2 X3 X2 Breakfast ! ! breakfast breakfast ! breakfast breakfast breakfast ! breakfast breakfast breakfast = new Sandwich(); = new Egg(breakfast); = new Egg(breakfast); = new Ham(breakfast); = new Ham(breakfast); = new Ham(breakfast); = new Lettuce(breakfast); = new Lettuce(breakfast);
  48. 48. Decorator Pattern • ⺫⽬目的! • • 別名! • • 提供附加的功能給物件,不⽤用修改原來的程式碼就可以增加功能 Wrapper 時機! • • 希望增加物件的功能時,仍然可以保留物件原來的特性 • 不希望繼承架構過於龐⼤大 • • 想要在執⾏行時期增加物件額外的功能,但是不會影響到其它物件 不希望⼦子類別繼承⼀一些不會使⽤用到的特性 效果! • ⽐比繼承架構更靈活。繼承是「編譯時期」的作法;Decorator是「執⾏行時期」的作法 • 在應⽤用程式運作的時候物件可能會太多
  49. 49. Decorator Pattern Component {abstract} operation() ConcreteComponent +operation() Decorator {abstract} +operation() ConcreteDecorationA addedState +operation() ConcreteDecorationB addedState +operation()
  50. 50. Note * Design pattern好像不不是那麼難 * 如果因為物件會㈲㊒有許多不不同的樣子而讓繼承架構太大的話,就 可以試試Decorator ast Breakf act} {abstr * 套用Decorator 1. 先不不考慮那些「不不同的樣子」, 把簡單的架構設計出來來 ge Hambur r Sa ndwich 2. 為那些「不不同的樣子」設計㆒㈠㊀一個 父類類別,加入㆖㊤上面的繼承架構㆗㊥中, 這個類類別就是Decorator 3. 為「不不同的樣子」設計Decorator 的子類類別 * 好像會㈲㊒有很多物件... EggCak e Ingredient {abstract} Ham Egg Corn Lettuce ...
  51. 51. macdidi5@gmail.com 張益裕
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×