|
-
Mar 10th, 2005, 04:18 AM
#1
Addicted Member
Re: Class Design
oh yeah ... you might want to seperate out the data type collection from the data type class, i noticed when you call possible data types you recreate the list everytime, might be a little nicer if it created one and kept it around, rather than recreating the same informatio nagain and again.
You could have a public static method on DataType which was getList() which returned a static List of data types to you, then you could add and remove from this in a static block e.g.:
Code:
public class DataType {
protected static List<DataType> dataTypes = new ArrayList<DataType>();
public static List<DataType> getPossibleDataTypes(){
return DataType.dataTypes;
}
static{
DataType.getPossibleDataTypes().add(new DataType(..string..));
DataType.getPossibleDataTypes().add(new DataType(..integer..));
DataType.getPossibleDataTypes().add(new DataType(..byte..));
}
/**
* Original Data Type class
*/
String sqltype,
javatype,
csharptype,
vbtype;
public DataType(){}
public DataType(String sqltype,
String javatype,
String csharptype,
String vbtype){
this.sqltype=sqltype;
this.javatype=javatype;
this.csharptype=csharptype;
this.vbtype=vbtype;
} }
This way you maintain you data type class, but you have a collection of possible data types availbale in the data type class.... you can staically initialise as many data types as you want, but then you also have the ability to add and remove from teh possible data type list from elsewhere because your exposing the list.....
Make sense?
-
Mar 10th, 2005, 04:24 AM
#2
Thread Starter
Fanatic Member
Re: Class Design
w00t
Thanks.
This is just used for my tier generator. The flow is get the information_schema.tables from a certain database and substitute the datatype from sql to java, c# and vb.net. Also to generate classes for the said languages. That's just the reason I made it as a string to write it on a code by code basis.
Say, I have a Customer table, it generates Customer.java providing the variable under the class are the fields from the Customer table. So, just replacing the types by string is (I think) ok for me now.
Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|