Results 1 to 12 of 12

Thread: [Resolved] Need help with some logic

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] Need help with some logic

    In one of my programs (news management), I allow the user to use [tags] if they want (just like here). When I store their submitted text, I store it with the [tags] in place.

    When the submitted text is displayed in another part of the program, it parses through the text and replaces the [tags] with their similiar <html>.

    Now, should I continue to do it this way, or should I parse the text and save it with the HTML already converted? It seems this would save some time and resources when displaying it, but...

    ...the user can also edit their submitted text. So when they go to edit it, I would have to convert the html entities back into the [tags], because the program has the ability to parse out HTML.

    So it would seem efficient to not have to parse the [tags] every time it is displayed, but by doing so, it would put all that work end on editting the items.

    Of course, the text will be viewed many, many more times than it would be editted. It just seems like weird programming to convert to html, convert back to [tags], and then convert back to html during editting.

    Which method would be best, in your opinion?
    Last edited by The Hobo; Oct 11th, 2003 at 05:41 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    If that post is confusing, let me know, and I'll try to explain myself better.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Make a "parser" and a "unparser". I think it'd be best to store it as HTML, and then just "unparse" it back into the tags when editting.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    It's best to keep it as it is. The parser to convert [] to <> would be used only when displaying. And no work is required while editing.

    If you go for the other option, the parser converts <> to [] only when editing. No work while displaying.

    Doesn't make much of a difference, does it?

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Yes, it does.

    Like I said above (I think), the items would be viewed far more often then they would be editted. It's a news management program.

    So the news item would be viewed often (depending on the traffic of the site), and then it would have to be converted everytime. However, it is very likely, at least in my experience, that most news items will never be editted.

    Does that make sense, or should I have gotten more sleep last night?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    In that case, do the <> thing instead. And get more sleep, because you're answering all of your own questions.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Another option (and I only propose this as a "thinking outside the box" answer)....
    Store (don't shoot me) both raw text the user would enter/edit, and the "pre-parsed" text with <> tags.... when being displayed, use the preprocessed text, and if the user edits it, display the raw text, then when saving it, parse it once and store that as well.
    Did that make sense, or am I smoking something again.... yes, I do realize it will double the size of each record.....but it would allow it to be quicker on both ends.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    I think the cons over weigh the pros in that one. Considering an article is editted 1 out of 10 times less the amount it is viewed (mabe less?), taking up double the amount of space seems worse then waiting an extra .003 seconds

  9. #9

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Thanks, guys. I'll go with the saving as HTML method.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Just for your information, vBulletin (like at vbforums.com) stores with the [] tags in place and parses on display. Invision Board (like on some forums that may not be mentioned) stores the converted stuff.

    Guess which one is always praised for the speed with which it displays pages
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by CornedBee
    Guess which one is always praised for the speed with which it displays pages
    I have no clue. Thanks.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width