Decorater pattern or strategy pattern

I’m constructing a c# serverside application and I’m trying to do this in a way it can easily be maintained aswell as extended if needed.

So what we have is 4 different requests that need to be done (SOAP, HTTPREQUEST and so on). These are then to be combined with a chunk of different actions like Importing/Exporting/Updating.

What I’m thinking is that every request should be a strategy, much like the switching algorithms description for the strategy pattern. Then I want to extend the strategy with a decorator, adding new functionality to the request. Is there a need to contain this in a separate class(SoapRequest_Import/HTTPRequest_Update) or how should I think? Last one about containing everything in a class seems to take away the flexibility?

So with that said, am I wrong?
First question, is this done better with each of the patterns or is it okay to combine them. I was thinking strategies for the different clients, and decorators for the commands(or added functionalites). Or am I just overdoing this?

Lastly how would it look codewise if I did combine them. I do understand that I need at least one interface for the decorators. Do I need one for the strategies too?

1

Stop thinking in terms of specific patterns. At least stop looking for places to apply patterns. Start thinking in terms of separation of concerns, and if that leads you back to a pattern, so be it.

You have two different groups of concerns there. The communication interfaces (Http, Soap, etc) and the data interfaces (Import, Export, Update, etc). Your goal should be to separate those concerns as completely as possible.

That is, imagine that you need to add 100 more communication protocols and 100 more data actions. Would it be better if you could do that by writing 200 more classes or would you expect to have to write 10,000 classes? If you’re answering “10,000” then you’re thinking about it all wrong.

So what you need is a framework that hooks everything together. Take messages from some kind of communication protocol, without knowing which protocol, and route these messages into actions that write to a data source, without ever knowing where the message is coming from or why it has been sent to this action.

Now, stretch your mind a little bit and this is starting to sound like a problem that’s already been solved.

  • Data Source = Model
  • Communications protocols = View
  • Actions = Controller
  • Routing = well … routing

Take a look at MVC frameworks. One of them may actually suit all your needs, or at least allow you to extend the framework to suit your needs. If not then look at the patterns used by an existing framework, see what you can learn and reapply in your own framework.

In places, I’m sure, you will recognise all sorts of GoF patterns. I’m certain there will be adapters, factories, maybe strategies. But the overall problem you’re trying to solve is a problem that MVC at least partly resolves (for example, you can route web page requests and Json requests to the same methods in a controller).

So that would probably be a good place to start researching. But, ultimately, the problem you’re trying to solve is separation of concerns, so that the extension of one concern doesn’t heavily affect existing code in the other concern.

So keep that in mind throughout.

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