【发布时间】:2013-08-17 14:24:10
【问题描述】:
我有一个关于数据分类的问题。我想这就像 Google 的 PageRank 的目标:如何对查询进行分类以便我们返回最佳匹配结果?
我简化了一个场景来说明我的业务问题。
假设我在市场上有一些房子,并假设我使用枚举作为“标志”或“选项”来分配给我的房子对象。 这个例子不是关于好的设计,而是关于根据客户的需求偏爱一所房子而不是另一所房子的程序化解决方案。
正如您在底部看到的,客户通常会混合/匹配许多相同的愿望。所以我需要找出哪个房子是最好的匹配,而不是诉诸一千个 if/else 或 switch 语句。
有可能吗?
标志/选项:
enum RoomTypes
{
Bathroom,
Bedroom,
Livingroom,
Study
}
enum Nearby
{
School,
Hospital,
ShoppingMall,
Park,
Trainstation
}
enum Features
{
Airconditioning,
Garage,
Garden,
Storage,
Basement
}
班级:
class House
{
public IEnumerable<RoomTypes> RoomTypes {get; set;}
public IEnumerable<Nearby> Nearby {get; set;}
public IEnumerable<Features> Features {get; set;}
}
==============
我们有 2 个可用的房子:
var bigHouse = new House
{
RoomTypes = new IEnumerable<RoomTypes>{ RoomTypes.Bathroom, RoomTypes.Bedroom, RoomTypes.Study };
Nearby = new IEnumerable<Nearby>{ Nearby.School, Nearby.Park, Nearby.ShoppingMall };
Features = new IEnumerable<Features>{ Features.Airconditioning, Features.Storage, Features.Garden };
}
var smallHouse = new House
{
RoomTypes = new IEnumerable<RoomTypes>{ RoomTypes.Livingroom, RoomTypes.Bedroom };
Nearby = new IEnumerable<Nearby>{ Nearby.Trainstation };
Features = new IEnumerable<Features>{ Features.Airconditioning };
}
==============
用例: 客户根据选择申请房子。
客户 A:
- 房间类型:浴室、卧室
- 附近:公园、购物中心、学校
- 特色:空调、地下室、花园
客户 B:
- 房间类型:卧室、浴室
- 附近:购物中心、火车站
- 特色:空调、车库
现在的问题是,如何根据可用房屋对申请进行评分?
【问题讨论】:
-
how do I rate the applications based on the available houses,我想这取决于提高和降低评级的因素。是什么让一个应用程序的评级高于下一个应用程序?这是您的域,这是您的计算
标签: c# ienumerable design-patterns classification flags