1 / 16

Web Application Framework with MVC

Web Application Framework with MVC. Outline. เปรียบเทียบ Web App. Framework Ruby On Rails คืออะไร Ruby On Rails with MVC การทำงานของ Ruby On Rails Flow MVC ของ Ruby On Rails. Framework Web Application Framework MVC คืออะไร ส่วนประกอบของ MVC การทำงานร่วมกันของ MVC

kristine
Télécharger la présentation

Web Application Framework with MVC

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. Web Application Framework with MVC

  2. Outline • เปรียบเทียบ Web App. Framework • Ruby On Rails คืออะไร • Ruby On Rails with MVC • การทำงานของ Ruby On Rails • Flow MVC ของ Ruby On Rails • Framework • Web Application Framework • MVC คืออะไร • ส่วนประกอบของ MVC • การทำงานร่วมกันของ MVC • ตัวอย่าง Web App. Framework

  3. Framework • เป็นโครงสร้างที่สนับสนุน Software ซึ่งถูกสร้างด้วยนักพัฒนา หรือองค์กร • ประกอบไปด้วย program, code library, scripting language หรือ Software อื่นที่ช่วยในการพัฒนา • Software เหล่านี้มีหน้าที่แตกต่างกัน แต่สามารถทำงานร่วมกันได้อย่างสอดคล้อง

  4. Web Application Framework • เป็นกลุ่มของ Sofeware ที่ช่วยในการพัฒนา Web Application ให้ง่ายและรวดเร็วขึ้น • โดยได้มีการรวบรวมโปรแกรมหลักที่จำเป็นในการพัฒนาไว้ด้วยกัน เช่น การเข้าถึงฐานข้อมูล(Database Access) ,การสร้าง template หรือการจัดการ session เป็นต้น

  5. MVC (Model-View-Controller) คืออะไร • เป็นสถาปัตยกรรมซอฟแวร์ (software architecture) ที่มีการแบ่งแยกระบบออกเป็น 3 ส่วนหลักๆ ได้แก่ data model, user interface, and control logic ซึ่งทั้ง 3 ส่วนนี้มีการทำงานร่วมกัน • การพัฒนางานด้วยรูปแบบ MVC นี้มักพบในการพัฒนางานประเภท framework เนื่องจากมีการแยกส่วนการทำงาน จึงง่ายต่อการนำไปพัฒนาต่อ หาก programmer รู้และเข้าใจ concept ของ MVC

  6. ส่วนประกอบของ MVC Modelเป็นส่วนที่ทำงานติดต่อกับ database จัดการข้อมูลเข้า-ออก เพื่อนำไปประมวลผลต่อไป Viewเป็นส่วนของการแสดงผลทาง Web browser อยู่ในรูปแบบของ HTML ซึ่งนำข้อมูลที่ได้มาจาก Model มาแสดงผลที่นี่ Controller เป็นส่วนของการประมวลผลหลักของระบบ ติดต่อกับ Web browser (user action) เพื่อส่งต่อให้ Model หรือ View ทำงานต่อไป

  7. การทำงานร่วมกันของ MVC จะเห็นว่า controller จะเป็นส่วนที่คอยรับคำสั่งจาก web browser (user) หากต้องการ query ข้อมูล จาก DB. Controller จะส่งต่อให้ Model ไปดึงข้อมูลออกมา Model ดึงข้อมูลออกมา ส่งไปที่ view เพื่อแสดงผลออกทาง web browser ตามลำดับ

  8. ตัวอย่าง Web Application Framework with MVC

  9. เปรียบเทียบ Web Application Framework with MVC

  10. Ruby On Rails คืออะไร Ruby คืออะไร • เป็นภาษา script object orientedที่มีลักษณะเป็นโปรแกรมแปลภาษา (interpreter) เหมือนกับ Perl, Python,Java • เป็นภาษาที่มี Syntax ที่สั้น กระชับ ไม่ซับซ้อน Ruby On Rails คืออะไร • เป็นโอเพนซอร์ส web application framework ที่พัฒนาด้วยภาษา Ruby • พัฒนาด้วย MVC architecture

  11. Ruby On Railswith MVC การเขียนโปรแกรมด้วย Ruby On Rails มีการใช้ Concept ของ MVC ดังนี้ Model • มีการติดต่อกับ Active Record เพื่อช่วยจัดการงานด้าน Database • ดูแลในเรื่องของการติดต่อสื่อสารระหว่าง Object และ Database โดยที่ ผู้พัฒนาไม่ต้องยุ่งยากกับการใช้ SQL command • เป็นงานด้านการตรวจสอบความสัมพันธ์ของข้อมูล มีผลกับฐานข้อมูล • Handles validation(ตรวจสอบความถูกต้อง), association(ความสัมพันธ์ระหว่างฐานข้อมูล), transactions, and more…

  12. Ruby On Railswith MVC View • เป็นส่วนที่ต้องแสดงผลผ่าน web browser • เขียนด้วยพื้นฐานของ HTML(.rhtml), แทรกด้วย script ของ ruby คล้าย PHP,JSP,ASP • การทำงานสัมพันธ์อยู่กับ controller • นำ component มาใช้ใหม่ได้ (Reusable)

  13. Ruby On Railswith MVC Controller • เป็นส่วนที่ทำงานเป็นอันดับแรกเมื่อมีโปรแกรมถูกเรียก จาก Web browser • เป็นส่วนที่ติดต่อการทำงานระหว่างผู้ใช้และโปรแกรม • มีการติดต่อกับ Database(ฐานข้อมูล) ด้วย Model และแสดงผลข้อมูลผ่านทาง View • เป็นส่วนที่มีการประมวลผลหลัก ของโปรแกรม

  14. การทำงานของ Ruby On Rails

  15. store.rhtml <html>… </html> index.rhtml <html>…</html> Views Layouts Flow MVC ของ Ruby On Rails 2 http://127.0.0.1:3000/store/index 1 store_controller.rb 3 def index…end 11 8 Controllers Layouts 10 7 4 - CSS- JS- Image- XML Product.rb 9 Database 5 • SQL- Validation- Association- Callback Database.yml Table : products 6 Models (Active Records)

  16. เอกสารอ้างอิง • www.rubyonrails.org • http://www.onlamp.com/pub/a/onlamp/2005/01/20... • http://www.isriya.com/node/908 • http://www.catalystframework.org/ • http://en.wikipedia.org/wiki/Framework • http://en.wikipedia.org/wiki/List_of_web_application_frameworks • http://www.phpit.net/article/ten-different-php-frameworks • http://wiki.nectec.or.th/giti/Knowledge/RubyOnRails

More Related