1. Trang chủ
  2. » Thể loại khác

CÔNG NGHỆ PHẦN MỀM Chương Thiết kế phần mềm

67 34 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

TRƯỜNG ĐẠI HỌC CÔNG NGHIỆP TP.HCM MÔN HỌC CÔNG NGHỆ PHẦN MỀM Chương Thiết kế phần mềm CNPM/NN Thiết kế phần mềm Thiết kế? Thiết kế mơ hình hệ thống Thiết kế điều khiển Thiết kế Module Các mẫu thiết kế CNPM/NN CNPM/NN Thiết kế? CNPM/NN Thiết kế gì?   Thiết kế tạo biểu diễn hay mơ hình phần mềm hướng thực thi Mơ hình thiết kế cung cấp thơng tin kiến trúc (architecture), Giao tiếp (interfaces), thành phần (components) liệu (data) CNPM/NN hướng thiết kế Hướng dẫn thiết kế  Một thiết kế phải đưa kiến trúc mà      Dùng mẫu (pattern) hay kiểu (style) kiến trúc thừa nhận Gồm thành phần (component) có đặc trưng thiết kế tốt Có thể thi hành theo cách tiến hóa Thiết kế phải có tính module, thiết kế phải đưa thành phần mà độc lập chức Thiết kế đưa từ việc dùng phương pháp lặp CNPM/NN Kiến trúc (Architecture)?     Kiến trúc phần mềm tổ chức có tính hệ thống chứa thành phần, mối quan hệ lẫn thành phần thành phần với mơi trường, chứa đựng nguyên lý định hướng cho việc thiết kế tiến hóa kiến trúc Kiến trúc có tính tổng thể Kiến trúc cho ta hình ảnh hệ thống phần mềm Module hệ thống (sub-systems):   CNPM/NN Module thành phần hệ thống mà cung cấp dịch vụ cho thành phần khác không xem hệ thống riêng biệt Một hệ thống hoạt động có tính độc lập cao customer requirements "four bedrooms, three baths, lots of glass " architectural design Kiến trúc CNPM/NN Ví dụ : ACD (Architectural Context Diagram) SafeHome Superordinate systems Safehome product Internet-based system Used by Peers Control panel Target system: Security function Surveillance system uses Homeowner uses Actors Depends on Sensors Sensors Subordinate systems 10 Mã Singleton class Singleston { private static Singleston instance; protect Singleston () {} public static Singleston Instance() { if (instance==null) instance = new Singleston (); return instance; } } 53 Mẫu thiết kế Observer  Bài toán thực tế: Một đối tượng thời gian để đếm thể nhiều hình thức đồng hồ số, đồng hồ kim… Ta   54 Dễ dàng thêm, bớt nhiều đối tượng thể Khi tay đổi đối tượng thời gian tất thể thời gian thay đổi theo CNPM/NN Mơ hình Observer Relative Percentages A B C D X 15 35 35 15 Y 10 40 30 20 A D B C Z 10 40 30 20 A Change notification Requests, modifications B A=10% B=40% C=30% D=20% C D Application data Ví dụ Observer Subject * Update() Attach(Observer) Detach(Observer) Notify() ClockTimer DigitalClock ClockTimer *sub; Update() Draw() 56 AnalogClock ClockTimer *sub; Update() Draw() ADAPTER   Tái sử dụng lớp giao diện (interface) khơng tương thích Có vấn đề khơng tương thích tiềm tàng Biểu đồ lớp Client - unaltered Pay Processor printPay (Weekly Employee e) Target -unaltered WeeklyEmployee getPay() getName() MonthlyAdapter MonthlyEmployee : me getPay() getName() Adaptor Contains an adaptee object Provides own implementation of target’s methods – which call adaptee’s methods MonthlyEmployee getMonthlyPay() getEmployeeName() Adaptee unaltered MonthlyAdapter public class MonthlyAdapter extends WeeklyEmployee { private MonthlyEmployee me; //composed with adaptee //created with adaptee object public MonthlyAdapter(MonthlyEmployee memp) { me = memp; } //own implementation of target method, //adapting to use adaptee’s instead public String getName() { return me.getEmployeeName(); } public int getPay() { return me.getMonthlyPay(); } } Test class Test { public static void main(String arg[]) { WeeklyEmployee we = new WeeklyEmployee (“tim”, 150); PayProcessor.printPay(we); MonthlyEmployee me = new MonthlyEmployee(“jane”, 200); MonthlyAdapter ma = new MonthlyAdapter (me); PayProcessor.printPay(ma); } } Mẫu composite * Graphic Draw() Add(Graphic) Remove(Graphic) GetChild(int) Picture Line Draw() Rectangle Text Draw() Add(Graphic) Draw() Draw() Remove(Graphic) GetChild(int) 61 VD: Hệ thống đặt phòng  Tổng quát CNPM/NN 62 Kiến trúc CNPM/NN 63 Thành phần CNPM/NN 64 Chọn ngôn ngữ CNPM/NN 65 Bảo trì phát triển CNPM/NN 66 CNPM/NN 67

Ngày đăng: 02/07/2020, 21:23

Xem thêm:

TỪ KHÓA LIÊN QUAN

w