Patrick McElhaney
Member since Dec 11, 2008
- Profile: /members/2026-patrick-mcelhaney.htm
- URL: http://careers.stackoverflow.com/pm
- Comments: 28
Recent Blog Comments By Patrick McElhaney
-
Sometimes I'm Tempted To Use Try / Finally In The Worst Way
Posted on Jul 10, 2015 at 9:10 AM
So you're not happy with the delete operator. Why not create an abstraction that has the semantics you expect? console.log('set', cache.set('foo', 'bar')); console.log('get', cache.get('foo')); console.log('delete', cache.delete('foo')); console.log('delete-again', cache.delete('foo')); Result: se... read more »
-
Providing A Return Value In A JavaScript Constructor
Posted on Sep 5, 2013 at 11:55 AM
When you define a constructor like that "new" becomes redundant (as it should be).... read more »
-
The Clean Code Video Series By Robert C. Martin, aka Uncle Bob
Posted on Mar 28, 2013 at 7:39 PM
I'm the kind of person who learns better by reading. I've read all of Uncle Bob's books and have been studying the subject matter of the videos for about 10 years. Still, these are tough concepts and seeing them presented in a different format really has really helped them sink in. I highly recommen... read more »
-
Chrome Dev Tools "Live Update" In The JavaScript Console Is Confusing
Posted on Aug 9, 2012 at 4:53 PM
Oh, nevermind. It's not asynchronous. This answer explains what's going on. http://stackoverflow.com/a/8249333/437... read more »
-
Chrome Dev Tools "Live Update" In The JavaScript Console Is Confusing
Posted on Aug 9, 2012 at 4:32 PM
The problem is Chrome's console is asynchronous. Instead of waiting for the array to be written to the console, the script goes on to the next line ( calling processSomeData() ). By the time the array is actually output in the console its contents have changed. The reason things like JSON.stringif... read more »
-
Creating A Lazy Loading Utility Module For RequireJS
Posted on Jul 26, 2012 at 9:40 AM
That's a good point, @Jens. The whole thing could probably be reduced to this. var faq; require(['faq'], function () { faq = faq || new FAQ(); faq.open('body'); }); Or more generally: var isInitialized = false; require(['module'], function () { if (!isInitialized) { // do synchronous ... read more »
-
Lazy Loading RequireJS Modules When They Are First Requested
Posted on Jul 24, 2012 at 1:37 PM
Nice thinking, as always! A couple of suggestions: 1. Add another variable to keep track of the status of the FAQ module, rather than overloading the faq variable with that responsibility. If you have another variable like faqModuleStatus and values "notloaded", "loading", "... read more »
-
How Do You Populate Shared Views In A Complex Layout Using MVC?
Posted on Jul 13, 2012 at 11:46 PM
@Kirill is right. The view is supposed to know about the model. That's how MVC works. (More precisely, it knows the model's interface -- and this may be where you got confused -- but not its implementation.) When it comes to aggregation, the aggregate list of tweets is a model. It may have referen... read more »
-
The 5th Annual Regular Expression Day (And Prizes) - June 1st, 2012
Posted on Jun 8, 2012 at 8:53 AM
Best regex day yet. I hope you'll consider expanding on the game as Quincy suggested. Maybe add a time penalty/reward for getting answers wrong/right. (I found that I can cheat by just skipping the \b..\b one.) I love the way that a lot of the regexes have an easily guessable answer (like /M(o)(\1... read more »
-
Branching Logic vs. Guard Logic When It Comes To Function Control Flow
Posted on May 17, 2011 at 12:08 PM
@Scott, Usually guard clauses are used when the function does normally does something non-trivial, but for some inputs a trivial result can be returned. <cffunction name="sluggingPercentage"> <cfif variables.cachedsluggingPercentage neq ""> <cfreturn ... read more »
-
Using jQuery's SlideUp() and SlideDown() Methods With Bottom-Positioned Elements
Posted on Jan 25, 2010 at 10:25 AM
Yeah, that's pretty confusing. Rather than try to keep track in your head that up really means down, you might consider aliasing those methods. $.fn.slideOpen = $.fn.slideDown; $.fn.slideClose = $.fn.slideUp;... read more »
-
National Regular Expression Day And Reflections On My Own Journey
Posted on Jun 5, 2008 at 8:45 AM
Congratulations on getting a mention from Webmonkey! That's a pretty significant honor in my book. BTW, next year I hope you'll expand it to International Regular Expression Day. Let me know if you need help tracking down every instance of "National" and replacing it with "International."... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 29, 2008 at 9:41 AM
I forgot to specify what I want. /Shakespeare RegEx Shirt|Mastering Regular Expressions/... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 28, 2008 at 12:16 PM
$madness =~ /method/... read more »
-
ClearCode Standards Project
Posted on Apr 30, 2008 at 1:35 PM
@Ben, Looking at your div.note {...} rule, my eyes tend to focus on the values before the properties. Values are more visually distinct than properties (especially within an editor that gives different types of values different colors). Also, looking at the CSS for this site, the vast majority of... read more »
-
ClearCode Standards Project
Posted on Apr 30, 2008 at 9:49 AM
Dumb question: Why does the order of attributes / named arguments / CSS properties need to be stable? What does it matter if one cfquery has name first and another has datasource first?... read more »
-
ClearCode Standards Project
Posted on Apr 29, 2008 at 2:27 PM
Great presentation. I only had time to skim through it but loved what I saw! -- +1 to Peter Boughton. I was going to say the same thing about treating logical operators like commas and putting them at the beginning of a line. -- You may have covered this, but I've started paying more attention... read more »
-
Name vs. Variable In ColdFusion
Posted on Mar 14, 2008 at 10:05 AM
Don't forget cfinvoke / returnVariable.... read more »
-
FLV 404 Error On Windows 2003 Server
Posted on Mar 12, 2008 at 8:49 AM
Thanks, Ben! Found this via a Google search for "Flash Video 404." Exactly what I needed. You made my day.... read more »
-
What Does It Mean To Be A CSS Class?
Posted on Feb 13, 2008 at 11:03 AM
Don't forget you can reference multiple classes on the same element with the same css selector. class="alert overdue" .alert {display: block; border: 2px solid black;} .alert.overdue {border-color: red} Patrick... read more »