C# Application Designs

  • Thread starter Thread starter Ed_P.
  • Start date Start date
E

Ed_P.

Hello,

I've been creating small applications in c# using an access db backend.
I've noticed that on all of those applications I rarely apply any OOP
technologies (such as Inheretance, Encapusulation, Interfaces, etc.). I
would like to take advantage of those technologies so that the
applications I create are easier to maintain and can be upgraded with
out (or as little) problems as possible. Speaking to a developer he
told me to try to sepearte the program into layers (presentation,
business, data access). I know how to create the presenation, but I am
getting stuck how to set up the other two layers.

Maybe I can give you an example of what I am trying to do and someone
out there can tell me how I could set up this. I have the following
tables in a database:

Customers
CustomerTypes
Contacts
ContactTypes
TechTickets
TechTicketTypes
TechAgents
TechAgentTypes

In the past applications I've created a class that would query the
database and query it to retreive a list of Customers, open Tech
Tickets, List of Tech Agents, and list of Contacts. This is all that I
have done to work with the data in the database.

Things I'd like to do is to be able to create new Customers, Contacts,
TechTickets, etc. in the Database. In addition I'd want to search for
and edit the entities referenced above.

Can anyone give me an idea as to how you would try to what I am trying
to do. Maybe there are some web sites out there with an example that I
can use as a template on how to go about doing this? Any information
that you can provide will be greatly appreciated!

Thanks,

Ed_P.
 
As far as your specific problem is concerned: the Agile developer in me
says: Don't overdesign this.

If it works the way it is, why change it.

On the other hand, you should know the fundamentals of OO design, so that
your code will be easier to maintain.
For that part, I can help. Start here:
http://blogs.msdn.com/nickmalik/archive/2004/12/21/328727.aspx

The pattern you are looking for is the Layers pattern, described by
Buschmann.
The goal is to create layers in your application that seperate the concerns.
Using this pattern, the data access layer overcomes the impedence between
relational storage and object oriented heirarchies.
The business logic layer handles rules specific to the business (limits on
behavior, calculations based on business needs, logic for auditing and
logging, etc).
The user interface layer simply maps the U/I to the business logic layer,
and does as little else as possible (because that's already plenty).

Personally, I find this pattern limiting. I would fall back to the even
earlier pattern of Model-View-Controller to describe the interacting
components within an application, with your data access layer acting as the
model, the user interface layer acting as the view, and the business logic
layer acting as controller. The shift is subtle, but it is more comfortable
to me.

To learn more: google the terms:
Buschmann layers pattern
Model view controller
Microsoft patterns and practices

Hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
Back
Top