473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Class Design and Re-use

krs
Hi,
I'm using the MS timetracker app as a basis for an application I am building.

I have at present two classes, Site and SitesCollection, similar to the timeentry and timeentrycollection classes. These classes use the ms sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes to build a collection of site objects from the database and display them in a datagrid. I have also provided fields to allow for adding sites to the db and allowed users to edit inline and delete by choosing a checkbox and hitting a delete button.

My question is around how I would now provide the same maintenance page for a different set of data. Sites contain pages, so I am allowing the user to choose a site from the grid to display the related pages in the same manner as for sites.

I'm thinking the best way is to now create a page and pagescollection class and then follow the same principle with datagrid, inputs, buttons etc as for the sites. I'm concerned though that I will be repeating code that could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this sort of problem?

Any suggestions greatly appreciated.

Thanks
K
Nov 18 '05 #1
7 1945
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am building.
I have at present two classes, Site and SitesCollection, similar to the timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.
I've now created a web form that uses the site and sitescollection classes to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.
My question is around how I would now provide the same maintenance page for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.
I'm thinking the best way is to now create a page and pagescollection class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.
Am I approaching this correctly or is there a better way to go about this sort of problem?
Any suggestions greatly appreciated.

Thanks
K

Nov 18 '05 #2
krs
Thanks for your input.

So I guess for now I'll leave the different classes seperate for Sites, SitesCollection, Page, PagesCollection. Do you think there is a way I could be re-using the code that I have written in the .aspx page that uses these classes? I currently have a page written that allows me to maintain the database for sites, update, delete, add etc...

I now need to do exactly the same thing for pages, though pages will have different data, in effect I still want to do add, update and delete. I dont think that lifting the code from one page and creating another for pages is the best option, should I be thinking along the lines of a server control, that implements the logic of the datagrid?

I hope this makes sense.

Thanks
K

"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am

building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K


Nov 18 '05 #3
krs
Thanks for your input.

So I guess for now I'll leave the different classes seperate for Sites, SitesCollection, Page, PagesCollection. Do you think there is a way I could be re-using the code that I have written in the .aspx page that uses these classes? I currently have a page written that allows me to maintain the database for sites, update, delete, add etc...

I now need to do exactly the same thing for pages, though pages will have different data, in effect I still want to do add, update and delete. I dont think that lifting the code from one page and creating another for pages is the best option, should I be thinking along the lines of a server control, that implements the logic of the datagrid?

I hope this makes sense.

Thanks
K

"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am

building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K


Nov 18 '05 #4
krs
Thanks for your input.

So I guess for now I'll leave the different classes seperate for Sites, SitesCollection, Page, PagesCollection. Do you think there is a way I could be re-using the code that I have written in the .aspx page that uses these classes? I currently have a page written that allows me to maintain the database for sites, update, delete, add etc...

I now need to do exactly the same thing for pages, though pages will have different data, in effect I still want to do add, update and delete. I dont think that lifting the code from one page and creating another for pages is the best option, should I be thinking along the lines of a server control, that implements the logic of the datagrid?

I hope this makes sense.

Thanks
K

"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K



"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am

building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K


Nov 18 '05 #5
krs
Thanks for your input.

So I guess for now I'll leave the different classes seperate for Sites, SitesCollection, Page, PagesCollection. Do you think there is a way I could be re-using the code that I have written in the .aspx page that uses these classes? I currently have a page written that allows me to maintain the database for sites, update, delete, add etc...

I now need to do exactly the same thing for pages, though pages will have different data, in effect I still want to do add, update and delete. I dont think that lifting the code from one page and creating another for pages is the best option, should I be thinking along the lines of a server control, that implements the logic of the datagrid?

I hope this makes sense.

Thanks
K

"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am

building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K


Nov 18 '05 #6
krs
Thanks for your input.

So I guess for now I'll leave the different classes seperate for Sites, SitesCollection, Page, PagesCollection. Do you think there is a way I could be re-using the code that I have written in the .aspx page that uses these classes? I currently have a page written that allows me to maintain the database for sites, update, delete, add etc...

I now need to do exactly the same thing for pages, though pages will have different data, in effect I still want to do add, update and delete. I dont think that lifting the code from one page and creating another for pages is the best option, should I be thinking along the lines of a server control, that implements the logic of the datagrid?

I hope this makes sense.

Thanks
K

"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am

building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K


Nov 18 '05 #7
krs
Thanks for your input.

So I guess for now I'll leave the different classes seperate for Sites, SitesCollection, Page, PagesCollection. Do you think there is a way I could be re-using the code that I have written in the .aspx page that uses these classes? I currently have a page written that allows me to maintain the database for sites, update, delete, add etc...

I now need to do exactly the same thing for pages, though pages will have different data, in effect I still want to do add, update and delete. I dont think that lifting the code from one page and creating another for pages is the best option, should I be thinking along the lines of a server control, that implements the logic of the datagrid?

I hope this makes sense.

Thanks
K

"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K



"Jeremy" wrote:
Here's my 2-cents worth on your specific question <<Am I approaching this
correctly or is there a better way to go about this sort of problem?>>
We all want to re-use as much code as possible for a variety of lofty
reasons. So the fact that you're on the lookout for an opportunity to re-use
your code means you are starting out on the right track. Now, in your
particular situation, it's hard to say whether you can completely re-use
your Site and SiteCollection classes or if you can partially re-use them
(abstracting some functionality into one or more base classes that are then
extended for unique entities). In fact, it might be hard for you to know
ahead of time whether you could re-use them. If you were perfectly clear on
the requirements (i.e., all the properties and methods of each), then you
could know ahead of time where all the similarities and differences are
(between {Sites/SiteCollection} and {Site/SitePages}), and therefore the
extent to which you could re-use your classes (perhaps renaming them to
something more generic in the process to facilitate maintenance and
readability of your code). However, a strong case could be made that you
will not (and cannot) be totally clear on the requirements until after you
have finished implementing the requirements to the user's satisfaction (I'm
assuming you have a non trivial project on your hands with real end-users).
Now, once you have implemented everything to the user's satisfaction, then
you can have total clarity on the specs for your classes - and would then be
in a position to refactor all of your app's classes - determining which
functionality can be abstracted... which base classes could be created, etc.
My hunch is that if you were more clear on the requirements that you
wouldn't be asking us this question and would be proceeding ahead with
confidence. So, given that you aren't totally clear (forgive me if I'm
wrong - it's happened before!), I'd suggest that you proceed with any way
you can see to make it work. Then when you feel you have enough clarity you
can refactor your code to make your final implementation more maintainable,
readable, extensible, blah blah blah.

Good Luck...

-J

MCSD, MCDBA, MCSE, MCSA (FWIW - which may not be much!)

"krs" <kr*@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi,
I'm using the MS timetracker app as a basis for an application I am

building.

I have at present two classes, Site and SitesCollection, similar to the

timeentry and timeentrycollection classes. These classes use the ms
sqlhelper class as a data access layer.

I've now created a web form that uses the site and sitescollection classes

to build a collection of site objects from the database and display them in
a datagrid. I have also provided fields to allow for adding sites to the db
and allowed users to edit inline and delete by choosing a checkbox and
hitting a delete button.

My question is around how I would now provide the same maintenance page

for a different set of data. Sites contain pages, so I am allowing the user
to choose a site from the grid to display the related pages in the same
manner as for sites.

I'm thinking the best way is to now create a page and pagescollection

class and then follow the same principle with datagrid, inputs, buttons etc
as for the sites. I'm concerned though that I will be repeating code that
could in some way be re-used.

Am I approaching this correctly or is there a better way to go about this

sort of problem?

Any suggestions greatly appreciated.

Thanks
K


Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jack | last post by:
Dear all, I'm using a commercial library that I cannot modify. There's this one class in the library which is almost 90% usable. But unfortunately, I have to reimplement 3 member functions. The...
6
by: RainBow | last post by:
Greetings!! I introduced the so-called "thin-template" pattern for controlling the code bloat caused due to template usage. However, one of the functions in the template happens to be virtual...
3
by: niyad | last post by:
hi On a form ive added my custom component (MyComponent) which has a property (IDs in the expample code) exposing a collection of int16. I see this property in the PropertyGrid and I dont have...
3
by: Mojtaba Faridzad | last post by:
Hi, my question is about OO design. imagine we have 2 classes with some common members and some different members. which one is better and why: 1) design class A completely and B as a drived...
2
by: Kalpesh | last post by:
Hello, I am facing a design problem here & need your expert design advice on this. Scenario: I have a class called Vendor - which has several simple attributes like Name, Address etc Now,...
0
by: --== Alain ==-- | last post by:
Hi I've create a C++ managed Class as : *.h file -------- #pragma once #include "afxcmn.h" using namespace System::Design; using namespace System::Drawing::Design; using namespace...
5
by: __PPS__ | last post by:
Hello all, I was working on someone else's code to implement some classes. The task seemed to be simple and I was confident that I won't spent alot of time on that task... But! I've already spent...
25
by: David Sanders | last post by:
Hi, As part of a simulation program, I have several different model classes, ModelAA, ModelBB, etc., which are all derived from the class BasicModel by inheritance. model to use, for example...
6
by: JoeC | last post by:
I have a question about designing objects and programming. What is the best way to design objects? Create objects debug them and later if you need some new features just use inhereitance. Often...
1
by: Angus | last post by:
Hi all I have a design which models a telephone system. Roughly the design has these two items: device class which models an extension on the telephone system. The device constructor takes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.