Im writing a .net webforms app. It has a number of classes, for example users, bookings etc. At the moment I have a number of manager classes, say bookingManager, that manage these classes. For example when creating a new booking, you call the add method in the bookingManager, and pass a booking. It then checks the booking is valid, checkis it doesn’t conflict, and if it does not, adds it to the db. I have similar managers for the other classes, however ones such as the user manager don’t do alot more than take the user and add to the DB. So my question is, is this the best way to be doing this sort of thing, or is there a pattern or method thats better suited to this?
Share
as you describe it you are already using a pattern, the 3 Tier pattern 🙂
This states that in the application you should have your code into 3 tiers (as the name states):
Presentation Tier : Where you write the code to present your data (ASPx/winforms/etc)
Application Tier : where you place all your business logic (what you are doing with the Manager Classes)
Data Tier : Where you do the actual access to the database.
Following this pattern can be useful when, you have something like a client with multiple addresses the client is stored in one table and the addresses in another. In your presentation tier you just invoke a method in the application tier to save the client. In the application tier you will check your data and invoke two methods in the Data tier, one for saving the client one for saving the addresses.
Now if you have suppliers with multiple addresses you can use the same method in the Data tier to save them.
This will be useful if you have complex objects. however if most of your objects are just plain simple I would recommend that you think it over if this pattern is the right one for you.
http://en.wikipedia.org/wiki/Multitier_architecture