intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Bài thực hành số 06: Structural Patterns

Chia sẻ: Gacon | Ngày: | Loại File: DOC | Số trang:2

218
lượt xem
19
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Tạo một Project mới trên EA. Tạo sơ đồ l ớp cho 7 m ẫu Structural t ừ Pattern tích hợp sẵn trong EA. 2. Thay đổi tên lớp trong...

Chủ đề:
Lưu

Nội dung Text: Bài thực hành số 06: Structural Patterns

  1. BÀI TẬP THỰC HÀNH Môn TKPMHDT --- Bài thực hành số 06: Structural Patterns 1. Tạo một Project mới trên EA. Tạo sơ đồ l ớp cho 7 m ẫu Structural t ừ Pattern tích hợp sẵn trong EA. 2. Thay đổi tên lớp trong các mẫu này đ ể t ạo ra nh ững ví d ụ c ụ th ể (nh ư ví d ụ trong GangOfFour). Hướng dẫn: Xem phần Help của EA, mục Pattern  Default, change Use a Pattern Using a Pattern enables you to use items defined in the Pattern with the UML model. Using Patterns enables you to rapidly create template solutions for code structures that perform the same type of task in other situations. To use a Pattern that you have previously imported into the model, follow the steps below: 1. Open the diagram into which to add the UML Pattern. 2. Select the Resources window. Expand the UML Pattern folder and find the Pattern to add. 3. 4. Either: Right-click on the Pattern and select the Add Pattern to Diagram menu option or • Drag and drop the Pattern from the Resources window onto the diagram. • 5. Once the appropriate selections have been made, click on the OK button to import the Pattern into the model, recreating the original diagram with new GUIDs. Change Pattern Element Default To change the default of the Pattern element, follow the steps below: 1. From the Add Pattern dialog select the individual element in the Pattern Element panel. 2. Click on the [ ... ] button to display the Edit dialog. The specific method for changing the element name is dependant upon the entry in the Action column of the Pattern Elements panel.
  2. 3. If the Action entry is Create, then in the Default field in the Edit dialog delete the existing value and type your own, user-defined value. Click on the OK button. The element default is updated on the Add Pattern dialog. 4. If the Action entry for the element is Merge, in the Edit dialog click on the [ ... ] button to browse to an existing element classifier. The Set Element Classifier dialog displays. Select an existing element classifier from the Classifier list. You can restrict the number 5. of choices by selecting the elements from a specific namespace; to do this, click on the In Namespace drop-down arrow and select a namespace. For more information regarding setting element classifiers see the Using Classifiers topic. 3. Import 7 mẫu structural từ code GangOfFour vào. L ưu ý: tổ ch ức thành các Package riêng cho từng mẫu. Mỗi dạng (Structural, RealWorld, .NETOptimized) bi ểu di ễn trong một lược đồ lớp riêng. 4. Mở phần code của GangOfFour trên Visual Studio, copy ph ần m ẫu FlyWeight (RealWorld) sang một Project mới. Kết hợp Singleton vào mẫu FlyWeight này đ ể đảm bảo chỉ tạo 1 thực thể duy nhất cho FlyWeightFactory. Import l ại s ơ đ ồ l ớp cho phần code đã điều chỉnh. Quan sát kết quả xem đã phù h ợp hay ch ưa. 5. Kết hợp FlyWeight với Composite để xử lý sao cho các LeafNodes (Primitives) đ ược chia sẻ giữa nhiều đối tượng (phức hợp) khác nhau. Lập s ơ đ ồ l ớp cho m ẫu lai này. Phát sinh code và hoàn chỉnh phần cài đặt cho ví dụ RealWorld c ủa Composite, sau khi đã kết hợp FlyWeight. -HẾT BÀI 6-
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2