Article 6QK4K CodeSOD: Take a Line Break

CodeSOD: Take a Line Break

by
Remy Porter
from The Daily WTF on (#6QK4K)

The number of web applications which need to generate PDFs is too damn high, in my experience. But it's a requirement which continues to exist for a variety of reasons, so we just have to accept it.

Derek was accepting of it, at least until he found this attempt to add ten lines of space between paragraphs.

 var pgText2N2 = section.AddParagraph(); pgText2N2.Format.Alignment = ParagraphAlignment.Right; pgText2N2.Format.RightIndent = rightMargin; var pgText2N3 = section.AddParagraph(); pgText2N3.Format.Alignment = ParagraphAlignment.Right; pgText2N3.Format.RightIndent = rightMargin; var pgText2N4 = section.AddParagraph(); pgText2N4.Format.Alignment = ParagraphAlignment.Right; pgText2N4.Format.RightIndent = rightMargin; var pgText2N = section.AddParagraph(); pgText2N.Format.Alignment = ParagraphAlignment.Right; pgText2N.Format.RightIndent = rightMargin; var pgText3N = section.AddParagraph(); pgText3N.Format.Alignment = ParagraphAlignment.Right; pgText3N.Format.RightIndent = rightMargin; var pgText4N = section.AddParagraph(); pgText4N.Format.Alignment = ParagraphAlignment.Right; pgText4N.Format.RightIndent = rightMargin; var pgText5N = section.AddParagraph(); pgText5N.Format.Alignment = ParagraphAlignment.Right; pgText5N.Format.RightIndent = rightMargin; var pgText6N = section.AddParagraph(); pgText6N.Format.Alignment = ParagraphAlignment.Right; pgText6N.Format.RightIndent = rightMargin; var pgText7N = section.AddParagraph(); pgText7N.Format.Alignment = ParagraphAlignment.Right; pgText7N.Format.RightIndent = rightMargin; var pgText8N = section.AddParagraph(); pgText8N.Format.Alignment = ParagraphAlignment.Right; pgText8N.Format.RightIndent = rightMargin;

This falls into the common WTF of "hey, have you ever heard of a loop? Or an array?".

These variables are never actually used or referenced anywhere, which arguably makes their cryptic, meaningless names better, but... does it? Also, given that this is ten blank lines, do we actually need to set the alignment and indent on them? Maybe- I don't know this PDF generating library, but if so, that's it's own WTF. And while we're at it, I'm no expert in PDFs, but there's gotta be some way to just include space without spamming a bunch of paragraphs in the document.

At this point, though, I'd just take a loop.

proget-icon.png [Advertisement] ProGet's got you covered with security and access controls on your NuGet feeds. Learn more.
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments