?
Solved

Real-World ASP.NET 2.0, Datasets, DAL, Dataview, and Disposal

Posted on 2007-11-26
6
Medium Priority
?
1,015 Views
Last Modified: 2013-11-07
Greetings,

I'm rewriting an app, and am starting to worry about long term performance of the way I'm writing it. First, a little background, and please read all of this because I think it all comes into play. Google EE Linkers need not apply.

I'm using Subsonic as my DAL, and subclassing it for the most part. I'm trying to avoid using their collections within the page classes (although sometimes that's just so easy it's sick!), and wrapping things in my own DAL (as seen below).

Getting to my questions,

1.) When I return a DataSet, how is that destroyed? Does the GC come by at the end of the page and wipe all that up? If so, is it something I can rely on, or is it like ASP Classics, "Oh, we close all connections so you don't have to *wink wink*?

2.) Same thing with a DataView, and would it be better to return the dataset and work with that, or is it roughly equivalent

3.) Same thing with SubSonic COLLECTIONS

4.) Any recommendations on making my DAL a little leaner, meaner, and extensible?

Points will be awarded to those who

a.) Link me to PRECISELY what I'm looking for
b.) Engage and really try to understand what I'm trying to accomplish.

I've asked these types of "theory" or best practices questions before, and have been consistently disappointed with the Interaction. I would really like to LEARN here, not just quick fix, and not with people randomly linking me garbage that doesn't really apply (the quick points people).

Thanks in advance.
public class StatusControl
{
	public static DataView GetAllStatus()
	{
        DataSet ds0 = new DataSet();
        IDataReader i1 = SPs.SelectStatusAll().GetReader();
        ds0.Tables.Add("Status");
        ds0.Tables[0].Load(i1, LoadOption.Upsert);
        DataView dvView = ds0.Tables[0].DefaultView;
        return dvView;
	}
}

Open in new window

0
Comment
Question by:NauticalNonsense
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 20353392
1) Garbage collection is non-deterministic--you can't predict when it will run.

2) It is a pretty complex algorithm that takes into account all kinds of things, but doesn't use reference counting.

3) With local variables that aren't passed outside of a method, the reference variables will be automatically garbage collected.

4) If an object implements the IDisposable interface, you can control when the object is destroyed by calling the Dispose method.

Bob
0
 
LVL 7

Author Comment

by:NauticalNonsense
ID: 20354291
Hiya Bob, I see you around here an awful lot.

So what is the "best" way of doing this, or how is this commonly done? Is this something that I should even worry about?

It just seems like when I'm binding up a bunch of data in a class file, and letting that hang out there, .. well .. just doesn't seem efficient.

I've worked with more web companies than I can count, and most of what I've learned is on the job stuff and they all seem to do it the same way .. now that I'm building a my OWN site, I find myself thinking, "wait a minute, is this the RIGHT way to do it?"
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20354460
The garbage collector makes your job significantly easier, but it is not the "perfect" way of memory management.  If you use a lot of global references that last the entire life-time of the application, or module-level references that get created indescriminately, you could run into some serious memory problems.  

A good rule of thumb, though, when developing software is to not worry about every little detail of memory management, and work more on the process details.  Then, you can use a profiler to monitor memory usage.  Sometimes worrying about memory management and other such optimization steps can make your program run slower.  

I read something the other day that there isn't any "right" or "wrong" way to build web sites, there is just a "better" way.   If the site does what you need, then it serves a purpose.  If it can look better, and perform faster, then it is a bonus!!  Studying, reading, talking, learning, experimenting, failing, and succeeding some ways that you can learn more about the "better way".

If you want to use static classes or methods, you can use them very carefully.  The life-time of static variables changes drastically with web sites, and server memory.  Using static methods with local instance variables is a perfectly good way of accessing methods without instance variables.

Bob

0
 
LVL 7

Author Comment

by:NauticalNonsense
ID: 20354558
Bob, thanks for the dialogue.

The site is basically a Social Engineering type site. For example, on any given number of pages I need to pull repetitive data/code (user's photo, common controls), and then there is the whole personal profiling for people and their objects of possession .. there will likely be thousands of users, hundreds online at any given time, looking at other people's inventories, blogs, photo galleries, etc. All is heavily data-driven and customizable ... data caching will only take me so far since the data is so disparate.

I'm throwing pretty much everything that is reusable into class files to get the data, but it sounds like I might be better off considering user controls with the DAL closer to that... but then again, maybe .NET can handle the way I'm laying things out now. Arrrgh. :)

This is a project that I've been developing for 3 years, since ASP.NET 1.1 and I'm in the process of basically doing a total rewrite... looking for some "gotchas" in design and scalability. At the worst case I'll have a great DAL and everything well consolidated in one framework. The best case is that I'm dong the right thing and everything runs like a champ, but I guess I'm starting to get nervous.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20354592
It you are starting to feel nervous, then you need to think about stress testing your web site.

There are a few tools, and here is a representative list:

How do I stress test my ASP application?
http://classicasp.aspfaq.com/general/how-do-i-stress-test-my-asp-application.html

There is the ACT (Application Center Test) for web applications from Microsoft:

INFO: Application Center Test (ACT) Tests Your Web Applications by Simulating Load
http://support.microsoft.com/default.aspx/kb/307492

Bob
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question