1. Trang chủ
  2. » Công Nghệ Thông Tin

Software design: Lecture 34 - Sheraz Pervaiz

27 3 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

Thông tin cơ bản

Định dạng
Số trang 27
Dung lượng 490,26 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Software design - Lecture 34. The main topics covered in this chapter include: structural design patterns; adapter or wrapper design pattern; laptop power supply to AC power supply Example; reasons for incompatibility; adapter pattern defined; issues in adapter design pattern;...

Trang 1

Lecture : 34

1

Trang 2

They deal with how classes and objects deal with to form large structures

Structural Design patterns use inheritance to compose 

interfaces or implementations

Structural Design Patterns basically ease the design by 

identifying the relationships between entities

Trang 3

3

Trang 4

Pattern

Trang 7

 This could happen due to various reasons such as  the existing interface may be too detailed, or it

    may lack in detail, or the terminology used by  the  interface  may  be  different  from  what  the  client is looking for.

7

Trang 8

 Keeping the client code intact we need to write a  new class which will make use of services offered 

by the class.

 Convert the services offered by class to the client 

in  such  a  way  that  functionality  will  not  be  changed  and  the  class  will  become  reusable  as  shown in next slide.

Trang 13

“Adapter  pattern  convert  the  interface  of  the  class into a form what client expects. Adapter  let  the  classes  work  together  which  couldn’t  otherwise due to incompatible interfaces.”

13

Trang 14

 Due  to  adapter  class  the  changes  are  encapsulated  within  it  and  client  is  decoupled  from the changes in the class.

Trang 15

 We  want  to  use  the  existing  class  and  its  interface does not match with the one you need.

 In case of reusable classes due  Non­Compatible  interfaces it is not possible to reuse them.

15

Trang 16

Pattern

Trang 18

 Client call operations on Adaptor instance, which 

in return call adaptee opertions that carry out the  request.

Trang 19

Object Adapters (Discussed till now)

Class Adapters

19

Trang 20

Class Diagram of Class Adapter

Trang 23

break; 

case SUNDAY: System.out.println("Weekends are best."); 

break; default: System.out.println("Midweek days are so­so."); break; } }

23

Ngày đăng: 05/07/2022, 14:06

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN