问题描述
我是一名业余程序员。我在各种论坛上在线销售,并编写自己的软件来帮助进行销售处理。所以说我有一个SQL数据库,其中有一个名为SQL.Customer的客户表。如果我在线销售,我可以下载一个feeBay.Customer对象,其中包含与SQL.Customer几乎相同的信息。如果客户支付费用,我可以下载一个feePay.Customer对象,再次使用几乎相同的信息。
我的问题是我需要传递客户信息。例如,我下载了一个feeBay客户,检查数据库以查看客户是否是新的,检查feePal以查看地址是否匹配等等。但是因为它们都是不同类型,从一个转换到另一个(并且返回)是一种痛苦。
我认为这是一种常见的问题。似乎每次遇到这样的事情我都会以不同的方式处理它。是否有标准的设计模式/过程/体系结构来处理包含大部分相同信息的不同无关对象?
I''m an amateur programmer. I sell online in various forums and write my own software to help with sales processing. So say I have a SQL database that has a customer table in it called SQL.Customer. If I make a sale online I can download a feeBay.Customer object with pretty much the same info as SQL.Customer. If the customer pays with feePal I can download a feePay.Customer object, again with pretty much the same info.
My problem is that I need to pass customer info around. For example, I download a feeBay customer, check the database to see if the customer is new, check feePal to see if the addresses match, etc. But since they are all different types converting from one to another (and back) is a pain.
I would think this is a common type of problem. It seems that every time I run into something like this I handle it a different way. Is there a standard design pattern/procedure/architecture to handle different unrelated objects which contain mostly the same information?
推荐答案
这篇关于不同类型的客户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!