Observer pattern: “Web of observers” – Is this ever in use?

I had an idea (which I’m sure already exists), to create a sort of ‘network of observers/subjects’. I would like to describe how it works and than ask several questions about it.

Say we have 5 objects: Objects A, B, C, D and E. Objects D and E need to observe objects A, B and C.

With the regular Observer pattern, both D and E would register as observers to A, B and C. This means both D and E would have to register three times as observers, creating six observer-subject relationships total.

enter image description here

The idea is to add another object in the middle, let’s call it Object O. It implements both the Observer and Observable interfaces. It registers as an observer to objects A, B and C. Objects D and E register as observers to object O.

Whenever objects A, B and C notify object O, object O notifies it’s own observers – D and E. Thus creating a sort of network. This network has a total of five observer-subject relationships.

enter image description here

As I see it, this has two main benefits:

  • The less important benefit: This solution allows for less observer-subject relationships, and thus (I think) creates less complexilty in the system. In this simple description the number of relationships only gets reduced by one, but the more observers and subjects there are, the bigger the benefit.

  • The more important benefit: Please consider an application with two groups of objects, group A and group B. All objects in group A need to observe all objects in group B. If we decide to add an object to group B, than using regular Observer we’d have to update a lot of code to register all objects in group A as observers to the new object. With the ‘network’ solution (which I’m sure has a different name), we only register the ‘middle’ object (object O) as an observer to the new object in group B, and all objects in group A would be notified when the new object in group B changes state.

My questions:

  1. Is this solution ever in use in professional projects? Did you ever encounter this in use? Or is it just a cool idea but never used in practice?

  2. What would you say are this pattern’s disadvantages?

  3. Does it have more advantages that I’m not aware of?

  4. Does this have a name?

3

  1. Sure, these things exist. D-BUS comes to mind, or any number of messaging frameworks (RabbitMQ , AMQP, ZeroMQ, etc). They’re all variations on a similar theme.
  2. Increased latency compared to directly-connected peers, and increased complexity for complex topologies.
  3. The biggest one I can think of is the ability to extend to multiple WANs and scale to massive numbers of subscribers. (Search for ‘message queue federation’ to learn more). Also, service discovery. Clients only need to know about the ‘router’ component in the middle to connect to any service.
  4. There are so many variations that it’s hard to pick a single name, but I would call it a ‘software message bus’ or ‘message broker’.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Observer pattern: “Web of observers” – Is this ever in use?

I had an idea (which I’m sure already exists), to create a sort of ‘network of observers/subjects’. I would like to describe how it works and than ask several questions about it.

Say we have 5 objects: Objects A, B, C, D and E. Objects D and E need to observe objects A, B and C.

With the regular Observer pattern, both D and E would register as observers to A, B and C. This means both D and E would have to register three times as observers, creating six observer-subject relationships total.

enter image description here

The idea is to add another object in the middle, let’s call it Object O. It implements both the Observer and Observable interfaces. It registers as an observer to objects A, B and C. Objects D and E register as observers to object O.

Whenever objects A, B and C notify object O, object O notifies it’s own observers – D and E. Thus creating a sort of network. This network has a total of five observer-subject relationships.

enter image description here

As I see it, this has two main benefits:

  • The less important benefit: This solution allows for less observer-subject relationships, and thus (I think) creates less complexilty in the system. In this simple description the number of relationships only gets reduced by one, but the more observers and subjects there are, the bigger the benefit.

  • The more important benefit: Please consider an application with two groups of objects, group A and group B. All objects in group A need to observe all objects in group B. If we decide to add an object to group B, than using regular Observer we’d have to update a lot of code to register all objects in group A as observers to the new object. With the ‘network’ solution (which I’m sure has a different name), we only register the ‘middle’ object (object O) as an observer to the new object in group B, and all objects in group A would be notified when the new object in group B changes state.

My questions:

  1. Is this solution ever in use in professional projects? Did you ever encounter this in use? Or is it just a cool idea but never used in practice?

  2. What would you say are this pattern’s disadvantages?

  3. Does it have more advantages that I’m not aware of?

  4. Does this have a name?

3

  1. Sure, these things exist. D-BUS comes to mind, or any number of messaging frameworks (RabbitMQ , AMQP, ZeroMQ, etc). They’re all variations on a similar theme.
  2. Increased latency compared to directly-connected peers, and increased complexity for complex topologies.
  3. The biggest one I can think of is the ability to extend to multiple WANs and scale to massive numbers of subscribers. (Search for ‘message queue federation’ to learn more). Also, service discovery. Clients only need to know about the ‘router’ component in the middle to connect to any service.
  4. There are so many variations that it’s hard to pick a single name, but I would call it a ‘software message bus’ or ‘message broker’.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật