<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>LA.NET [EN]</title>
	
	<link>http://luisabreu.wordpress.com</link>
	<description>Ramblings about C#, .NET and Programming</description>
	<lastBuildDate>Tue, 18 Jun 2013 07:45:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain="luisabreu.wordpress.com" port="80" path="/?rsscloud=notify" registerProcedure="" protocol="http-post" />
<image>
		<url>http://1.gravatar.com/blavatar/f72534352f1aa2540d398b6d8e515b66?s=96&amp;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>LA.NET [EN]</title>
		<link>http://luisabreu.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://luisabreu.wordpress.com/osd.xml" title="LA.NET [EN]" />
	
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Laneten" /><feedburner:info uri="laneten" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://luisabreu.wordpress.com/?pushpress=hub" /><item>
		<title>Book review: Propose, prepare, present: hot to become a successful, effective and popular speaker at industry conferences</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/UsiC9EHv4I8/</link>
		<comments>http://luisabreu.wordpress.com/2013/06/18/book-review-propose-prepare-present-hot-to-become-a-successful-effective-and-popular-speaker-at-industry-conferences/#comments</comments>
		<pubDate>Tue, 18 Jun 2013 07:45:49 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1827</guid>
		<description><![CDATA[[Disclaimer: I’ve received a copy of this book for reviewing] In this (really!) short book, Alistair Croll presents you several tips on how to improve your chances of becoming a good professional speaker. Alistair starts by introducing the conference industry world. Having an idea about how it works is important for understanding the risks and [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1827&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>[Disclaimer: I’ve received a copy of this book for reviewing]</p>
<p>In this (really!) short <a href="http://www.amazon.com/Propose-Prepare-Present-successful-conferences/dp/product-description/1449366376/ref=dp_proddesc_0?ie=UTF8&amp;n=283155&amp;qid=1371540086&amp;s=books&amp;sr=8-1">book</a>, Alistair Croll presents you several tips on how to improve your chances of becoming a good professional speaker. Alistair starts by introducing the conference industry world. Having an idea about how it works is important for understanding the risks and obstacles you might face. After this introduction, you’ll see how you can adapt an idea to a specific type of event. As you’ll find out (if you read the book), having a good idea is not enough for making into the conference as a presenter. You’ll probably need to have one or two good topics, write a good CFP about it and, if you get picked, you’ll probably need to adapt it to the available sessions/slots. </p>
<p>Chapter 3 is a great one because it will present several tips that will help you get chosen from the available candidates. It also presents several things which will probably hurt you during the process, so you should really pay attention to this chapter. The last two chapters give you some tips on how to improve your presentations and on how you can improve your chances of making money at these conferences.</p>
<p>Typically, this is not the sort of book I read. However, I was looking for something to give me some tips on this subject (conferences) and this book was really what I needed to get an overall look on the topic. Overall, I’m giving it a 7/10.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1827/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1827/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1827&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/UsiC9EHv4I8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/06/18/book-review-propose-prepare-present-hot-to-become-a-successful-effective-and-popular-speaker-at-industry-conferences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/06/18/book-review-propose-prepare-present-hot-to-become-a-successful-effective-and-popular-speaker-at-industry-conferences/</feedburner:origLink></item>
		<item>
		<title>Book review: UX for Lean Startups</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/kw6IUUpkZr4/</link>
		<comments>http://luisabreu.wordpress.com/2013/06/07/book-review-ux-for-lean-startups/#comments</comments>
		<pubDate>Fri, 07 Jun 2013 07:41:20 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1825</guid>
		<description><![CDATA[[Disclaimer: I’ve received a copy of this book for reviewing.] Nowadays, there are no doubts about the role UX plays in getting a great product. Unfortunately, UX is generally associated with costly processes which involve lots of design. In this book, Laura Klein does an excellent job in showing you how to apply several techniques [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1825&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>[Disclaimer: I’ve received a copy of this book for reviewing.]</p>
<p>Nowadays, there are no doubts about the role UX plays in getting a great product. Unfortunately, UX is generally associated with costly processes which involve lots of design. In this <a href="http://www.amazon.com/UX-Lean-Startups-Experience-Research/dp/1449334911/ref=sr_1_1?ie=UTF8&amp;qid=1370589863&amp;sr=8-1&amp;keywords=ux+lean">book</a>, Laura Klein does an excellent job in showing you how to apply several techniques in&#160; order to reduce the time and money which is typically spent in this area.</p>
<p>Even though the book has UX in its title, the truth is that book concentrates on showing you several techniques that will help you continuously test the user experience. No, I’m not talking about color use or stuff like that. I’m talking about techniques which will help you validate if the problem you’re trying to solve deserves to be solved (ie, should you be wasting your time and money building this product) or that will improve the way you run your qualitative and quantitative research and testing. In other words, Laura introduces several approaches which will help you apply lean principles to UX design.</p>
<p>Looking at its title (UX for Lean Startups) might mislead you into thinking that this book is for someone who wants to create a startup. In my opinion, it’s not. In fact, I’d say that given the importance that UX plays in software, the book’s title should be something like UX for Lean Developers. But hey, that’s just me <img class="wlEmoticon wlEmoticon-smile" style="border-style:none;" alt="Smile" src="http://luisabreu.files.wordpress.com/2013/06/wlemoticon-smile.png?w=497" /></p>
<p>Overall, I’m giving it a 8/10.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1825/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1825/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1825&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/kw6IUUpkZr4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/06/07/book-review-ux-for-lean-startups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>

		<media:content url="http://luisabreu.files.wordpress.com/2013/06/wlemoticon-smile.png" medium="image">
			<media:title type="html">Smile</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/06/07/book-review-ux-for-lean-startups/</feedburner:origLink></item>
		<item>
		<title>My ASP.NET 4.5 is out</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/VKHFLsHWyM8/</link>
		<comments>http://luisabreu.wordpress.com/2013/04/04/my-asp-net-4-5-is-out/#comments</comments>
		<pubDate>Thu, 04 Apr 2013 11:08:10 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1822</guid>
		<description><![CDATA[I’ve been so busy that I’ve forgot to mention that my ASP.NET 4.5 book (written in Portuguese) is out.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1822&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve been so busy that I’ve forgot to mention that my ASP.NET 4.5 book (written in Portuguese) is <a href="http://www.fca.pt/cgi-bin/fca_main.cgi/?isbn=978-972-722-760-0&amp;op=2">out</a>. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1822/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1822/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1822&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/VKHFLsHWyM8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/04/04/my-asp-net-4-5-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/04/04/my-asp-net-4-5-is-out/</feedburner:origLink></item>
		<item>
		<title>Book review: CLR via C#</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/nkNZJq4W33E/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/25/book-review-clr-via-c-2/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 19:56:37 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1821</guid>
		<description><![CDATA[[Disclaimer: I’ve received a copy of this book for reviewing] Yesterday I’ve finally finished reading Jeffrey Richter’s last book CLR via C#, 4th edition. I’ve been getting a copy of this book (buying or being lucky enough to get a review copy) since it was called Applied Microsoft .NET Framework Programming. Each new edition ends [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1821&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>[Disclaimer: I’ve received a copy of this book for reviewing]</p>
<p>Yesterday I’ve finally finished reading Jeffrey Richter’s last book <a href="http://www.amazon.co.uk/CLR-Via-Edition-Developer-Reference/dp/0735667454/ref=sr_1_1?ie=UTF8&amp;qid=1361821594&amp;sr=8-1">CLR via C#, 4th edition</a>. I’ve been getting a copy of this book (buying or being lucky enough to get a review copy) since it was called <a href="http://www.amazon.co.uk/Applied-Microsoft-NET-Framework-Programming/dp/0735614229/ref=sr_1_14?ie=UTF8&amp;qid=1361821739&amp;sr=8-14">Applied Microsoft .NET Framework Programming</a>. Each new edition ends up adding new cool stuff and this last edition didn’t disappoint. Besides Garbage Collector chapter rewrite, this latest edition introduces the new Reflection API (introduced by .NET 4.5)&#160; and presents several new concepts associated with the new WinRT framework. If you’re a die hard C# programmer, you should be pleased to know that the book has been updated to illustrate the new C# 5.0 async features introduced by the latest .NET framework release.</p>
<p>So, this is really a book I love and fortunately for us developers, Jeffrey has been doing an excellent job of maintaining and updating it during these last years. In my opinion, this is still the .NET reference book every developer should buy and read. My score: 10/10.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1821/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1821&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/nkNZJq4W33E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/25/book-review-clr-via-c-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/25/book-review-clr-via-c-2/</feedburner:origLink></item>
		<item>
		<title>Book review: The art of SEO</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/MwsfpE-rncM/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/18/book-review-the-art-of-seo/#comments</comments>
		<pubDate>Mon, 18 Feb 2013 15:22:12 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1820</guid>
		<description><![CDATA[[Disclaimer: I’ve received a free copy of this book for reviewing] In these last couple of days, I’ve spent most of my free time reading this book. It’s a really thick book (I must confess that is was way more thicker than I was expecting initially). It does cover a lot of ground and it’s [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1820&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>[Disclaimer: I’ve received a free copy of this book for reviewing]</p>
<p>In these last couple of days, I’ve spent most of my free time reading this <a href="http://www.amazon.com/The-Art-SEO-Mastering-Optimization/dp/B008SMJ1SO/ref=cm_cr_pr_product_top">book</a>. It’s a really thick book (I must confess that is was way more thicker than I was expecting initially). It does cover a lot of ground and it’s probably the best reference on the subject available on print. It’s a little dense and I wouldn’t recommend it to someone who is just starting doing web development. Even though it covers several topics in depth, I must say that chapter 7 is really a must for anyone interested in understanding how links are used for ranking pages.</p>
<p>Even though the book has lots of examples (I think it would be better to reduce them, specially the ones presented in the first chapters), this isn’t a platform specific book. In other words, don’t expect to get instructions on how to perform a specific task for server A or platform B. Instead, expect to find lots of examples that can be used across all platforms. Overall, I liked the book and that’s why I’m giving it an 8/10.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1820/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1820/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1820&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/MwsfpE-rncM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/18/book-review-the-art-of-seo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/18/book-review-the-art-of-seo/</feedburner:origLink></item>
		<item>
		<title>The–LiteralPath parameter</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/i1Z-YOIZ1RM/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/15/theliteralpath-parameter/#comments</comments>
		<pubDate>Fri, 15 Feb 2013 13:02:46 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1819</guid>
		<description><![CDATA[It’s 2013, we’ve got Powershell for a couple of years now, so it’s only natural to automate things, right? At least, that’s what I try to do. So, one of the things I’ve ended up doing some time ago was writing a simple script for copying files from an USB pen to a specific folder. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1819&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It’s 2013, we’ve got <a href="http://technet.microsoft.com/en-us/library/bb978526.aspx">Powershell</a> for a couple of years now, so it’s only natural to automate things, right? At least, that’s what I try to do. So, one of the things I’ve ended up doing some time ago was writing a simple script for copying files from an USB pen to a specific folder. As you can see, it’s really simple:</p>
<pre><code>ls j:\ | foreach { 
  $itemName = $_.Name.Replace('.', ' ') 
  $destination = ls | where { $itemName -match $_.Name } | select -First 1 
  if( $destination -ne $null){       
   mi $_.PSPath $destination.PSPath -Verbose -WhatIf  
  } 
}</code></pre>
<p>After some time where everything seemed to be running ok, I’ve noticed that some of the files weren’t being copied. After further analysis, I’ve noted that files contained the [ and ] chars weren’t being copied. Fortunately, we have <a href="http://stackoverflow.com/">StackOverflow</a> and I’ve ended posting my <a href="http://stackoverflow.com/questions/14842927/powershell-moving-items-not-working-when-filenames-that-have-chars">question</a> over there. One of the answers suggested to use the –LiteralPath parameter for the <a href="http://technet.microsoft.com/en-us/library/hh849852.aspx">move-item</a> cmdlet. According to the docs, the –LiteralPath parameter :</p>
<blockquote>
<p>Specifies the path to the current location of the items. Unlike Path, the value of LiteralPath is used <strong>exactly as it is typed</strong>. No characters are interpreted as <strong>wildcards</strong>. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.</p>
</blockquote>
<p><font style="background-color:#1b1814;">Did you notice the wildcards part? Yep, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa717088(v=vs.85).aspx">wildcards</a>…unfortunately form me, I had completely forgotten that [] define wildcards which match a range of characters (note to self: do read the PowerShell docs). For instance, and this is just copied from the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa717088(v=vs.85).aspx">docs</a>, here’s a quick example:</font></p>
<p><font style="background-color:#1b1814;"></font>[a-l]ook matches book, cook or look, but not took.</p>
<p>Aha! ok, now it makes sense…that’s why those files which contained the [ ] on its name weren’t being copied. PowerShell was translating the values defined within [ ]&#160; into ranges. Another note to self: don’t forget about wildcards when you’re writing PowerShell scripts. </p>
<p>And that’s it for now. Stay tuned for more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1819/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1819&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/i1Z-YOIZ1RM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/15/theliteralpath-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/15/theliteralpath-parameter/</feedburner:origLink></item>
		<item>
		<title>Updated material for ASP.NET MVC book</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/GuYefX2cpko/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/14/updated-material-for-asp-net-mvc-book/#comments</comments>
		<pubDate>Thu, 14 Feb 2013 21:04:04 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1818</guid>
		<description><![CDATA[If you’ve bought the ASP.NET book I’ve written, you’ll probably be happy to know that I’ve added a new online chapter that deepens the initial cover of the Web API presented in chapter 9 of the book. If you’ve bought the book, just head to the web site and download the extra material associated with [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1818&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If you’ve bought the <a href="http://www.fca.pt/cgi-bin/fca_main.cgi/?op=2&amp;isbn=978-972-722-742-6">ASP.NET book</a> I’ve written, you’ll probably be happy to know that I’ve added a new <a href="http://www.fca.pt/cgi-bin/fca_main.cgi/?op=2&amp;isbn=978-972-722-742-6">online chapter</a> that deepens the initial cover of the <a href="http://www.asp.net/web-api">Web API</a> presented in chapter 9 of the book. If you’ve bought the book, just head to the <a href="http://www.fca.pt/cgi-bin/fca_main.cgi/?op=2&amp;isbn=978-972-722-742-6">web site</a> and download the extra material associated with the book.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1818/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1818&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/GuYefX2cpko" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/14/updated-material-for-asp-net-mvc-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/14/updated-material-for-asp-net-mvc-book/</feedburner:origLink></item>
		<item>
		<title>Modules: overriding properties</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/c8IVMGV0ou0/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/14/modules-overriding-properties/#comments</comments>
		<pubDate>Thu, 14 Feb 2013 15:33:19 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1817</guid>
		<description><![CDATA[As we’ve seen in the previous post, we can add properties to an object exposed by a module through a technique known as augmentation. Even though there are some advantages associated with the approach shown (ex.: no need for loading scripts in a specific order), the truth is that we’re out of luck if we [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1817&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>As we’ve seen in the previous <a href="http://feedproxy.google.com/~r/Laneten/~3/VJEssoUxqsU/">post</a>, we can add properties to an object exposed by a module through a technique known as augmentation. Even though there are some advantages associated with the <a href="http://feedproxy.google.com/~r/Laneten/~3/VJEssoUxqsU/">approach shown</a> (ex.: no need for loading scripts in a specific order), the truth is that we’re out of luck if we need to “override” a property defined in one of the files of the module. As I’ve said, in this case order of loading is important and there’s no way around it (after all, if we’re augmenting a property, it surely must have already been defined before being augmented, right?).</p>
<p>In order to illustrate this approach, we’ll rewrite the <a href="http://A partir de Janeiro passa a vigorar um novo modelo para emiss&atilde;o das facturas, a factura simplificada que deve ser entregue ao ao cliente, mas para esse documento dar direito &agrave; dedu&ccedil;&atilde;o, o cliente ter&aacute; que disponibilizar o n&uacute;mero de identifica&ccedil;&atilde;o fiscal, que deve ser incluido na factura.">previous example</a>. We’ll remove the jQuery dependency and will change the code so that each file defines&#160; a single printValue (file 2 overrides and augments this method). The following snippet shows the code I’ve ended writing in each file (assume we’re using strict mode and that file 1 is loaded before file 2):</p>
<div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:022fdba7-d99b-4d8b-bde8-8d2bb29db723" class="wlWriterEditableSmartContent" style="float:none;margin:0;display:inline;padding:0;">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background-color:#000000;max-height:500px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#000000;color:#808080;">//file1</span><br /> <span style="background:#000000;color:#cc7832;">var</span><span style="background:#000000;color:#ffffff;"> obj = (</span><span style="background:#000000;color:#cc7832;">function</span><span style="background:#000000;color:#ffffff;"> (baseModule) {</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#cc7832;">var</span><span style="background:#000000;color:#ffffff;"> someValue = </span><span style="background:#000000;color:#a5c25c;">&quot;private&quot;</span><span style="background:#000000;color:#ffffff;">;</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#cc7832;">function</span><span style="background:#000000;color:#ffffff;"> printValue(elemSelector) {</span><br /> <span style="background:#000000;color:#ffffff;">        </span><span style="background:#000000;color:#cc7832;">return</span><span style="background:#000000;color:#ffffff;"> someValue;</span><br /> <span style="background:#000000;color:#ffffff;">    }</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#cc7832;">return</span><span style="background:#000000;color:#ffffff;"> {</span><br /> <span style="background:#000000;color:#ffffff;">        printValue: printValue</span><br /> <span style="background:#000000;color:#ffffff;">    };</span><br /> <span style="background:#000000;color:#ffffff;">})();</span><br /> <span style="background:#000000;color:#808080;">//file2</span><br /> <span style="background:#000000;color:#ffffff;">(</span><span style="background:#000000;color:#cc7832;">function</span><span style="background:#000000;color:#ffffff;"> (baseModule) {</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#cc7832;">var</span><span style="background:#000000;color:#ffffff;"> someOtherValue = </span><span style="background:#000000;color:#a5c25c;">&quot;private 2&quot;</span><span style="background:#000000;color:#ffffff;">;</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#808080;">//save reference to overriden method</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#cc7832;">var</span><span style="background:#000000;color:#ffffff;"> otherModulePrintAnotherValue = baseModule.printValue;</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#cc7832;">function</span><span style="background:#000000;color:#ffffff;"> printValueOverride(elemSelector) {</span><br /> <span style="background:#000000;color:#ffffff;">        </span><span style="background:#000000;color:#cc7832;">return</span><span style="background:#000000;color:#ffffff;"> otherModulePrintAnotherValue() + </span><span style="background:#000000;color:#a5c25c;">&quot;&#8212;&quot;</span><span style="background:#000000;color:#ffffff;"> + someOtherValue;</span><br /> <span style="background:#000000;color:#ffffff;">    }</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#808080;">//change reference to new method</span><br /> <span style="background:#000000;color:#ffffff;">    baseModule.printValue = printValueOverride;</span><br /> <span style="background:#000000;color:#ffffff;">})(obj);</span></div>
</p></div>
</p></div>
<p>If you compare this code with the one we had before, you’ll notice several differences. The most interesting part happens within the anonymous function defined in file2. As you can see, I start by saving a reference to the printValue method which was defined by the module introduced by file1. This reference is used by another function which will end up overriding the initial printValue method. Without this reference, it would be impossible to call the function after performing the override. From now on, you can simply call the overridden function like this (assuming we’ve got an element with ID set to info):</p>
<div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a55d6571-e25a-44f7-9075-c20fbd1a88c5" class="wlWriterEditableSmartContent" style="float:none;margin:0;display:inline;padding:0;">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background-color:#000000;max-height:500px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#000000;color:#ffffff;">&lt;</span><span style="background:#000000;color:#e8bc64;">script</span><span style="background:#000000;color:#ffffff;">&gt;</span><br /> <span style="background:#000000;color:#ffffff;">    </span><span style="background:#000000;color:#a5c25c;">&quot;use strict&quot;</span><span style="background:#000000;color:#ffffff;">;</span><br /> <span style="background:#000000;color:#ffffff;">    $(</span><span style="background:#000000;color:#a5c25c;">&quot;#info&quot;</span><span style="background:#000000;color:#ffffff;">).text(obj.printValue());</span><br /> <span style="background:#000000;color:#ffffff;">&lt;/</span><span style="background:#000000;color:#e8bc64;">script</span><span style="background:#000000;color:#ffffff;">&gt;</span></div>
</p></div>
</p></div>
<p>And that’s it for now. Stay tuned for more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1817/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1817/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1817&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/c8IVMGV0ou0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/14/modules-overriding-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/14/modules-overriding-properties/</feedburner:origLink></item>
		<item>
		<title>More about modules: augmentation</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/VJEssoUxqsU/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/07/more-about-modules-augmentation/#comments</comments>
		<pubDate>Thu, 07 Feb 2013 22:15:55 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1816</guid>
		<description><![CDATA[In the previous posts, I’ve introduced some basics aspects related to the implementation of the module pattern in JavaScript. Even though it introduces several benefits, there are some problems that might make you think that this pattern isn’t for you. For instance, if you’re working in a team where several members are contributing to the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1816&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the <a href="http://feedproxy.google.com/~r/Laneten/~3/hhu2a1_xsto/">previous</a> <a href="http://feedproxy.google.com/~r/Laneten/~3/UTNX279FvAo/">posts</a>, I’ve introduced some basics aspects related to the implementation of the module pattern in JavaScript. Even though it introduces several benefits, there are some problems that might make you think that this pattern isn’t for you. For instance, if you’re working in a team where several members are contributing to the same module at the same time, then your best option is to spread&#160; the module across different files. </p>
<p>Before going on, I must confess that splitting modules across different files isn’t really something I love. Whenever I’m facing this decision, I always try to re-check my code and see if I can refactor it so that a module is defined in a single file. There are, however, some cases where that isn’t possible and in those cases we need strategies like augmentation. The best way to illustrate it is to show an example. We’ll augment the module introduced in the previous <a href="http://feedproxy.google.com/~r/Laneten/~3/UTNX279FvAo/">post</a> by adding a new method. Here’s one way to do it (notice that this code should be placed into a different JavaScript file):</p>
<div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c678316-bcd6-4002-9d40-ca69f2145355" class="wlWriterEditableSmartContent" style="float:none;margin:0;display:inline;padding:0;">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background-color:#000000;max-height:500px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">,</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">someOtherValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#d69d85;">&quot;private 2&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">).</span><span style="background:#1e1e1e;color:#ffffff;">text</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">someOtherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">.</span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">return</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">}</span><span style="background:#1e1e1e;color:#b4b4b4;">)(</span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#b4b4b4;">,</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">jQuery</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#b4b4b4;">.</span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#d69d85;">&quot;#info&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#b4b4b4;">.</span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#d69d85;">&quot;#info2&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span></div>
</p></div>
</p></div>
<p>Notice that this second anonymous function receives a reference to the original module which is being augmented (besides the jQuery global reference). There’s a slight gotcha with the previous code: you need to preserve the correct order when importing the files of the module. In the previous sample, that is not needed because none of the files uses properties defined in the other module, so we should do everything in our power to remove that dependency. Fortunately for us, we can remove that restriction by slightly changing the code: </p>
<div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5edbd45a-26b5-4053-944c-b10a5d590070" class="wlWriterEditableSmartContent" style="float:none;margin:0;display:inline;padding:0;">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background-color:#000000;max-height:500px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">,</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">someValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#d69d85;">&quot;private&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">).</span><span style="background:#1e1e1e;color:#ffffff;">text</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">someValue</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span></p>
<p> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">.</span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">return</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">}</span><span style="background:#1e1e1e;color:#b4b4b4;">)(</span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">||</span><span style="background:#1e1e1e;color:#dcdcdc;"> {}</span><span style="background:#1e1e1e;color:#b4b4b4;">,</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">jQuery</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">,</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">someOtherValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#d69d85;">&quot;private 2&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">).</span><span style="background:#1e1e1e;color:#ffffff;">text</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">someOtherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">.</span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printAnotherValue</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">return</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">baseModule</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">}</span><span style="background:#1e1e1e;color:#b4b4b4;">)(</span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">||</span><span style="background:#1e1e1e;color:#dcdcdc;"> {}</span><span style="background:#1e1e1e;color:#b4b4b4;">,</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">jQuery</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span></div>
</p></div>
</p></div>
<p>According to the standard, the operator || will return the first expression when it’s convertible to true. If that isn’t possible, then it will return the second expression. In my example, we can use an empty object ({}) to ensure that we’re always working with a valid object within the anonymous functions that define the module. Since there is no dependency between the files, then this is more than enough for removing the order dependency introduced by our first snippet.</p>
<p>Even though the previous snippet allows one method to call another (ie, if, for instance, we need to call printValue from within printAnotherValue at runtime, then we should be fine), if we need to access&#160; properties in order to override them, then we’re out of luck . In these cases, we need to change the and there’s no way to escape the need to preserve the loading order. That will be the topic for another post. Stay tuned for more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1816/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1816/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1816&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/VJEssoUxqsU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/07/more-about-modules-augmentation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/07/more-about-modules-augmentation/</feedburner:origLink></item>
		<item>
		<title>JavaScript: more about the module pattern</title>
		<link>http://feedproxy.google.com/~r/Laneten/~3/UTNX279FvAo/</link>
		<comments>http://luisabreu.wordpress.com/2013/02/05/javascript-more-about-the-module-pattern/#comments</comments>
		<pubDate>Tue, 05 Feb 2013 22:28:39 +0000</pubDate>
		<dc:creator>Luis Abreu</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">https://luisabreu.wordpress.com/?p=1815</guid>
		<description><![CDATA[In the previous post, we’ve started looking at the module pattern and how we can use it to write modular JavaScript code. I’ve ended the post mentioning that we still need to discuss an important topic before wrapping up the basics aspects associated with the pattern. If you’ve been following along, you know I’m talking [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1815&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the previous <a href="http://feedproxy.google.com/~r/Laneten/~3/hhu2a1_xsto/">post</a>, we’ve started looking at the module pattern and how we can use it to write modular JavaScript code. I’ve ended the <a href="http://feedproxy.google.com/~r/Laneten/~3/hhu2a1_xsto/">post</a> mentioning that we still need to discuss an important topic before wrapping up the basics aspects associated with the pattern. If you’ve been following along, you know I’m talking about dependencies. In order to illustrate the topic, I’ll modify the previous example so that we use <a href="www.jquery.com">jQuery</a> to print the message inside an element whose ID will be passed as a parameter. The next snippet shows our final code:</p>
<div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:52621442-cb80-4b2f-a587-a33a1e4f247a" class="wlWriterEditableSmartContent" style="float:none;margin:0;display:inline;padding:0;">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background-color:#000000;max-height:500px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">()</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">someValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#d69d85;">&quot;private&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">).</span><span style="background:#1e1e1e;color:#ffffff;">text</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">someValue</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">return</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">:</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">}</span><span style="background:#1e1e1e;color:#b4b4b4;">)();</span><br /> <span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#b4b4b4;">.</span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#d69d85;">&quot;#info&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span></div>
</p></div>
</p></div>
<p>Now, if you’ve been doing JS for some time, you’ve probably noticed something which might get you worried: we’re depending on a global. Technically, $ is an alias to the jQuery global object. In other words, were depending on an implied global and whenever the JS interpreter engine finds one, it’ll have to walk the scope chain backwards until it finds a valid reference (in our example, it’ll walk until it gets to the global scope). Now, in our case, we’d end with an error if jQuery hasn’t been imported before our script gets run. Things could be worse though. For instance, suppose we were using the implied global in the left sign of an assignment expression. In that case, if the global didn’t exist, we’d end up creating a new one (if we were not running in strict mode).</p>
<p>Fortunately, there’s an easy solution for this kind of problem: I’m talking about global imports. Whenever you need a reference to a global variable within the closure created by the anonymous function, you just pass it as a parameter. The next snippet shows this strategy in action:</p>
<div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e915476d-a09b-4c14-ba90-1cb41d8cad89" class="wlWriterEditableSmartContent" style="float:none;margin:0;display:inline;padding:0;">
<div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background-color:#000000;max-height:500px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">obj</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">var</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">someValue</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#b4b4b4;">=</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#d69d85;">&quot;private&quot;</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">function</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">)</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">$</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">elemSelector</span><span style="background:#1e1e1e;color:#b4b4b4;">).</span><span style="background:#1e1e1e;color:#ffffff;">text</span><span style="background:#1e1e1e;color:#b4b4b4;">(</span><span style="background:#1e1e1e;color:#ffffff;">someValue</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    </span><span style="background:#1e1e1e;color:#569cd6;">return</span><span style="background:#1e1e1e;color:#dcdcdc;"> {</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">        </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><span style="background:#1e1e1e;color:#b4b4b4;">:</span><span style="background:#1e1e1e;color:#dcdcdc;"> </span><span style="background:#1e1e1e;color:#ffffff;">printValue</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">    }</span><span style="background:#1e1e1e;color:#b4b4b4;">;</span><br /> <span style="background:#1e1e1e;color:#dcdcdc;">}</span><span style="background:#1e1e1e;color:#b4b4b4;">)(</span><span style="background:#1e1e1e;color:#ffffff;">jQuery</span><span style="background:#1e1e1e;color:#b4b4b4;">);</span></div>
</p></div>
</p></div>
<p>Even though we’re still using the $ alias, this time it refers to the local parameter defined by the anonymous function which is initialized with a reference to the jQuery global variable. With this strategy, we’ve ended with better code which is also faster. </p>
<p>Now that we already have gone through the basics, we’re ready to take a look at some more advanced scenarios. Stay tuned for more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/luisabreu.wordpress.com/1815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/luisabreu.wordpress.com/1815/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=luisabreu.wordpress.com&#038;blog=35871519&#038;post=1815&#038;subd=luisabreu&#038;ref=&#038;feed=1" width="1" height="1" /><img src="http://feeds.feedburner.com/~r/Laneten/~4/UTNX279FvAo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://luisabreu.wordpress.com/2013/02/05/javascript-more-about-the-module-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ef50ae4032124f87927d917ac713ee3b?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">luisabreu</media:title>
		</media:content>
	<feedburner:origLink>http://luisabreu.wordpress.com/2013/02/05/javascript-more-about-the-module-pattern/</feedburner:origLink></item>
	</channel>
</rss>
