开发者

Which design pattern to choose

I am using asp.net and c#.

I have a some classes. Some of the classes are having same met开发者_运维问答hods insert, update and delete.

Each insert will insert different data to different table. (same for update and delete). What type of pattern can be applied for this kind of class.

please suggest.


Patterns are things you should identify in your code from usage. Choosing a design pattern and then applying it, is perhaps a classic mistake.

Use a pattern, where a pattern is required.


Uhm... Generics?

Otherwise this sounds like the Template Method pattern.


While I agree wholeheartedly with Mitch Wheat, based on your description I do believe you're already using a pattern, without being aware of it completely.

Based on you description, I believe you are talking about the Table Gateway pattern. Each class represents access to a specific table, so you can perform your CRUD operations on a class. This offers a very tight binding of your model to your database logic, which can sometimes be useful (and more often than not can become very restrictive).

BTW: I am making the assumption here that when you say "each insert will insert different data to different table (same for update and delete)", you actually meant "each class".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜