Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2009, 02:22 PM
Authorized User
 
Join Date: Jun 2009
Posts: 32
Thanks: 17
Thanked 0 Times in 0 Posts
Default Article instance no longer synchronized with the corresponding row in a DB table

hi
Page 233 – Instance method Article.Approve also sets Articles.Approved property to true:

Code:
        public bool Approve()
        {
            bool success = Article.ApproveArticle( this.ID );
            if (success)
               this.Approved = true;
            return success;
        }
So why don’t instance methods Article.IncrementViewCount and Article.Rating also set View, TotalRating and Votes properties accordingly? Since they don’t set these properties, whenever we rate an article or increment its view count, this Article instance is no longer synchronized with the corresponding row in a DB table


Cheers
 
Old October 13th, 2009, 06:07 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I suspect that this is because if an article is approved, you want that to be reflected in the object right away. However, that behavior may not be desirable for other properties such as ViewCount or AverageRating.

For example, let's say an article has been viewed 57 times. When a user pulls it up, the ViewCount will be incremented to 58 in the database, however, the page will still show 57. In other words, it is showing what the ViewCount was before the current user viewed it, which is probably the behavior the author intended.

Whether or not you agree with this behavior is a matter of preference. Either way is valid.

By the way, I wouldn't sweat the instance properties in the BLL too much, as most of them are never actually used anyway.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
carewithl (October 14th, 2009)
 
Old October 14th, 2009, 01:23 PM
Authorized User
 
Join Date: Jun 2009
Posts: 32
Thanks: 17
Thanked 0 Times in 0 Posts
Default

thanx mate

cheers




Similar Threads
Thread Thread Starter Forum Replies Last Post
BLL Article Instance Methods alfinmass BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 August 19th, 2009 05:54 PM
Incrementing member variable in Synchronized block vikkiefd Pro Java 0 March 24th, 2008 04:15 AM
Error in BLL.Article.Article.cs drohm BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 August 14th, 2006 09:56 AM
UPDATING 1 row with another row in same table rit01 SQL Server 2000 3 February 19th, 2006 08:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.