|
-
Oct 7th, 2003, 06:21 PM
#1
Thread Starter
Stuck in the 80s
[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.
-
Oct 7th, 2003, 06:21 PM
#2
Thread Starter
Stuck in the 80s
If that post is confusing, let me know, and I'll try to explain myself better.
-
Oct 7th, 2003, 08:51 PM
#3
Member
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.
-
Oct 9th, 2003, 01:27 AM
#4
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?
-
Oct 9th, 2003, 10:52 AM
#5
Thread Starter
Stuck in the 80s
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?
-
Oct 10th, 2003, 12:19 PM
#6
In that case, do the <> thing instead. And get more sleep, because you're answering all of your own questions.
-
Oct 10th, 2003, 12:44 PM
#7
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
-
Oct 10th, 2003, 12:54 PM
#8
Member
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
-
Oct 11th, 2003, 05:41 PM
#9
Thread Starter
Stuck in the 80s
Thanks, guys. I'll go with the saving as HTML method.
-
Oct 12th, 2003, 08:02 AM
#10
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.
-
Oct 12th, 2003, 11:24 AM
#11
Thread Starter
Stuck in the 80s
Originally posted by CornedBee
Guess which one is always praised for the speed with which it displays pages
I have no clue. Thanks.
-
Oct 12th, 2003, 01:04 PM
#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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|