How to Design a generic business entity and still be OO?

前端 未结 7 874
抹茶落季
抹茶落季 2021-02-01 20:57

I am working on a packaged product that is supposed to cater to multiple clients with varying requirements (to a certain degree) and as such should be built in a manner to be f

7条回答
  •  有刺的猬
    2021-02-01 21:27

    I know your question is general, not tied to a technology, but since you mention you actually work with .NET, I suggest you look at a new and very important technology piece that is part of .NET 4: the 'dynamic' type.

    There is also a good article on CodeProject here: DynamicObjects – Duck-Typing in .NET.

    It's probably worth to look at, because, if I have to implement the dynamic system you describe, I would certainly try to implement my entities based on the DynamicObject class and add custom properties and methods using the TryGetxxx methods. It also depends whether you are focused on compile time or runtime. Here is an interesting link here on SO: Dynamically adding members to a dynamic object on this subject.

提交回复
热议问题