Click here to Skip to main content
14,384,739 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Long Lines Pin
PIEBALDconsult21-Oct-19 8:01
protectorPIEBALDconsult21-Oct-19 8:01 
GeneralRe: Long Lines Pin
  Forogar  21-Oct-19 8:40
professional  Forogar  21-Oct-19 8:40 
AnswerRe: Long Lines Pin
ZurdoDev21-Oct-19 6:58
professionalZurdoDev21-Oct-19 6:58 
GeneralRe: Long Lines Pin
PeejayAdams22-Oct-19 0:19
memberPeejayAdams22-Oct-19 0:19 
GeneralRe: Long Lines Pin
PIEBALDconsult21-Oct-19 7:10
protectorPIEBALDconsult21-Oct-19 7:10 
GeneralRe: Long Lines Pin
Gary Wheeler22-Oct-19 3:10
memberGary Wheeler22-Oct-19 3:10 
GeneralRe: Long Lines Pin
Kevin Marois21-Oct-19 7:16
professionalKevin Marois21-Oct-19 7:16 
GeneralRe: Long Lines Pin
Marc Clifton21-Oct-19 10:35
protectorMarc Clifton21-Oct-19 10:35 
PeejayAdams wrote:
Two short-lived variables


Lifetime should not influence readability. I almost always put things into variables not just for readability but that it makes it easier to debug.

Given:

OutputImage(file, allFaces.Where(f => f.Proportion > double.Parse(ConfigurationManager.AppSettings["LowerBound"].ToString()) && f.Proportion < double.Parse(ConfigurationManager.AppSettings["UpperBound"].ToString())).ToList().OrderBy(f => f.Proportion).ThenByDescending(f => f.Rectangle.Height).FirstOrDefault());


I do have a penchant for extension methods. As in:

var face = allFaces
  .AnyBetween(f => f.Proportion, "LowerBound".AppSetting().to_f(), "UpperBound".AppSetting().to_f())
  .OrderBy(f => f.Proportion)
  .ThenByDescending(f => f.Rectangle.Height)
  .FirstOrDefault();
OutputImage(file, face);


As bizarre as it is to extend string, I find it a lot more readable.

The ToList() seems superfluous. Not sure you want to output an image if no images meet the selection criteria. I might move FirstOrDefault into OutputImage(file, face.FirstOrDefault()); as well, who knows, the way you get the faces might be re-usable.

I leave it to the reader to figure out to_f, AnyBetween, and AppSettings Should be obvious.

GeneralRe: Long Lines Pin
PeejayAdams22-Oct-19 0:22
memberPeejayAdams22-Oct-19 0:22 
GeneralRe: Long Lines Pin
PIEBALDconsult22-Oct-19 3:57
protectorPIEBALDconsult22-Oct-19 3:57 
GeneralRe: Long Lines Pin
Member 916705721-Oct-19 21:52
memberMember 916705721-Oct-19 21:52 
GeneralRe: Long Lines Pin
Sander Rossel21-Oct-19 22:55
professionalSander Rossel21-Oct-19 22:55 
GeneralRe: Long Lines Pin
Rolf Borchmann22-Oct-19 1:14
memberRolf Borchmann22-Oct-19 1:14 
GeneralRe: Long Lines Pin
Richard Deeming22-Oct-19 2:35
mveRichard Deeming22-Oct-19 2:35 
GeneralRe: Long Lines Pin
PeejayAdams22-Oct-19 2:45
memberPeejayAdams22-Oct-19 2:45 
GeneralRe: Long Lines Pin
Gary Wheeler22-Oct-19 3:10
memberGary Wheeler22-Oct-19 3:10 
GeneralRe: Long Lines Pin
Dan Neely22-Oct-19 3:53
memberDan Neely22-Oct-19 3:53 
GeneralRe: Long Lines Pin
obermd22-Oct-19 4:35
memberobermd22-Oct-19 4:35 
GeneralRe: Long Lines Pin
Thomas James22-Oct-19 5:36
memberThomas James22-Oct-19 5:36 
GeneralRe: Long Lines Pin
MikeTheFid22-Oct-19 6:51
memberMikeTheFid22-Oct-19 6:51 
GeneralRe: Long Lines Pin
Jan Heckman22-Oct-19 13:11
professionalJan Heckman22-Oct-19 13:11 
GeneralThought of the Day Pin
OriginalGriff21-Oct-19 5:38
protectorOriginalGriff21-Oct-19 5:38 
GeneralRe: Thought of the Day Pin
lopatir21-Oct-19 6:12
memberlopatir21-Oct-19 6:12 
GeneralRe: Thought of the Day Pin
Kschuler21-Oct-19 6:44
memberKschuler21-Oct-19 6:44 
GeneralRe: Thought of the Day Pin
jeron121-Oct-19 6:46
memberjeron121-Oct-19 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.