首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

表结构类的设计思路解决思路

2012-03-19 
表结构类的设计思路我想构建一个类似表的类,该类能够记录字段名称、字段类型、字段值,在表中的纵坐标值、横坐

表结构类的设计思路
我想构建一个类似表的类,该类能够记录字段名称、字段类型、字段值,在表中的纵坐标值、横坐标值

我定如下
  TExcelField = class;

  TExcelFields = class;

  TExcelTable = class
  private
  public
  FFieldCount :Integer;
  FRecordCount :Integer;
  FExcelFieldList : array[1..RECCOUNT] of TExcelFields;
  end;


  TExcelField=class(TObject)
  private
  function GetCFName:string;
  function GetFName:string;
  function GetFType:string;
  function GetValue:string;
  public
  FCFName: string; //字段中文名称
  FFName: string; //字段名称
  FFType: string; //字段类型
  FValue: string; //字段值


  constructor Create(); reintroduce;
  destructor Destroy; reintroduce;

  property CFName:string read GetCFName;
  property FName:string read GetFName;
  property FType:string read GetFType;
  property Value:string read GetValue;

  end;

  TExcelFields=class(TObject)
  private

  public
  FExlField: array[1..MAXCOUNT] of TExcelField; //字段序列
  end;


有什么不好的地方吗?

[解决办法]
1.
FCFName: string; //字段中文名称
FFName: string; //字段名称
FFType: string; //字段类型
FValue: string; //字段值
不用public
2.
FExcelFieldList : array[1..RECCOUNT] of TExcelFields;
不灵活,TList好些
3.
FFieldCount :Integer;
FRecordCount :Integer;
原定义是个一维数组,为啥2个count尼

粗看了下,供参考
[解决办法]
TExcelFields=class(TObject)
可以包装一个List,该list存放Field对象;
提供查找Field方法,添加、删除Field等(依据实际需要)

热点排行