A Place for C Sharpers/.Netters

I Will do coding till last moment of life-Kiran Patil

Archive for the ‘GoodToKnow’ Category

DataSet Vs Custom Entities

Posted by kiranpatils on June 1, 2012

Challenge:

Dear Readers, Apologize for not sharing anything with you since so long. As was bit busy with projects. (But as I told in my earlier posts as well, It’s good to be busy. Because during your busy time you will learn a lot, and needless to say once you get time you will have a lot to share!)

This week, We were discussing what to use for our new project for passing data from one layer to another layer. DataSet Or Entities.

I’m big fan of Entities and Generics. But thought to do some research on it, before concluding anything. And my research revealed that I’m (I know you as well) not only one who is searching on this topic. Lot of people shared their views on web. But I filtered out few links, which I liked most (along-with the Excerpt which is important to read from that link)  and thought to share with you! So, here you go

http://forums.asp.net/t/1129497.aspx/1

“The problem with DataSets is that they tend to be pretty memory hungry. They also get a bit difficult to manage as your application gets larger. When you need more complex solutions, the initial effort that you put into getting custom classes up and running can pay off with shorter development cycles if you do it right. “

Going with custom classes is certainly better in many ways.

i) easier to add logic

ii) business validation is easier. This is tougher when using DataSet

iii) if you are using DataSet, even when the number of rows returned are small, the whole dataset has to be constructed which is quite an overhead. Custom classes are more light-weight

http://codebetter.com/jefferypalermo/2005/05/20/displaying-aggregates-dataset-vs-domain-object-performance-level-300/

“The page that used an array of custom domain objects to present a read-only display was 3.7% FASTER than the same functionality using a DataSet. “

http://blogs.msdn.com/b/reinouth/archive/2006/03/08/546510.aspx

“Now, amazingly, this has sparked somewhat of a religious war between various parties within the project. Just to be clear – I prefer custom objects – partly for their simplicity and readability”

“I agree with you on custom objects, you will have more control and better performance.”

http://blogs.msdn.com/b/irenak/archive/2006/02/27/539832.aspx

  • Memory consumption using Dataset = 290,436 (3.5 times larger than using Products class)
  • Memory consumption using array of objects = 140,028 (1.7 times larger than using Products class)
  • Memory consumption using Product class = 82,656 (BEST)

So, no matter how you turn it, strongly typed custom classes are your best bet in terms of memory consumption!

http://weblogs.asp.net/paolopia/articles/dsvscustomentities.aspx

2) BIZ and DAL are written by people different from the presentation layer group, so they have different knowledge about the data structures

http://www.4guysfromrolla.com/articles/051805-1.aspx

While DataSets are an easy way to return data, I think they are less than ideal for a couple of reasons. First, they add a lot of bloat to the returned XML payload since DataSets return not only the data they contain but also the data’s schema.

In my original article one of my main thrusts for not using DataSets was the performance disparity between DataSets and DataReaders. As I cited from A Speed Freak’s Guide to Retrieving Data in ADO.NET, when bringing in several hundred or thousands of records, a DataSet can take several seconds to be populated, where as a DataReader still boasts sub-second response times. Of course, these comparisons against several hundred to several thousand records are moot if you are working with a much smaller set of data, say just 10 to 50 records in total. For these smaller sized result sets, the DataSet will only cost you less than a second (although the DataReader still is, percentage-wise, much more efficient).

http://swap.wordpress.com/2007/07/10/dataset-vs-custom-entity/

Benefit with Custom Entity Classes

- Take advantage of OO techniques such as inheritance and encapsulation
- You can add custom behavior
- Object-Relational Mapping
- Mapping Custom Collections
- Managing Relationships between two entities in Object oriented way

http://stackoverflow.com/questions/1679064/should-i-use-entity-framework-dataset-or-custom-classes

I would agree with Marc G. 100% – DataSets suck, especially in a WCF scenario (they add a lot of overhead for handling in-memory data manipulation) – don’t use those. They’re okay for beginners and two-tier desktop apps on a small-scale maybe – but I wouldn’t use them in a serious, professional app.

http://www.rosscode.com/blog/index.php?title=datasets_vs_custom_objects&more=1&c=1&tb=1&pb=1

Solution:

So, in summary, as per my understanding, performance, maintainability, and serialization point of view entities looks more promising than DataSet.

Few of my guidelines:

You should use DataSet when:

1. Project is small.
2. Only Single person is going to work on all layers.
3. Data size is small.
4. Application is not going to get changed in future. (Mainly Database structure).
5. You are not worried about Maintainability.

You should use Custom Entities when:

1. Project is big.
2. Different people will be working on different layers.
3. Data size is big.
4. Application is going to get changed in future. (Mainly Database structure).
5. You are worried about Maintainability.
6. If you love to follow OOPs concepts.

These all are my views, and they might look biased toward Entities. Because as i told earlier, I’m big fan of custom entities. But if you would like to use DataSet and have good reasons to use it. Don’t worry go for it!

Happy Coding! :-)

Posted in .NET, ASP.NET, GoodToKnow | Tagged: , , | Leave a Comment »

Good To Know on ASP.NET Application Restarts

Posted by kiranpatils on May 25, 2010

You all may heard about ASP.NET Application restart. If no then it’s really good to know. Today i got few good links which i would like to share with you guys as well:

http://fuchangmiao.blogspot.com/2007/11/aspnet-application-restarts.html

http://blogs.msdn.com/b/johan/archive/2007/05/16/common-reasons-why-your-application-pool-may-unexpectedly-recycle.aspx

http://blogs.msdn.com/b/johan/archive/2008/02/18/monitoring-application-pool-and-application-restarts.aspx

Hope this articles clear all your questions on ASP.NET application restart. If not feel free to drop a comment here.

Posted in ASP.NET, GoodToKnow | 3 Comments »

Embed Almost any Document on Your Website

Posted by kiranpatils on May 14, 2010

Challenge:

one of my friend asked me that how can i embed any document on a webpage? gotcha? Nope? okay let me elaborate functionality in a brief.

1. User can post/upload articles on portal in any format. e.g. .PPT,.PPTX,.DOC,.XLS,.XLSX, PDF.

2. Once uploaded after that user can preview his/her uploaded articles in read only format and in same format on Webpage only. No download required.

This is the big challenge! After searching a bit we found a good site and implemented it. I know you guys are eager to know. how? Okay here you go..

Solution:

There is a nice site called http://embedit.in which supports all our requirements – really great stuff by site developers!

It supports embedding document using three ways:

1. Uploading document manually :- Visit http://embedit.in/ and upload your document.

2. using embedit API :- Visit http://embedit.in/api and you can do all operations programmatically. Wow!! And you can sign in using any of the below option. No new form you need to fill up :-)

image

3. SiteWide :-  Use Sitewide to automatically convert all the links to documents in your website to embeds. You just need to put Javascript reference in your HTML content and rest will be managed by Embedit guys! isn’t is great? So, hurry visit : http://embedit.in/sitewide and have fun!

Our Main Hero is SiteWide – which helped us in fulfilling our requirement.

I know you are eager to see it in action before using it.here you go..

image

image

Looks great na? would like to see within your browser? see this example page : http://embedit.in/sitewide/example

Thanks to my friend for throwing this challenge to me and thanks to Google for searching out embedit.in for me and thanks to embedit.in for developing such a nice functionality!

Happy embedding! :)

Webliography

http://go4webapps.com/2010/04/29/embedit-in-embed-any-document-file-or-webpage-in-your-blog-profile-or-website/

http://www.blogsolute.com/embed-documents-word-ppt-pdf-psd-xls/2838/

Posted in GoodToKnow | Tagged: , | 2 Comments »

 
Follow

Get every new post delivered to your Inbox.

Join 102 other followers