1 / 27

ทำโปรเจคเป็นทีม

ทำโปรเจคเป็นทีม. ทำโปรเจคเป็นทีม. สอนไม่ได้ … ลองฝึกทำดีกว่า แต่ …. เทคนิคเขียนโปรแกรมด้วยกัน(หลายๆคน). เป้าหมาย : เขียนโปรแกรมแต่ละส่วนไปพร้อมๆ กันได้. Def: ซุย = มั่วไปเรื่อยๆ (นิยามโดย argen ). 1. ซุยโลด. เขียนทุกอย่างไว้ในไฟล์เดียว โปรแกรมเวิร์ค แต่..... เพื่อนนั่งทำตาปริบๆ.

liko
Download Presentation

ทำโปรเจคเป็นทีม

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ทำโปรเจคเป็นทีม

  2. ทำโปรเจคเป็นทีม • สอนไม่ได้… • ลองฝึกทำดีกว่า • แต่….

  3. เทคนิคเขียนโปรแกรมด้วยกัน(หลายๆคน)เทคนิคเขียนโปรแกรมด้วยกัน(หลายๆคน)

  4. เป้าหมาย: เขียนโปรแกรมแต่ละส่วนไปพร้อมๆ กันได้

  5. Def: ซุย = มั่วไปเรื่อยๆ (นิยามโดย argen) 1. ซุยโลด • เขียนทุกอย่างไว้ในไฟล์เดียว • โปรแกรมเวิร์ค • แต่..... • เพื่อนนั่งทำตาปริบๆ

  6. 2. ออกแบบดีๆ • เอาความรู้ OOP มาใช้ • แบ่งโปรแกรมออกเป็นหลายส่วน YellowPages . . . แห แหวน – 0812222 แห้ว – 08112341 แหงะ - 0000012 Search(name : string) : string[] . . . ก ข A

  7. class YellowPages { // อาจต้องประกาศค่าเพิ่มเติม public YellowPages() { // โหลดข้อมูล..... } public string[] Search(string name) { // หลับหูหลับตาค้นมาให้จงได้ return ……; } } ข

  8. SearchButton_Click() { YellowPages yp = new YellowPages(); string[] result = yp.Search(textBox1.Text); for(int i = 0; i < result.Length; i++) listBox1.Items.Add(result[i]); } ก

  9. SearchButton_Click() { // YellowPages yp = new YellowPages(); // string[] result = yp.Search(textBox1.Text); string[] result = {“nancy - 081xx”, “lula – 089xx”}; for(int i = 0; i < result.Length; i++) listBox1.Items.Add(result[i]); } ก

  10. 2. ออกแบบดีๆ • ตัวอย่างการออกแบบโปรแกรมดีๆ ซักอัน (ไม่ต้องเป็น UML ก็ได้)

  11. 2. ออกแบบดีๆ • ดูตัวอย่างโปรแกรมชาวบ้าน ที่ Open source • สอนไม่ไหว.... • ออกแบบโปรแกรมไม่เก่งเหมือนกัน • งั้น?

  12. 3. ซุยหลายฟอร์ม • ทำคนละฟอร์ม(หรือมากกว่า) แหวน แห 0812222 แหวน – 0812222 แห้ว – 08112341 แหงะ - 0000012 ใต้สะพานข้ามแยก เกษตร ข ก

  13. 3. ซุยหลายฟอร์ม SearchButton_Click() { Form2 info = new Form2(); info.Show(); info.DisplayInfo(“แหวน”); } Form1 Form2 public void DisplayInfo(string name) { // do something }

  14. ทบทวน: Object is pass-by-reference void StormSeeker(Hero x) { x.HP = x.HP - 200; } class Hero { public int HP; ... } Hero skelKing = new Hero(); skelKing.HP = 100; StormSeeker(skelKing); skelKing.HP = ??

  15. 4. ซุยลงแขก

  16. 4. ซุยลงแขก • 2 คน 1 ฟอร์ม Chat Client Demonstration!

  17. Chat Client Chat Server ChatAPI.GetMessage() ChatAPI.PostMessage()

  18. ChatAPI.GetMessage(); • คืนค่าเป็น array ของ 20 ข้อความล่าสุด • 1 string = 1 ข้อความ string[] msgs = ChatAPI.GetMessage(); msgs[0] == "118>nattster>สวัสดีครับน้องๆ ทุกคน" msgs[1] == "119>nattster>นี่คือโจทย์ Chatroom Client" msgs[2] == "120>b4lmung>ข้าคือ maid guy" msgs[3] == "121>nattster>@b4lmung มา maidguy อะไรกันแถวนี้ :P“ …

  19. ChatAPI.PostMessage(name, message); • name = ชื่อคนส่งข้อความ • message = ข้อความ • คืนค่าเป็น enum ชื่อ Response • Response.OK ส่งข้อความเรียบร้อย

  20. textBox1 listBox1 ก ข UserList ChatBox ทุกๆ 2 วินาที Update(ListBox ulist) . . . Update(TextBox mtext) . . .

  21. class ChatBox { public void Update(TextBox mtext) { mtext.Text = “นี่คือข้อความจ๊ะ”; } }

  22. ไปลองทำกันได้แล้ว... ใช้ SVN ด้วยนะ ซุยโลด, ออกแบบดีๆ, ซุยหลายฟอร์ม, ซุยลงแขก

  23. หนทางสู่สุดยอด Chat Client

  24. UserList • แสดงว่าส่งแล้วกี่ข้อความ • แสดงว่าส่งครั้งล่าสุดเมื่อไหร่(วัน+เวลา) • ถ้าไม่ได้ส่งข้อความเลย ในช่วง 5 นาทีที่ผ่านมา ให้ลบออกจาก List • แปลว่าไม่ได้ chat แล้ว

  25. MessageList • แสดงข้อความจากห้อง…..เท่านั้น • “#dota นี่คือห้อง dota ข้อความทุกอันที่ปะหน้าว่า #dota แปลว่าคุยในห้องนี้” • เปลี่ยนไปใช้ RichTextBox • ใส่สีสันให้ข้อความ • /yellow นี่คือข้อความสีเหลือง • /red นี่คือข้อความสีแดง

  26. Chat ได้หลายหน้าต่าง(พร้อมกัน) • เราอาจเปิดหลายๆ หน้าต่างสำหรับห้องแต่ละห้อง

  27. สร้างฟอร์ม Chat กันสองต่อสอง • สมมติว่า nattster จะคุยกับ b4lmung อาจส่งข้อความหากันแบบนี้ nattster: @b4lmung หวัดดี b4lmung: @nattster บูชาเมดเถอะลูก nattster: @b4lmung สาธุ! • ทำหน้าต่างแสดงเฉพาะข้อความระหว่างเราสองคน • (เว่อร์)เข้ารหัสข้อความ

More Related