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

Software design: Lecture 39 - Sheraz Pervaiz

25 6 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 25
Dung lượng 400,46 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 39. The main topics covered in this chapter include: behavioral patterns; category of patterns are concerned with algorithms and assignments of responsibilities between objects; describe not just patterns of objects or classes but also the pattern of communication between them;...

Trang 1

Lecture : 39

Trang 2

This  category  of  patterns  are  concerned  with algorithms  and  assignments  of  responsibilities between objects

They  describe  not  just  patterns  of  objects  or classes  but  also  the  pattern  of  communication between them

Trang 3

This  category  will  shift  the  focus  from  flow  of control to concentrate just on the way objects are interconnected

These    patterns  are  concerned  with  the assignment  of  responsibilities  between  objects, 

or,  encapsulating  behavior  in  an  object  and delegating requests to it. 

Trang 4

OR  Well Managed Collection

Trang 5

 There  are  different  data  structure  to  store  data  or  objects in a collection i­e Array, Array list , Vector,    stack, link list etc.

 In  other  words  there  are  different  container  which  contain different object and to access the content of  each container different mechanism is applied.

Trang 6

Arrays are Static data 

structure

Vectors are dynamic data  structure

list of references to other  objects

Since size is fixed memory is 

way of storing data

Trang 10

Apple

Orange

Banana

Trang 11

“The  Iterator  Design  pattern  provides  a  way  to  access  the  element  of  aggregate  object  sequentially  without  knowing it’s underlying representation”

Trang 12

container  in  a  sequential  manner,  without  having  any  knowledge  about  the  internal  representation  of  its  contents.

the contents of the container.

Trang 13

Pattern

Uniform  method  of  accessing  elements  of   collection  without  knowing  the  underlying representation

We  can  write  polymorphic  code  to  access  the elements of underlying aggregate objects

Trang 14

The  idea  is  to  take  out  the  responsibility  for access and traversal out of the collection and put them in the Iterator Object

Iterator  class  will  define  an  interface  for accessing the element of the collection

Trang 15

 The  abstraction  provided  by  the  Iterator  pattern  allows  you  to  modify  the  collection  implementation  without making any changes outside of collection. It  enables  you  to  create  a  general  purpose  GUI  component  that  will  be  able  to  iterate  through  any  collection of the application. 

Trang 16

should  be  designed  to  provide  a  public  interface  in  the  form of an Iterator object   for different client objects to  access its contents.

client object to navigate through the list of objects within  the container

Trang 17

Pattern

Trang 20

 Benefits

i  Simplifies the interface of the Aggregate by not polluting it with traversal methods

ii.Supports multiple, concurrent traversals

iii.Supports variant traversal techniques

 Liabilities

    None!

Trang 21

 This example is using a collection of books and 

it  uses  an  iterator  to  iterate  through  the collection

Trang 22

Class Diagram

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

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

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

TÀI LIỆU LIÊN QUAN