Re: data transporting questions



>From a consistency point of view, I think the class based data set should be
as complete as possible, so as to keep the handling code as straightforward
as possible. I mean, all of the references should always be resolved.
Obviously this way could quickly lead to a rather complex structure when you
have a model with several nesting levels.
In this case I think the MVC model may help: keeping to this paradigm rules,
you will have as many different presentation sets as needed (i.e. different
views), each containing just the pieces of information pertaining to it. In
other words you keep just one copy of the whole data set, breaking it into
smaller lumps depending on presentation and use needs.

Of course this is just my opinion...

Regards

MSL

"Rizwan" <hussains@xxxxxxxxxxxx> ha scritto nel messaggio
news:TpDse.11489$Qr3.1210014@xxxxxxxxxxxxxxxxxxxxxxxx
> For each table in my database, I have created a seperate class (java-beans
> style) whose attributes matches to the columns of its table. If its a
> foreign key then the datatype is actually another class.
>
> CREATE TABLE LOCATION (
> location_id int NOT NULL PRIMARY KEY,
> location_name varchar(50) NOT NULL,
> location_flag int NULL )
>
> CREATE TABLE EMPLOYEE (
> employee_id int NOT NULL PRIMARY KEY,
> first_name varchar(25) NOT NULL,
> middle_name varchar(25) NULL,
> last_name varchar(25) NOT NULL,
> location_id int NOT NULL REFERENCES LOCATION(location_id) )
>
> Then my classes are :
>
> public class Location implements java.io.Serializable {
> private int locationId;
> private String locationName;
> private Integer locationFlag;
>
> public Location() {}
>
> // Setters and Getters
> ...
> }
>
> public class Employee implements java.io.Serializable {
> private int employeeId;
> private String firstName;
> private String middleName;
> private String lastName;
> private Location location;
>
> public Employee() {}
>
> // Setters and Getters
> ...
> }
>
> The reason for creating these classes is that for each data request, the
> data can be passed in the shape of these classes. For that the logic I
have
> in my mind is :
> * data will be first retrieved in a resultset
> * the concerned class's object is instantiated
> * its attributes are populated through its setters
> * the object is passed to the data request module
>
> Now I have some questions:
>
> 1) Taking Employee example sometimes the data request is only concerned
> about Employee data (EMPLOYEE table only) and some time it is concerned
> about the corresponding Location data as well (EMPLOYEE and LOCATION
table).
>
> Should I pass Employee class in both cases?
> Or Should I create another class which is same as Employee class but with
no
> Location class reference and pass this new class?
> public class EmployeeRaw implements java.io.Serializable {
> private int employeeId;
> private String firstName;
> private String middleName;
> private String lastName;
> private int locationId;
>
> public Employee() {}
>
> // Setters and Getters
> ...
> }
>
> 2) Sometimes the data request cannot be represented in a class which
> represents a table. Its a combination of more than one class (here class
> means one which strictly represents a table). What is the solution in this
> case?
>
> 3) In the above scenario Employee class has Location class which has no
> other class. I will call this as 1 level deep. But there are some
scenarios
> where a class has another class which in turn also has some class. Its
like
> more than 1 level deep. In this scenario what is the recommended practice
> regarding retrieval?
>
>
> Thanks
>
>
>
>
>
>
>
>


.



Relevant Pages

  • data transporting questions
    ... private int locationId; ... private String locationName; ... public class Employee implements java.io.Serializable { ... The reason for creating these classes is that for each data request, ...
    (comp.lang.java.programmer)
  • Re: data transporting questions
    ... private int locationId; ... private String locationName; ... The reason for creating these classes is that for each data request, ... Taking Employee example sometimes the data request is only concerned ...
    (comp.lang.java.programmer)
  • Re: Building class
    ... R> public class CreditCard ... R> private int _creditCardId; ... R> private string _creditCardCode; ...
    (microsoft.public.dotnet.general)
  • Re: OOP object collections
    ... and a Employee class. ... private int m_Id; ... private string m_Name; ... private string m_LastName; ...
    (microsoft.public.dotnet.languages.csharp)
  • OOP object collections
    ... a Employee class. ... private int m_Id; ... private string m_Name; ... private string m_LastName; ...
    (microsoft.public.dotnet.languages.csharp)