Questions about UML in relation to the command pattern

http://www.oodesign.com/command-pattern.html
In reading through a tutorial about the command pattern, I came across a UML diagram that seems to omit some relationships. For the following diagram, the client instantiates a stock trade, an agent, and buy and sell stock orders. Why is it that the author omits the relationship arrow to the agent class? Why is the dashed line for <> used in place of a solid arrow like the one from Client to StockTrade?

enter image description here

I also compared the above diagram with the one below, which leaves out the Invoker/Agent class entirely and also uses the class CallbackTwo to aggregate Receivers. The C# implementation has an invoker class, although the implementations in other languages don’t. Does this mean the invoker relationship is implicit?

http://sourcemaking.com/design_patterns/command

http://sourcemaking.com/design_patterns/command/c-sharp-dot-net

enter image description here

1

I recommend you don’t take depicted diagrams too close. Depicted ones in GoF book should be referencing examples. Also, there are variations of patterns caused by environment where it is used.

The only thing we can do is formally validate it for UML and logic compliance.

At first diagram I see that designer wanted to show orders accumulation in agent instance, thus it uses “<>”, but:

  1. Inside big yellow box with code sample Client doesn’t call agent.sell() and thus all holded in ‘Agent’ instance ‘Order’s (bsc, ssc) will never be processed.
  2. Use of “<>” emphasizes that orders are holded inside ‘Agent’ and its relation is strong. Using of aggregation (<>) instead of simple association means more strong semantic, but I think in this certain case aggregation is not necessary. Hence, you’re right, simple association (solid arrow) is good enough.
  3. Omitting of relationship between ‘Client’ and ‘Agent’ instances is a bug. There must be dependency (dashed line with <> andor <>) between them.
  4. Moreover, designer was inconsistent in his decision. He redundantly placed field ‘+stock:StockTrace’ in both ‘BuyStockOrder’ and ‘SellStockOrder’ and also added accociation between both ‘BuyStockOrder’ and ‘SellStockOrder’ and ‘StockTrace’. But for similar case with ‘Client’ and ‘StockTrace’, ‘Client’ class doesn’t contain ‘+stock:StockTrace’ field.

At second diagram there are no invokers, thus it is assumed to be implicit :). The only thing I want to add that “also uses the class CallbackTwo to aggregate Receivers” is wrong. Word “also” is wrong.

  1. Previous example depicted Invoker (Agent) holding Comamnds (Orders), but there Command (CallbackTwo) holds some data (Receiver).
  2. Also, defining of both association and private field in CallbackTwo is redundant.

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