|
-
June 16th, 2012, 12:20 AM
#1
Preferred Design Pattern...?
Just wondering if anyone has a preferred design pattern for this basic task in a website:
you have the following classes (pseudocode version):
class Car{
int carID ;
String make;
int year;
String color;
}
class Driver{
int driverID;
int age;
String name;
int idOfCarTheyDrive;//Car.carID
}
you need to have an admin area that can:
list-all/add/edit/delete cars
list-all/add/edit/delete/assign-a-car drivers
in the front end you need to:
list all cars
list all drivers
select a driver to view
select a car to view
pretty much the standard task of most web pages - capture, list,edit,save, and display.
For years I've simply defaulted to using a CommandFactory (SaveCommand, DeleteCommand, GetItemCommand, GetAllCommand) that would receive an object via its interface and not be aware of what type of object it held (Driver, Car, etc...). The Driver/Car classes extend an Iterator pattern that would keep an internal array of database rows loaded into individual instances of themselves. Other instances I use a Chain of Responsibility pattern (really handy for some of the server-side AJAX we implement since it allows us to have a single point of origin that can perform XSS security (token based) checks through a 'doorman'. I'm feeling rather stagnated on this approach though (in particular the save/retrieve from the database) and am looking for other people's input on what they've come to favor in terms of piecing it together.
Tags for this Thread
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
|