Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A real life LAYERED: Kernel--Math Algorithms--GUI Algorithms--Output

Status
Not open for further replies.

rexhunter

Programmer
Dec 30, 2004
9
NL
I am developing a forum (discussion) site and other funny stuff. First, I will explain:
(Note: this question goes not about ASP.NET or .NET, but about OOP in general).

Most of the things run on a database. I created a database class that simplifies the interacting between the other code and de database provider. Other classes must inherit this class. This code is in a separate .NET DLL.
Other classes that derived from the core class are classes for discussion algorithms, user login…etc…
These classes are used by the ASPX files (or if you are unknown with .NET, let’s call it PHP files if you want). The ASPX files have also an own code base. Because I am using many controls, it is very hard to put this code into the DLL; I have to send references of all the controls to that particular DLL.

Okay my question is revealing.

I wrote that classes in the DLL inherit form the kernel. They search the database and process the tree algorithms and so on. They also give the output in HTML format or give the controls the correct values. However, there is also similar code in the ASPX files that should be in the DLL. I wrote this in the ASPX files because of the references to the ASP.NET controls (more then 12 controls).

The real question is how I can put this thoroughly in good layers, without writing much code to do this. The classes in the DLL (also the functions in the ASP.NET file) use the kernel class for processing things. Have I to partition the things?
? Do I have to write one layer that has only access to the database and the kernel class and another class that formats the output and have to do with the controls? Nowadays one class does this. E.G., the discussion class inherits form the database class, has access to the database, and formats the output.

Could you give me advice? When you do not understand me, I will explain it later. When you can give me also some advice on programming in ASP.NET, I’m pleased.







I am developing a forum (discussion) site and other funny stuff. First, I will explain:
(Note: this question goes not about ASP.NET or .NET, but about OOP in general).

Most of the things run on a database. I created a database class that simplifies the interacting between the other code and de database provider. Other classes must inherit this class. This code is in a separate .NET DLL.
Other classes that derived from the core class are classes for discussion algorithms, user login…etc…
These classes are used by the ASPX files (or if you are unknown with .NET, let’s call it PHP files if you want). The ASPX files have also an own code base. Because I am using many controls, it is very hard to put this code into the DLL; I have to send references of all the controls to that particular DLL.

Okay my question is revealing.

I wrote that classes in the DLL inherit form the kernel. They search the database and process the tree algorithms and so on. They also give the output in HTML format or give the controls the correct values. However, there is also similar code in the ASPX files that should be in the DLL. I wrote this in the ASPX files because of the references to the ASP.NET controls (more then 12 controls).

The real question is how I can put this thoroughly in good layers, without writing much code to do this. The classes in the DLL (also the functions in the ASP.NET file) use the kernel class for processing things. Have I to partition the things?
? Do I have to write one layer that has only access to the database and the kernel class and another class that formats the output and have to do with the controls? Nowadays one class does this. E.G., the discussion class inherits form the database class, has access to the database, and formats the output.

Could you give me advice? When you do not understand me, I will explain it later. When you can give me also some advice on programming in ASP.NET, I’m pleased.



 
rexhunter

model-view-controller (MVC) is the pattern you want. The presentation layer (the view) is implemented by the ASPX stuff. This gets the information from the model and renders it for display. This should give you a clue - it is these classes that should be producing the HTML, not the kernel classes. In this way, you can change the appearance of the displayed data without having to change the kernel classes at all. Use a Data Transfer Object class (possibly a .NET Dataset) to transfer the information between the layers.

The Presentation layer interacts with the model (the kernel classes) to update it to reflect any changes requested by the user. The kernel classes (already) know how to interact with the database.

Hope this helps.
 
Thanks,
I think it's worth trying it. I have to rewrite some things and I'll some more code. But I think the code will be more bright with that idea and easier the maintain. And to transport data with a dataset is a very good idea. A simple idea in fact, but very SMART and clever!

Thanks for your opinion and advice. I'm working on it and I'm testing some things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top