Wrox Programmer Forums
| 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 15th, 2007, 07:22 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default Articles/links that have TBH relevance

The idea of this thread is that articles or links are posted hi-lighting various techniques or tips that can be adapted for use in TBH to either make it more scalable, simpler or generally more elegant. I'll kick off with this article:

http://davidhayden.com/blog/dave/arc...erPattern.aspx

followed by code examples of it's use presently and proposed in TBH:

presently from BLL\Forums\Forum.cs:

        public static Forum GetForumByID(int forumID)
        {
            Forum forum = null;
            string key = "Forums_Forum_" + forumID.ToString();

            if (BaseForum.Settings.EnableCaching && BizObject.Cache[key] != null)
            {
                forum = (Forum)BizObject.Cache[key];
            }
            else
            {
                forum = GetForumFromForumDetails(SiteProvider.Forums.GetFo rumByID(forumID));
                BaseForum.CacheData(key, forum);
            }
            return forum;
        }

proposed/amended:

        public static Forum GetForumByID(int forumID)
        {
            Forum forum = null;
            string key = "Forums_Forum_" + forumID.ToString();

            // get the cachedata upfront into an object
            object data = BizObject.Cache[key];
            if (BaseForum.Settings.EnableCaching && data != null)
            {
                // if test is passed, then set forum to typeof (Forum)data;
                forum = (Forum)data;
            }
            else
            {
                forum = GetForumFromForumDetails(SiteProvider.Forums.GetFo rumByID(forumID));
                BaseForum.CacheData(key, forum);
            }
            return forum;
        }

hope this makes sense. it certainly 'beats' the race condition and the if statement really only tests for cacheing being enabled as well as the data object not being null. if the condition is met, then the Forum forum object is set to the data object as type Forum.

one worth modifying and using throughout.

[edit] the url above is making the page very wide, i couldn't get the standard <a href="www.site.com">description</a> to work. any tips??

jimi

http://www.originaltalent.com
__________________
jimi

http://www.originaltalent.com
The Following User Says Thank You to jimibt For This Useful Post:
jminatel (December 16th, 2008)
 
Old October 15th, 2007, 08:00 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's a good point!

The first version was:

if (BaseForum.Settings.EnableCaching && BizObject.GetCacheData(key) != null)

But, and if you write:

if (BizObject.GetCacheData(key) != null && BaseForum.Settings.EnableCaching)

?

Did you tested if the first condition is FALSE, ASPNET will verify the second condition?
 
Old October 15th, 2007, 08:16 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:( I forgot the Null Check

I'll edit the last post

 
Old October 15th, 2007, 08:36 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Max,

yes, no matter the order of the expressions within the brackets, both will be evaluated. however, if an exception were to occur on the 1st expression, then the second would not be evaluated.


jimi

http://www.originaltalent.com
 
Old October 15th, 2007, 09:06 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Another little TIP. based on a question by trystanc on this forum, he asked about the thread safety of singleton patterns. after a bit of research, i came up with a minor change that addresses the failure in the TBH implementation. anyway, here's a link to the original thread, as well as my code changes below:

http://p2p.wrox.com/topic.asp?TOPIC_ID=65461

here's how my ForumsProvider (DAL\Provider\ForumsProvider.cs) 'intro' looks now:

namespace MB.TheBeerHouse.DAL
{
    public abstract class ForumsProvider : DataAccess
    {
        static private readonly ForumsProvider _instance = (ForumsProvider)Activator.CreateInstance(
                    Type.GetType(Globals.Settings.Forums.ProviderType) );

        static ForumsProvider() { }

        static public ForumsProvider Instance
        {
            get
            {
                return _instance;
            }
        }

        public ForumsProvider()
        {
            this.ConnectionString = Globals.Settings.Forums.ConnectionString;
            this.EnableCaching = Globals.Settings.Forums.EnableCaching;
            this.CacheDuration = Globals.Settings.Forums.CacheDuration;
        }
        // other code below unchanged

hope this makes sense.

jimi

http://www.originaltalent.com
 
Old October 17th, 2007, 06:25 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If someone wants to add Page Threads Links to BrowseThreads Page do follow the link on the bottom.
(This script can redirect too to last page!
If you want to go to the second page of thread127 you use ...showthread.aspx?threadid=127&pg=2
If you want to go to the last page of thread127 you use ...showthread.aspx?threadid=127&pg=last)

The result is:
http://img521.imageshack.us/img521/1...nkpagespm9.jpg

The script is:
http://p2p.wrox.com/topic.asp?TOPIC_ID=65938

 
Old October 18th, 2007, 04:49 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Copenhagen, , Denmark.
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Jimi, I'd nominate your post where you described how to add threads to the breadcrumbs to be posted here, too :)

http://entropia-online.blogspot.com/
 
Old October 18th, 2007, 04:51 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by ViagraFalls
 Jimi, I'd nominate your post where you described how to add threads to the breadcrumbs to be posted here, too :)

http://entropia-online.blogspot.com/
Peter,

ermm - i can't remember that one :). could you add the link??

thanks !!

jimi

http://www.originaltalent.com
 
Old October 18th, 2007, 05:45 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Copenhagen, , Denmark.
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Posted - 03/20/2007 : 4:53:20 PM Report Abuse


--------------------------------------------------------------------------------

TIP!!
========

quick tip (this may have been covered before but it bugged me for a few hours). to get the breadcrumbs to 'follow' from forum to threads, you have to do 2 things:

1. amend the web.sitemap as follows:

      <siteMapNode title="$Resources: SiteMap, Forum" url="~/ShowForums.aspx">
        <siteMapNode title="$Resources: SiteMap, Browse_Threads" url="~/BrowseThreads.aspx" />
        <siteMapNode title="$Resources: SiteMap, Thread" url="~/ShowThread.aspx" />
      </siteMapNode>

2. open the App_GlobalResources\SiteMap.resx and add a new entry:

name: Browse_Threads
Value: Browse Threads

thats it - rebake and your breadcrumbs should now be complete!! :)

Posted by jimi in this thread: http://p2p.wrox.com/topic.asp?TOPIC_...hichpage=1#top

http://entropia-online.blogspot.com/
 
Old June 4th, 2008, 05:01 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

found an interesting article re a project called 'velocity' which describes the 'next' big thing in layering the application architecture. basically, it's a kind of distributed 'super-cache' that sits between the business layer and the data access layer. does it sound familiar :D. anyway, i think the idea would be to have an actual cache layer between the BLL and DAL. you can read the 1st thoughts on it here:

http://blogs.msdn.com/velocity/archi...-velocity.aspx

[edit] plus followup on the initial blog:

http://blogs.msdn.com/velocity/archi...-followup.aspx

jimi

http://www.originaltalent.com




Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox.com C# articles jminatel C# 2005 0 March 23rd, 2007 08:43 PM
Recent articles not showing on articles page kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 December 16th, 2006 10:06 AM
Help with search relevance raybanuk SQL Server ASP 0 September 9th, 2006 03:38 AM
Categorical Articles Beebs BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 9 May 31st, 2006 10:48 PM





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