<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5521512899202663630</id><updated>2012-02-05T14:58:00.604-02:00</updated><category term='VBScript'/><category term='Vista'/><category term='Usability'/><category term='Visual SourceSafe'/><category term='Microsoft'/><category term='introduction'/><category term='Deep'/><category term='Cygwin'/><category term='Google Wave'/><category term='VirtualBox'/><category term='Postfix'/><category term='Review'/><category term='.Net'/><category term='Visio'/><category term='Project'/><category term='XML'/><category term='Design'/><category term='Windows'/><category term='Security'/><category term='Word'/><category term='Registry'/><category term='Office 2010'/><category term='DTO'/><category term='Google'/><category term='mainframe'/><category term='C#'/><category term='LOC'/><category term='COBOL'/><category term='Chrome'/><category term='Enterprise Library'/><category term='Linux'/><category term='POCO'/><category term='Hardware'/><category term='Internet Explorer'/><category term='Rant'/><category term='Bash'/><category term='Applications'/><category term='Analysis'/><category term='ShellScript'/><category term='DOS'/><category term='Excel'/><title type='text'>Tek Corner</title><subtitle type='html'>The Technology Corner, a place to share my thoughts over anything related to my work and career - that is, programming, technology, etc.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-6068694770384596533</id><published>2012-02-03T12:31:00.001-02:00</published><updated>2012-02-05T13:34:46.369-02:00</updated><title type='text'>Careful with Abstractions</title><content type='html'>Browsing around &lt;a href="http://www.msdn.com/"&gt;MSDN &lt;/a&gt;the other day, I bump into the following paragraph:&lt;br /&gt;&lt;br /&gt;&lt;div class="label" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;b&gt;"&lt;/b&gt;The order and types of binding elements in Bindings are significant: The collection of binding elements is used to build a communications stack ordered according to the order of binding elements in the binding elements collection. The last binding element to be added to the collection corresponds to the bottom component of the communications stack, while the first one corresponds to the top component. Incoming messages flow through the stack from the bottom upwards, while outgoing messages flow from the top downwards. Therefore the order of binding elements in the collection directly affects the order in which communications stack components process messages. Note that WCF provides a set of pre-defined bindings that can be used in the majority of scenarios instead of defining custom bindings."&lt;/div&gt;&lt;div class="label" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;Most programmers understand the concept of a stack. It's a abstraction for a data structure which allows new data items to be removed in the exact opposite order which they were inserted, that is, the first element to be inserted is the last to be removed (&lt;a href="http://en.wikipedia.org/wiki/LIFO_(computing)"&gt;FILO&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;And most people knows what a stack is: a pile of stuff.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-n2UcY3P65Bk/TyvtRCKjdBI/AAAAAAAAAIk/Av31NRIgbnQ/s1600/step024_stack_poker_chips.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="266" src="http://1.bp.blogspot.com/-n2UcY3P65Bk/TyvtRCKjdBI/AAAAAAAAAIk/Av31NRIgbnQ/s320/step024_stack_poker_chips.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;And the deal with it is that you can only add /remove stuff to/from the &lt;b&gt;top. &lt;/b&gt;The text on MSDN, however, goes through great length to tells us to imagine a stack that &lt;i&gt;adds to the bottom&lt;/i&gt;, and that the message goes from bottom to top. A&amp;nbsp;upside-down&amp;nbsp;stack, in other words. Whoever wrote that was so deep into abstracting his communication stack is a certain way that he forces us to think in a counter-intuitive way. It would be easier for the author to change the way he thought about it.&lt;br /&gt;&lt;br /&gt;I used to say that some people, sometimes, are so fixed onto a solution that &lt;i&gt;when the solution doesn't works, they adapt the problem.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;Whenever you are writing a technical article like this, be careful with your abstractions; They should help people understand the problem better, so if you have to explain your abstraction (instead of explaining how it relates to the concrete problem itself), something is wrong. Like code smells, if you see a upside-down stack or any other abnormality appearing in one of your texts, take the time to review it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-6068694770384596533?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/6068694770384596533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2012/02/careful-with-abstractions.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6068694770384596533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6068694770384596533'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2012/02/careful-with-abstractions.html' title='Careful with Abstractions'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-n2UcY3P65Bk/TyvtRCKjdBI/AAAAAAAAAIk/Av31NRIgbnQ/s72-c/step024_stack_poker_chips.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-3165455884191193783</id><published>2011-12-17T20:12:00.001-02:00</published><updated>2011-12-17T20:20:44.477-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Postfix'/><category scheme='http://www.blogger.com/atom/ns#' term='Analysis'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>A Postfix Calculator, Step-by-step - Part 1</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;b&gt;Goal&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;Recently, I was introducing the C# language to someone from work. I gave him a few challenges, but after a while a colleague of mine asked him if he would be able to make a &lt;i&gt;postfix calculator&lt;/i&gt;, or a calculator which uses &lt;a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation"&gt;postfix notation&lt;/a&gt;. More than that, we wanted to design a &lt;i&gt;postfix expression evaluator&lt;/i&gt; (instead of a common calculator which receives a single operation as input).&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The objective of this series of posts will be to show a step-by-step analysis of the problem, the&amp;nbsp;design, implementation&amp;nbsp;and, finally, testing. It seems an ideal for first-timers, being simple to implement but requiring a more deep analysis and thinking.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;b&gt;Analysis&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The cool thing about this exercise is that, once understood, it's very simple to implement, while at first it may seem very complex. Most of us (myself included) knows this type of calculator as an user: you first enter operands and then the operation. But the inner workings are deceiving: they look convoluted and counter-intuitive.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Again, we are deceived by our mind... this kind of calculator is much more simpler than an usual expression evaluator. Let's begin by analyzing an example... let's see an addition in postfix:&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Table 1 - The Polish Reverse Notation&lt;/b&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Common Notation&lt;/th&gt;&lt;th&gt;Postfix Notation (PRN)&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 + 5&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 5 +&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Looking at the example, you can see that you should change the reading order of the expression in order to understand it more easily. Our brain (probably, since I'm no&amp;nbsp;psychiatrist here) usually reads the first expression as:&lt;/div&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1. Read 10, hold the value.&lt;br /&gt;2. The operation is "add", seek another value.&lt;br /&gt;3. Feeds 5 into the "add" operation.&lt;br /&gt;4. Returns 15.&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;Listing 1 - Evaluating an Expression&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;Or something like that. In the Occident people learn to read left-to-right, and it's expected that we apply the same rule to expression reading. Take a look at the steps above. Are they simple? Not really. To execute the second step, you must execute another! It seems that our brain in making a call to a subroutine.&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Now, let's look at the second expression. How to read it? We could apply the same left-to-right reading rule. We would have to store the values in two areas first and later retrieve then in order to perform the addition. Insightful readers may already have realized that it's easier to reading the expression right-to-left:&lt;/div&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1. The operation is add, seek two values.&lt;br /&gt;2. Feeds 5 into the add operation.&lt;br /&gt;3. Feeds 10 into the operation.&lt;br /&gt;4. Returns 15.&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;Listing 2 - Postfix Evalutaion&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Hmm, what changed? It's simple enough, you see. You first understand the operation, which leads you to seek enough operands to perform it. But wait! There's another notation that looks exactly like this, isn't it? Take a look below:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;Table 2 - Enter C-Like Notation&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;table border="1" style="text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;  &lt;th&gt;Common Notation&lt;/th&gt;  &lt;th&gt;Postfix Notation (PRN)&lt;/th&gt;  &lt;th&gt;C-like Notation&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;10 + 5&lt;/td&gt;  &lt;td&gt;10 5 +&lt;/td&gt;  &lt;td&gt;add(5, 10)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Wow! It looks like a common function (method) call, doesn't it? This is an advantage of&amp;nbsp;&lt;i&gt;postfix; &lt;/i&gt;All in all, it looks more like how a machine would work than the "common notation". Now, another advantage of the PRN is that&amp;nbsp;it doesn't requires&amp;nbsp;parenthesis. Let's see another example:&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Table 3 - Parenthesis in PRN&lt;/b&gt;&lt;br /&gt;&lt;table border="1" style="text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Common Notation&lt;/th&gt;&lt;th&gt;Postfix Notation (PRN)&lt;/th&gt;&lt;th&gt;C-like Notation&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;10 + 5&lt;/td&gt;&lt;td&gt;10 5 +&lt;/td&gt;&lt;td&gt;add(5, 10)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;(10 + 5) * (10 + 2)&lt;/td&gt;&lt;td&gt;10 5 + 10 2 + *&lt;/td&gt;&lt;td&gt;???&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;It's becoming harder. I have involved another operation (multiplication) to exemplify the parenthesis. But now, how does one evaluates the PRN above? Again, I will risk trying to explain the brain process behind it:&lt;/div&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1. The operation is &lt;i&gt;multiplication&lt;/i&gt;, seek two values.&lt;br /&gt;2. Ooops! Operation!?&lt;br /&gt;3. ...&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;Listing 3 - How to multiply?&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Things get complicated after you read the value to the multiplication. As it turns out, it's not a value, but another operation. What if we evaluate it and feed the result into the multiplication?&lt;/div&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1. The operation is multiplication, seek two values.&lt;br /&gt;2.1. The operation is add, seek two values.&lt;br /&gt;2.2. Feeds 2 into the add operation.&lt;br /&gt;2.3. Feeds 10 into the operation.&lt;br /&gt;2.4. Returns 12.&lt;br /&gt;3.1. The operation is add, seek two values.&lt;br /&gt;3.2. Feeds 5 into the add operation.&lt;br /&gt;3.3. Feeds 10 into the operation.&lt;br /&gt;3.4. Returns 15.&lt;br /&gt;4. Returns 180.&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;Listing 4 - Multiplication Complete&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;OK, it's working properly. The &lt;i&gt;call&lt;/i&gt;&amp;nbsp;to multiplication resulted in two other calls, both to, again, adds. It seems that whenever we are evaluating an operation, we might run into another one. Hmm... which may lead into yet another one and so forth. This looks a hell lot like &lt;i&gt;recursion&lt;/i&gt;, doesn't it? Well, hold that thought for a moment; we still must fill the third&amp;nbsp;column&amp;nbsp;of the table.&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;How would the operation above looks like in "C-like notation"? Let's again assume a multiply operation, just like add.&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Table 4 - C-Like for Multiplication&lt;/b&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Common Notation&lt;/th&gt;&lt;th&gt;Postfix Notation (PRN)&lt;/th&gt;&lt;th&gt;C-like Notation&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 + 5&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 5 +&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;add(5, 10)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;(10 + 5) * (10 + 2)&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 5 + 10 2 + *&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;multiply(add(2, 10), add(10, 5))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Looking good! We have already&amp;nbsp;established the principles and already projected the calculations to a computer language.&lt;br /&gt;&lt;br /&gt;So let's focus on the C-like notation and expand it, after all, we are building a program, aren't we? Let's take another look at the steps in &lt;i&gt;listing 4&lt;/i&gt;. There is something that calls&amp;nbsp;attention: "&lt;i&gt;seek two values"&lt;/i&gt;&lt;i&gt;. &lt;/i&gt;We do that a lot, don't we? Let's us assume that we could have an operation that seeks those values and then evaluate it. Could that be possible? Enter X(), a function that does that for us.&lt;br /&gt;&lt;br /&gt;So&lt;/div&gt;&lt;blockquote class="tr_bq"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;multiply(add(2, 10), add(10, 5))&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;becomes&lt;br /&gt;&lt;blockquote class="tr_bq"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;multiply(add(X(), X()), add(X(), X()))&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;What's this X operation we are talking about? An operation that &lt;i&gt;extracts something from the expression&lt;/i&gt; and returns its value. And doesn't both &lt;i&gt;multiply &lt;/i&gt;and &lt;i&gt;add&lt;/i&gt;&amp;nbsp;do exactly that -- return a value from an expression? Oh yes, they do, and they are recursive, because, before returning a value, they will extract two more values from the expression. Yes! We got back to that recursive thing, didn't we? I told you to hold on to that, didn't I?&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;i&gt;(I said that this was a good exercise for first timers, but recursion is an advanced topic. If you need help to follow it, go to &lt;a href="http://en.wikipedia.org/wiki/Recursion_(computer_science)"&gt;Wikipedia&lt;/a&gt;.)&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;Anyway, if X takes something out of the expression (an operation or operand) and chooses whether to call multiply or add? Then, add and multiply can rely on X to retrieve more data. We have a two-step recursion (A calls B, B calls A). Let's check an algorithm that uses this X thing:&lt;br /&gt;&lt;br /&gt;&lt;table border="1" style="width: 300px;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Let X:&lt;br /&gt;1. a ← next_factor&lt;br /&gt;2. If a is a multiplication&lt;br /&gt;2.1 &amp;nbsp; &amp;nbsp; b&amp;nbsp;←&amp;nbsp;X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;2.2 &amp;nbsp; &amp;nbsp; c&amp;nbsp;←&amp;nbsp;X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;2.3. &amp;nbsp; &amp;nbsp;Return b times c&lt;br /&gt;3. If a is an addition&lt;br /&gt;3.1 &amp;nbsp; &amp;nbsp; b&amp;nbsp;← X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;3.2 &amp;nbsp; &amp;nbsp; c&amp;nbsp;←&amp;nbsp;X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;3.3. &amp;nbsp; &amp;nbsp;Return b plus c&lt;br /&gt;4. a must be a value, so, return a &amp;nbsp; &amp;nbsp;(&lt;i&gt;else)&lt;/i&gt;&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;Listing 5 - Recursion&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;So far I have avoided the non-commutative operation&amp;nbsp;&lt;i&gt;subtraction &lt;/i&gt;and &lt;i&gt;division&lt;/i&gt;. That's because there's a particularity in PRN, which is that the operands to an operation are always read left-to-right. In addition and multiplication it doesn't matter, them being recursive, but we must reverse the operation order for subtraction and division. Let me clarify what I just said with an example:&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;b&gt;Table 5 - Subtraction and Division&lt;/b&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Common Notation&lt;/th&gt;&lt;th&gt;Postfix Notation (PRN)&lt;/th&gt;&lt;th&gt;C-like Notation&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 + 5&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 5 +&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;add(5, 10)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;(10 + 5) * (10 + 2)&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 5 + 10 2 + *&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;multiply(add(2, 10), add(10, 5))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style="background: yellow;"&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 / 2&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;10 2 /&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div style="text-align: center;"&gt;divide(10, 2)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;We could have thought, from my earlier explanation, that 10 / 2 would actually be written as 2 10 /, because, following the recursive algorithm for addition or multiplication:&lt;br /&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Algorithm&lt;/th&gt;&lt;th&gt;Application&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0. Let X:&lt;br /&gt;1. a ← next_factor&lt;br /&gt;2. If a is a multiplication&lt;br /&gt;2.1. &amp;nbsp; &amp;nbsp;b&amp;nbsp;←&amp;nbsp;X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;2.2. &amp;nbsp; &amp;nbsp;c&amp;nbsp;←&amp;nbsp;X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;2.3. &amp;nbsp; &amp;nbsp;Return b times c&lt;br /&gt;3. If a is an addition&lt;br /&gt;3.1. &amp;nbsp; &amp;nbsp;b&amp;nbsp;← X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;3.2. &amp;nbsp; &amp;nbsp;c&amp;nbsp;←&amp;nbsp;X() &amp;nbsp; (&lt;i&gt;recursion)&lt;/i&gt;&lt;br /&gt;3.3. &amp;nbsp; &amp;nbsp;Return b plus c&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;4. If a is a division&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;4.1 &amp;nbsp; &amp;nbsp;b&amp;nbsp;← X()&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;4.2 &amp;nbsp; &amp;nbsp;c&amp;nbsp;← X()&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;4.3 &amp;nbsp; &amp;nbsp;Return b / c&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;&lt;span style="background-color: yellow;"&gt;4. If a is a subtraction&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;&lt;span style="background-color: yellow;"&gt;4.1 &amp;nbsp; &amp;nbsp;b&amp;nbsp;← X()&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;&lt;span style="background-color: yellow;"&gt;4.2 &amp;nbsp; &amp;nbsp;c&amp;nbsp;← X()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: yellow;"&gt;&lt;span style="background-color: yellow;"&gt;4.3 &amp;nbsp; &amp;nbsp;Return b - c&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;5. a must be a value, so, return a &amp;nbsp; &amp;nbsp;(&lt;i&gt;else)&lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;Expression is &lt;/i&gt;"10 2 /"&lt;br /&gt;&lt;br /&gt;(0) &amp;nbsp;X();&lt;br /&gt;(1) &amp;nbsp;a&amp;nbsp;← next_factor &amp;nbsp; &amp;nbsp;&lt;i&gt;{10 2 [/]}&lt;/i&gt;&lt;br /&gt;(1') a&amp;nbsp;← /&lt;br /&gt;(4) &amp;nbsp;Is (a="/") is a division:&lt;br /&gt;(4.1) &amp;nbsp; &amp;nbsp;b&amp;nbsp;← X()&lt;br /&gt;(4.1 leads to 0)&lt;br /&gt;(1) &amp;nbsp;a&amp;nbsp;← next_factor &amp;nbsp; &amp;nbsp;&lt;i&gt;{10 [2]&amp;nbsp;/}&lt;/i&gt;&lt;br /&gt;(1') a&amp;nbsp;← 2&lt;br /&gt;(5) Return 2&lt;br /&gt;(returns to 4.1)&lt;br /&gt;(4.1') &amp;nbsp; &amp;nbsp;b&amp;nbsp;← 2&lt;br /&gt;(4.2) &amp;nbsp; &amp;nbsp; c&amp;nbsp;← X()&lt;br /&gt;(4.1 leads to 0)&lt;br /&gt;(1) &amp;nbsp;a&amp;nbsp;← next_factor &lt;i&gt;{[10] 2 /}&lt;/i&gt;&lt;br /&gt;(1) a&amp;nbsp;← 10&lt;br /&gt;(5) Return 10&lt;br /&gt;(returns to 4.2)&lt;br /&gt;(4.2') c&amp;nbsp;← 10&lt;br /&gt;(4.3) Return b / c&lt;br /&gt;&lt;span style="color: red;"&gt;(4.3') Return 2 / 10&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan="2"&gt;&lt;div style="text-align: right;"&gt;&lt;i&gt;Listing 6 - Non commutative operations&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;So, as you can see from the listing, we have to invert b and c. This should be simple enough, instead of "Return b / c", you just "Return c / b". I won't get back to the algorithm, but you can make the alteration by yourself.&lt;/div&gt;&lt;br /&gt;Once the algorithm above is established, you can see that any PRN expression can be solved by applying it. We must turn our attention to the&amp;nbsp;&lt;i&gt;next_factor&lt;/i&gt;&amp;nbsp;operation. We could parse the expression reversely, reading characters from right to left, but then &amp;nbsp;&lt;span style="text-align: justify;"&gt;another problem arises, since we'll be reading the digits in the wrong order (e.g. 10 will be read as {0, 1}). This means taking care of reversing them back to the usual order, which can make the parsing become highly complex. So instead, let's look at our algorithm once more... we need a structure that will process first the last items stored. Hmm...&amp;nbsp;Last&amp;nbsp;In,&amp;nbsp;First&amp;nbsp;Out...? A LIFO, which is a stack! And, hear me, stacks are &lt;/span&gt;&lt;i style="text-align: justify;"&gt;goooood&lt;/i&gt;&lt;span style="text-align: justify;"&gt;! Whenever you can implement something with a stack, do so.They usually make for nice, clean algorithms.²&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Anyway, so we can parse the expression left-to-right, pushing factors into a list and, later, as X calls for a new item, we pop them out.¹&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Wrapping Up&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Uffs! We finished analyzing the problem, resulting in devising an algorithm to process the data, the necessary data structure and rules. By checking our reasoning above, we could create a formal process of analysis:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Gather requirements from the problem, do your homework!&amp;nbsp;&lt;/li&gt;&lt;li&gt;Iterate in order to create a mathematical model to describe your problem. Most things are reduced to a series of calculations.&lt;/li&gt;&lt;li&gt;Iterate in order to define data structures that can support your algorithm. You will usually end up with lists, queues and stacks. Or some cases (on data-centric problems) you will deal with dictionaries.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;This is a very high-level process for analysis. As you can see, we have not used any kind of formalism to solve this problem. The goal here is exactly that: on a day-to-day basis, you won't be required to hold a degree in mathematics (or computer science, for that matter) in order to design problems.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Next On&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;On the next article we will produce an implementation for the algorithm above. As usual, after having a a well defined problem and a fully designed solution, building the program should be very, very simple. But I will try to iterate over the algorithm to show programming steps, like where you should focus first, then how to clean-up the code and where you should make heavy use of comments.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ht&gt;&lt;/ht&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;Notes&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;¹ Veterans might have realized earlier that this model is, in fact, a &lt;a href="http://en.wikipedia.org/wiki/Stack_Machine"&gt;Stack Machine&lt;/a&gt;. I refrain to mention it so that I wouldn't scare of newcomers to programming. It was extremely helpful to have read &lt;a href="http://blogs.msdn.com/b/ericlippert/archive/2011/11/28/why-have-a-stack.aspx"&gt;the excellent article&lt;/a&gt;&amp;nbsp;from Eric Lippert that discussed the IL as a stack machine.&lt;br /&gt;&lt;br /&gt;² In my particular opinion, of course. This is by no means a rule.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-3165455884191193783?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/3165455884191193783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2011/12/postfix-calculator-step-by-step-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/3165455884191193783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/3165455884191193783'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2011/12/postfix-calculator-step-by-step-part-1.html' title='A Postfix Calculator, Step-by-step - Part 1'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-6411320152816736618</id><published>2011-11-22T09:27:00.000-02:00</published><updated>2011-11-22T09:27:56.800-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Applications'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Recuva - A Free Software You Have To Know</title><content type='html'>One day you wake up, take that long drive to the office, pour a cup of coffee and boot up your PC, only to find out that you&amp;nbsp;accidentally&amp;nbsp;deleted a very, very important file the day before.&lt;br /&gt;&lt;br /&gt;This is not uncommon, right?&amp;nbsp;-- files are fragile things which can vanish with the click of a mouse. Most of the time, we can confide in the &lt;em&gt;Recycle Bin&lt;/em&gt;, but sometimes, it's gone. Maybe the option is to create a new one, and lose lot's of time redoing something. Other times, well, you just cry for a bit - no way to get back what you lost. So you move on.&lt;br /&gt;&lt;br /&gt;Recently, however, something even worse happened to me: while aumatically updating my work notebook&amp;nbsp;to Windows 7 I lost all my files. I didn't had an recent backup for many, many items. Of course, critical work stuff was safe -- we use&amp;nbsp;SharePoint, Mercurial, etc., so there was no immediate risk, but some files -- annotations, stuff like that -- were lost.&lt;br /&gt;&lt;br /&gt;Having no choice other than &lt;em&gt;trying&lt;/em&gt; to recover&amp;nbsp;the files, I started looking over the net for an application that would be able to help me achieve that. You'd be surprise with the number of apps out there that intents to do exactly that. But most of those applications simply don't work... maybe because they depend on a specific API from other versions of Windows or something like that. The ones that might work are paid software with free trials available, but then the trial doesn't work and I won't pay for something I don't know if works.&lt;br /&gt;&lt;br /&gt;I thought all was lost. Many documents, projects and personal files, all gone.&lt;br /&gt;&lt;br /&gt;And then I stumbled upon&amp;nbsp;&lt;a href="http://www.piriform.com/recuva"&gt;Recuva&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The first thing to know about Recuva is that it's completely free. Indeed, you can donate money to Piriform, but that entirely up to you. This utility enables you to&amp;nbsp;scan the disk for deleted files by &lt;i&gt;file type&lt;/i&gt;, and it'll list everything it finds&lt;br /&gt;&lt;br /&gt;The interface &lt;em&gt;could &lt;/em&gt;have been a bit nicer, but other than that, you have all the options that a good recovery software should have. For every file it finds, it gives you a rating of "recoverability" - some files are found, but can't be recovered since it's contents are corrupt. And, of course, you can filter the list to show only recoverable files.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Recuva saved my life&lt;/i&gt;. It didn't do any miracles - some files were gone since the Win7 update copied over them - but those that the tool found where enough to save me hours of work. Clearly recommended.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-6411320152816736618?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/6411320152816736618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/10/recuva-free-software-you-have-to-know.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6411320152816736618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6411320152816736618'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/10/recuva-free-software-you-have-to-know.html' title='Recuva - A Free Software You Have To Know'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-2413178444971513778</id><published>2011-08-20T13:37:00.004-03:00</published><updated>2011-08-20T13:51:09.048-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Careful with the C# "as" operator</title><content type='html'>&lt;div class="MsoNormal"&gt;It's very common to use the &lt;a href="http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.71).aspx"&gt;&lt;i&gt;as&lt;/i&gt;&amp;nbsp;operator&lt;/a&gt; instead of it's "ugly cousin", the &lt;i&gt;explicit cast&lt;/i&gt;. The reason behind this is that &lt;i&gt;as&lt;/i&gt;&amp;nbsp;appears to be more clear to the reader, demanding less cognitive effort from the mind.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b&gt;&lt;span lang="EN-US"&gt;1. Using&amp;nbsp;&lt;i&gt;as&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span lang="EN-US"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #f0f0f0; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: dashed; border-top-width: 1px; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow-x: auto; overflow-y: auto; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 99%;"&gt;&lt;code style="word-wrap: normal;"&gt;1:    &lt;b&gt;Panel&lt;/b&gt; getSomeElem()  &lt;br /&gt;2:    {    &lt;br /&gt;3:      &lt;b&gt;var &lt;/b&gt;some_ui_elem = this.Children[0]; // Assume at least one element     &lt;br /&gt;4:      &lt;b&gt;return &lt;/b&gt;some_ui_elem as Panel;    // Using “as”  &lt;br /&gt;5:    }  &lt;br /&gt;6:    &lt;b&gt;void &lt;/b&gt;AnotherMethod()  &lt;br /&gt;7:    {  &lt;br /&gt;8:      &lt;b&gt;var &lt;/b&gt;panel = getSomeElem();           &lt;br /&gt;9:      panel.Height += 100;         // &lt;u&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;A&lt;/span&gt;&lt;/u&gt;  ...  &lt;br /&gt;10:    }  &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b&gt;2. Using&amp;nbsp;&lt;i&gt;cast&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #f0f0f0; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: dashed; border-top-width: 1px; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow-x: auto; overflow-y: auto; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 99%;"&gt;&lt;code style="word-wrap: normal;"&gt;1:    &lt;b style="color: black;"&gt;Panel &lt;/b&gt;getSomeElem()  &lt;br /&gt;2:    {   &lt;br /&gt;3:      &lt;b style="color: black;"&gt;var &lt;/b&gt;some_ui_elem = this.Children[0];  // Assume at least one element     &lt;br /&gt;4:      &lt;b style="color: black;"&gt;return &lt;/b&gt;(&lt;b style="color: black;"&gt;Panel&lt;/b&gt;)some_ui_elem;           // Using a explicit cast. &lt;u&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;B&lt;/span&gt;&lt;/u&gt;  &lt;br /&gt;5:    }  &lt;br /&gt;6:    &lt;b style="color: black;"&gt;void&lt;/b&gt; AnotherMethod()  &lt;br /&gt;7:    {    &lt;br /&gt;8:      &lt;b style="color: black;"&gt;var&lt;/b&gt;&lt;/code&gt;&lt;code style="word-wrap: normal;"&gt; panel = getSomeElem(); &amp;nbsp;&lt;br /&gt;9:      panel.Height += 100;    &lt;br /&gt;10:     ...  &lt;br /&gt;11:   }  &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The difference between both operators is very clear. The &lt;i&gt;cast&lt;/i&gt;&amp;nbsp;immediately&amp;nbsp;throws&amp;nbsp;an exception whenever the object can't be cast to the specified type, while the &lt;i&gt;as &lt;/i&gt;operator will only return &lt;b&gt;null&lt;/b&gt;.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;One could imagine that returning &lt;b&gt;null&lt;/b&gt;&amp;nbsp;is better. And actually, if the caller (or the rest of the code) is prepared to get a &lt;b&gt;null&lt;/b&gt;, than you should go with &lt;i&gt;as&lt;/i&gt;. But that usually isn't the case: we don't usually write code expecting stuff to be &lt;b&gt;null&lt;/b&gt;. Moreover, the method's contract implicates that an object will be returned.&amp;nbsp;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;i&gt;Wait a bit! This is getting a little cryptic, right? In both operations, on the hypothesis that the object can't be cast to &lt;b&gt;Panel, &lt;/b&gt;we will get an exception. So there's no difference, right?&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Well, there is. The question is that the operator &lt;i&gt;as&lt;/i&gt;&amp;nbsp;will hide the error. See, on the first example above, the exception thrown will be&amp;nbsp;&lt;i&gt;NullReferenceException &lt;/i&gt;at the method&amp;nbsp;&lt;i&gt;AnotherMethod&lt;/i&gt;, up in the stack, in the line "&lt;u&gt;&lt;span style="color: red;"&gt;A&lt;/span&gt;&lt;/u&gt;". Whereas in the example 2, the returned exception will be&amp;nbsp;&lt;i&gt;InvalidCastException&lt;/i&gt;, exactly at the line&amp;nbsp;&lt;u&gt;&lt;span style="color: red;"&gt;B&lt;/span&gt;&lt;/u&gt;, exactly where the error was originated.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;If &amp;nbsp;&lt;/o:p&gt;&lt;i&gt;getSomeElem &lt;/i&gt;is a library method, it will get really difficult to understand where the exception has arisen (which was the fact that the first element of children wasn't of the expected type). A uninformed caller might come to the conclusion that the object doesn't exists (usually the case when something returns &lt;b&gt;null&lt;/b&gt;).&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;&lt;b&gt;In conclusion&lt;/b&gt;, when you need to make a cast,&amp;nbsp;prefer to do it explicitly. Get used to the cast notation early. If there is a dire need to use &lt;i&gt;as&lt;/i&gt;,&amp;nbsp;then remember to always check whether the returned reference is &lt;b&gt;null&lt;/b&gt;. Only return this value after a &lt;i&gt;as &lt;/i&gt;operation if the method's contract explictly states that the method returns &lt;b&gt;null&lt;/b&gt;&amp;nbsp;on error.&lt;/o:p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-2413178444971513778?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/2413178444971513778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2011/08/careful-with-c-as-operator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/2413178444971513778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/2413178444971513778'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2011/08/careful-with-c-as-operator.html' title='Careful with the C# &quot;as&quot; operator'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-8653603294237342823</id><published>2011-07-26T11:27:00.000-03:00</published><updated>2011-11-22T09:19:54.468-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>A Vector Type for C# - CodeProject</title><content type='html'>&lt;div&gt;The other day I was looking for a Vector class for a C# project. I was actually wanting a 2D vector, but I've come across a 3D one which is great, so, recommended:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://www.codeproject.com/KB/recipes/VectorType.aspx"&gt;A Vector Type for C# - CodeProject&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-8653603294237342823?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.codeproject.com/KB/recipes/VectorType.aspx' title='A Vector Type for C# - CodeProject'/><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/8653603294237342823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2011/07/vector-type-for-c-codeproject.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8653603294237342823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8653603294237342823'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2011/07/vector-type-for-c-codeproject.html' title='A Vector Type for C# - CodeProject'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-7315606305617152324</id><published>2011-07-13T18:01:00.000-03:00</published><updated>2011-07-13T18:01:35.099-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Office 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Word'/><title type='text'>Customize Keyboard on Microsoft Word</title><content type='html'>This one is quick and simple, but as obscure as hell:&lt;br /&gt;&lt;br /&gt;In Microsoft Word 2010 (probably 2007 as well), hold CTRL-ALT-+ to have your cursor turn into a kind of crosshairs. Click in whatever button you want to assign a button to, and the &lt;i&gt;Customize Keyboard&lt;/i&gt;&amp;nbsp;dialog will appear.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-4w4xHg8z-Xo/Th4HcqN843I/AAAAAAAAAGU/5uNqmIaaIFw/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="292" src="http://2.bp.blogspot.com/-4w4xHg8z-Xo/Th4HcqN843I/AAAAAAAAAGU/5uNqmIaaIFw/s320/Untitled.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This obscure, undocumented feature saved my life once.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-7315606305617152324?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/7315606305617152324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2011/07/customize-keyboard-on-microsoft-word.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/7315606305617152324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/7315606305617152324'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2011/07/customize-keyboard-on-microsoft-word.html' title='Customize Keyboard on Microsoft Word'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-4w4xHg8z-Xo/Th4HcqN843I/AAAAAAAAAGU/5uNqmIaaIFw/s72-c/Untitled.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-3567401989616239572</id><published>2011-05-27T17:21:00.000-03:00</published><updated>2011-12-17T20:21:16.930-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Analysis'/><category scheme='http://www.blogger.com/atom/ns#' term='Design'/><title type='text'>Solid (object-oriented design) - Wikipedia, the free encyclopedia</title><content type='html'>This is a "note-to-self". While mainly overlooked by many official computer science courses and graduations (mine included), &lt;a href="http://en.wikipedia.org/wiki/Solid_(object-oriented_design)"&gt;Solid&lt;/a&gt; is a very important principle to apply to projects. &lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It should be standard practice to test every software implementation against it. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'd turn it into a rule-of-thumb, if possible. After designing the domain classes, check for SOLID. After finishing every release of the product, check for SOLID. Nice and smart!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-3567401989616239572?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://en.wikipedia.org/wiki/Solid_(object-oriented_design)' title='Solid (object-oriented design) - Wikipedia, the free encyclopedia'/><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/3567401989616239572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2011/05/solid-object-oriented-design-wikipedia.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/3567401989616239572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/3567401989616239572'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2011/05/solid-object-oriented-design-wikipedia.html' title='Solid (object-oriented design) - Wikipedia, the free encyclopedia'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-4933194713466725177</id><published>2011-05-26T17:14:00.001-03:00</published><updated>2011-05-26T17:48:11.155-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='POCO'/><category scheme='http://www.blogger.com/atom/ns#' term='DTO'/><title type='text'>DTO vs. POCO</title><content type='html'>This should have been clear enough. DTOs and POCO are two different things. If, by some reason, you are as confuse as I have been:&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- &lt;a href="http://msdn.microsoft.com/en-us/library/ms978717.aspx"&gt;Data Transfer Objects&lt;/a&gt; are objects that only have data (properties, if we are talking about C#) and, sometimes, logic to retrieve that data.&lt;/div&gt;&lt;div&gt;- &lt;a href="http://en.wikipedia.org/wiki/Plain_Old_CLR_Object"&gt;Plain Old CLR Objects&lt;/a&gt; are objects that are simple -- they have simple logic to represent a real world object. They do contain methods and stuff.&lt;br /&gt;&lt;br /&gt;I got them both mixed up some time ago (actually, a long time ago) when designing an architecture. It took me at least an year to discover that, while &lt;i&gt;similar &lt;/i&gt;(POCOs may look like DTOs), they weren't the same.&amp;nbsp;You see, I decided not to attach any logic to my POCOs, and I thought that it was "compliant" with this design principle. &lt;br /&gt;&lt;br /&gt;Now I was reading some stuff over the matter and remembered to post it here. Someone might make the same mistake.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-4933194713466725177?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/4933194713466725177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2011/05/dto-vs-poco.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4933194713466725177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4933194713466725177'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2011/05/dto-vs-poco.html' title='DTO vs. POCO'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-5858283088425492805</id><published>2010-11-24T21:11:00.001-02:00</published><updated>2010-11-24T21:12:53.659-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Library'/><title type='text'>Validation Application Block Warts</title><content type='html'>As you all will have noticed from my previous post, I'm digging deeper with VAB from Enterprise Library (4.1, not 5, by-the-way). The reason for choosing VAB as my validation framework was simply the fact that I could, by using it, remove all notion of validation from the Model classes and stick it into a configuration file.&lt;br /&gt;&lt;br /&gt;This serves two purposes:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;On a multi-tier architecture, I could make sure presentation tiers had no access to validation structures but still use the validation classes, because the validation configuration would be deployed only at the back-end, where my BLL resides.&lt;/li&gt;&lt;li&gt;I could lookup all messages being issued by my application on a single file. Of course this would be possible by using Resources, but that is a lot of work when not planning to localize the application.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;So I delved into VAB during the last couple of days. Only to get myself disappointed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Don't get me wrong, it's still a nice framework, but the two reasons above are linked to storing the validation rules in external configuration files. And that fails miserably because &lt;u&gt;VAB won't validate ancestors rules when using configuration files based validation&lt;/u&gt;.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The workaround for that is to replicate every rule for an ancestor at the derived class. Which is not a real solution, since such replication will lead to errors quicker than you can say "what".&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I think this defeats the purpose of using configuration files. VAB is a choice only when dealing with complex system, and on such systems, there probably will have at least some cases of inheritance.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-5858283088425492805?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/5858283088425492805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/11/validation-application-block-warts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/5858283088425492805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/5858283088425492805'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/11/validation-application-block-warts.html' title='Validation Application Block Warts'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-1150811358406105869</id><published>2010-11-24T17:15:00.000-02:00</published><updated>2010-11-24T17:15:04.404-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Library'/><title type='text'>Validation Application Block and Unit Testing</title><content type='html'>The Enterprise Library VAB is a very sane way of maintaining validation rules for your Model entities. I love the idea that you can keep the validation rules in a separate configuration file, because that enables you to more clearly check what rules are being applied, the messages, etc, without having to open many files.&lt;br /&gt;&lt;br /&gt;The problem with this approach is that unit tests will fail to open the .config is usual&amp;nbsp;circumstances, which will&amp;nbsp;frustrate&amp;nbsp;many developer. But, like almost everything in life, there's a solution, and a good one.&lt;br /&gt;&lt;br /&gt;Check it &lt;a href="http://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=65"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-1150811358406105869?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/1150811358406105869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/11/validation-application-block-and-unit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1150811358406105869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1150811358406105869'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/11/validation-application-block-and-unit.html' title='Validation Application Block and Unit Testing'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-4249983346298074267</id><published>2010-10-19T11:55:00.001-02:00</published><updated>2010-11-24T21:13:27.076-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VirtualBox'/><title type='text'>Enlarging/Expanding a VirtualBox HDD</title><content type='html'>I've been &amp;nbsp;using VirtualBox as a development host for quite some time now. But I've recently ran into a problem: the HDD that I defined wasn't large&amp;nbsp;enough to install all tools I need (it ran out of 20G of space when I decided I needed to install management tools for SQL Server Express 2008).&lt;br /&gt;&lt;br /&gt;So I've looked around the net searching for how to do this. First, I'm quite disappointed that VirtualBox itself doesn't accompany a tool that does that. Secondly, most of the solutions I found were complex or involved downloading large LiveCD images. Until I found &lt;a href="http://blog.macuyiko.com/2008/09/virtualbox-expanding-disk-drive.html"&gt;this blog&lt;/a&gt;, which not only compiles many links to other solutions, but provides a simple one -- the one I used and recommend.&lt;br /&gt;&lt;br /&gt;If you're brave enough (you must be; We are dealing with disk partitions here) all you have to do is:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download GParted LiveCD (~150MB) from &lt;a href="http://gparted.sourceforge.net/"&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Define a new HDD in VirtualBox and set it to be your &lt;i&gt;secondary&lt;/i&gt;&amp;nbsp;partition.&lt;/li&gt;&lt;li&gt;Mount the live cd as the primary IDE controller. Make sure the BIOS in your Virtual Machine is configured to boot from the CD first (and HDD next).&lt;/li&gt;&lt;li&gt;Boot GParted in command line (shell) mode.&lt;/li&gt;&lt;li&gt;Use &lt;i&gt;fdisk -l&lt;/i&gt;&amp;nbsp;to identify the old disk and the new one. Be careful!&amp;nbsp;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Usually, your original partition will be /dev/hda*, where * is a number. It can also be /dev/sda*. The new partition can have another number (higher one, in most cases) or be something like /dev/sdb.&lt;/li&gt;&lt;li&gt;Remember that GParted will have a partition of its on, mounted on /. Use &lt;i&gt;mount &lt;/i&gt;to list mounted partitions.&lt;/li&gt;&lt;li&gt;If you try to mount a unpartitioned hdd &lt;i&gt;mount&lt;/i&gt; will tell that you need to inform its file format. That is a good clue you are talking about the right partition.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Once you identified the source and target devices, all you have to do is &lt;i&gt;dd if=[source] of=[target]&lt;/i&gt;. It will take a long time, since its doing a byte-by-byte copy of your partition.&amp;nbsp;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Assuming your source device is /dev/hda2 and your target is /dev/hdb, the command above should be: &lt;i&gt;dd if=/dev/hda2 of=/dev/hdb&lt;/i&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;Once the copy is over, all you need to do is shutdown the system, map only the new drive as the main HDD of your VM, and boot it up.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Good luck.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-4249983346298074267?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/4249983346298074267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/10/enlargingexpanding-virtualbox-hdd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4249983346298074267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4249983346298074267'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/10/enlargingexpanding-virtualbox-hdd.html' title='Enlarging/Expanding a VirtualBox HDD'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-814206709126043918</id><published>2010-09-08T15:29:00.000-03:00</published><updated>2011-12-17T20:22:05.408-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='Applications'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Bash'/><title type='text'>Better Cygwin Terminal</title><content type='html'>It's been a while since my last post. I still don't have time to do it properly, but here goes a tip for those of us who use Cygwin:&lt;br /&gt;&lt;br /&gt;Make sure rxvt is part of your Cygwin install, and update your C:\cygwin\cygwin.bat to this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;@echo off&lt;br /&gt; C:&lt;br /&gt; chdir \cygwin\bin&lt;br /&gt; start rxvt -sr -sl 10000 -fg white -bg black -fn fixedsys -fb fixedsys -tn cygwin -e /bin/bash --login -i&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;(If you don't want the first window hanging around)&lt;br /&gt;&lt;pre&gt;@echo off&lt;br /&gt; C:&lt;br /&gt; chdir C:\cygwin\bin&lt;br /&gt; set EDITOR=vi&lt;br /&gt; set VISUAL=vi&lt;br /&gt; set CYGWIN=codepage:oem tty binmode title&lt;br /&gt; rxvt -sr -sl 10000 -fg white -bg black -fn fixedsys -fb fixedsys -tn cygwin -e bash --login -i&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Check out &lt;a href="http://www.c2.com/cgi/wiki?BetterCygwinTerminal"&gt;this site&lt;/a&gt; for more info.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-814206709126043918?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/814206709126043918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/09/better-cygwin-terminal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/814206709126043918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/814206709126043918'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/09/better-cygwin-terminal.html' title='Better Cygwin Terminal'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-6333810592247818176</id><published>2010-08-04T15:34:00.001-03:00</published><updated>2011-12-17T20:23:03.924-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to read a binary file/stream in C#?</title><content type='html'>This one is simple, but helped me a lot recently.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.chilkatsoft.com/faq/dotnetstrtobytes.html"&gt;http://www.chilkatsoft.com/faq/dotnetstrtobytes.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-6333810592247818176?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/6333810592247818176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/08/how-to-read-binary-filestream-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6333810592247818176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6333810592247818176'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/08/how-to-read-binary-filestream-in-c.html' title='How to read a binary file/stream in C#?'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-2243281230835162295</id><published>2010-08-03T11:52:00.002-03:00</published><updated>2011-12-17T20:22:32.189-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Analysis'/><category scheme='http://www.blogger.com/atom/ns#' term='Design'/><title type='text'>SourceMaking</title><content type='html'>This one is for developers and architects out there. An&amp;nbsp;excellent&amp;nbsp;site about Design Patterns and UML:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://sourcemaking.com/"&gt;https://sourcemaking.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-2243281230835162295?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/2243281230835162295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/08/sourcemaking.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/2243281230835162295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/2243281230835162295'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/08/sourcemaking.html' title='SourceMaking'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-5911157777069684545</id><published>2010-06-04T17:17:00.002-03:00</published><updated>2010-06-04T17:23:12.006-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Office 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Usability'/><title type='text'>Recent Files on Office</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/div&gt;I have to agree that this is a very personal thing, but still, one of my favorite things in Office 2007 menus was the recent list.&lt;br /&gt;&lt;br /&gt;You had about 20 items to choose &amp;nbsp;(up from 4), from which 9 you could access using a simple key combo. It was&amp;nbsp;amazing! I saved several minutes of my day that were wasted searching for files in very deep folder trees. Moreover, that was a very nice pin feature, that allowed you to &lt;i&gt;hold&lt;/i&gt;&amp;nbsp;or &lt;i&gt;pin down&lt;/i&gt;&amp;nbsp;a certain file to that list. This made sure that the file would remain in the list even if you don't access it very frequently. In short, it was a &lt;i&gt;Favorite File &lt;/i&gt;combined with &lt;i&gt;File History&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.sunflowerhead.com/msimages/RecentDocuments.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://www.sunflowerhead.com/msimages/RecentDocuments.png" width="291" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;i&gt;The recent file list as of Office 2007 (picture taken from &lt;a href="http://blogs.msdn.com/b/jensenh/archive/2006/08/16/702214.aspx"&gt;here&lt;/a&gt;)&lt;/i&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;And what I loved the most was the fact that I could get some files very quickly. Inside Word, for example, I'd type ALT-F, 1, and wow! That timesheet that I used everyday would be open. The great advantage of not having to search is that I didn't had to focus my mind in&amp;nbsp;opening&amp;nbsp;the file: it was a mechanical task. Looking for files in directories requires focus because you have to scan the folder for your file.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;The problem is that, in Office 2010, which I have been using for some weeks now, the Recent list is not on the "&lt;u&gt;F&lt;/u&gt;ile" menu, but on a sublevel of it. If, having something open on Word, I go ALT-F, I get:&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_mGql6Et46Z0/TAleqlbqXaI/AAAAAAAAAFQ/XkVc307Q738/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="331" src="http://4.bp.blogspot.com/_mGql6Et46Z0/TAleqlbqXaI/AAAAAAAAAFQ/XkVc307Q738/s640/Untitled.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Some names where censored on purpose&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;To access the Recent files list, I have to click at the Recent item on the left-side menu! Or the other hand, the features that I'm seeing here aren't really that useful. In fact, I don't recall&amp;nbsp;ever&amp;nbsp;using them on Word 2007. So, another tip for MS Information Architects: Verify which features are mostly used and make them more easy (direct) to access.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-5911157777069684545?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/5911157777069684545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/06/recent-files-on-office.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/5911157777069684545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/5911157777069684545'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/06/recent-files-on-office.html' title='Recent Files on Office'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_mGql6Et46Z0/TAleqlbqXaI/AAAAAAAAAFQ/XkVc307Q738/s72-c/Untitled.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-5830546002986548916</id><published>2010-05-28T15:07:00.001-03:00</published><updated>2010-06-04T17:26:23.155-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Vista'/><title type='text'>Another Bad UI</title><content type='html'>Microsoft is the champion of Bad UI design... mostly because MS has so many end-user softwares that are very spread. So, it's not really their fault. However, I find some mistakes more serious, mainly when we are talking about the OS. And let's remember that Windows hasn't changed a real lot in the last 15 years.&lt;br /&gt;&lt;br /&gt;The bad design was in the Copy File box:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_mGql6Et46Z0/TAAFMsyDsUI/AAAAAAAAAFI/KpLXMWZpsX0/s1600/error+copia.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_mGql6Et46Z0/TAAFMsyDsUI/AAAAAAAAAFI/KpLXMWZpsX0/s320/error+copia.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Names ommited due to privacy issues&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;It's bad enough that for some reason the file transfer had stalled. But I was copying many files, one at a time, to this destination folder. Now, one of the "Copying..." boxes was clearly telling me one of the operations have failed, but which? &lt;b&gt;Where is the name of the file?&lt;/b&gt;&amp;nbsp;When copying a file from one place to another, there are 3 informations that are crucial to the user:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Which file&lt;/li&gt;&lt;li&gt;From where&lt;/li&gt;&lt;li&gt;To where&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;(2) could be ommited if files in our HD had unique names, but since we end up naming a lot of stuff like "Todo.txt", "tasks.txt", "prices.txt", "list.txt", we need to know which of them we are talking about. Older boxes like these solved the space trouble by including additional information in a ToolTip. But in Vista, MS forgot that the filename had to appear somewhere.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I had to start over and check each file to see if it was correctly copied.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-5830546002986548916?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/5830546002986548916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/05/another-bad-ui.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/5830546002986548916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/5830546002986548916'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/05/another-bad-ui.html' title='Another Bad UI'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_mGql6Et46Z0/TAAFMsyDsUI/AAAAAAAAAFI/KpLXMWZpsX0/s72-c/error+copia.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-8033396757259636833</id><published>2010-05-20T12:54:00.003-03:00</published><updated>2011-12-17T20:22:46.168-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Project'/><title type='text'>Microsoft Project tutorial: Duration and task types</title><content type='html'>&lt;a href="http://articles.techrepublic.com.com/5100-10878_11-1031576.html"&gt;This article&lt;/a&gt; might be helpful for those of us that are sure there is a form of Artificial&amp;nbsp;Intelligence&amp;nbsp;inside Project.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-8033396757259636833?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/8033396757259636833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/05/microsoft-project-tutorial-duration-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8033396757259636833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8033396757259636833'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/05/microsoft-project-tutorial-duration-and.html' title='Microsoft Project tutorial: Duration and task types'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-6060924070793602960</id><published>2010-04-23T14:42:00.004-03:00</published><updated>2010-04-23T14:49:32.061-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Visio'/><category scheme='http://www.blogger.com/atom/ns#' term='Registry'/><title type='text'>Opening Visio 2007 docs in Individual Windows</title><content type='html'>I repeatedly disagree with Microsoft UI designers. Ok, they think it's nice that Visio treats many diagrams with a single instance. That I can live with. But shouldn't they enable the user to quick swap between them, maybe by using tabs, etc.?&lt;br /&gt;&lt;br /&gt;Anyway, Visio is actually a great tool, so I'm not ready to ditch it just yet. Not surprisingly, there's a way to make sure Visio opens a new instance every time you open a new file, which results in a taskbar item for each document, which essentially mimics the effect that I desire, because it enables the user to quickly see whichs &amp;nbsp;files are open. Not surprisingly as well, the method it's obscure, requiring some tweaking with Windows registry:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Open Visio and go to&amp;nbsp;Tools-&amp;gt;Options, select the Advanced tab and check "Put all settings in the Windows Registry".&lt;/li&gt;&lt;li&gt;Open &lt;i&gt;regedit&lt;/i&gt;&amp;nbsp;by typing &lt;i&gt;regedit &lt;/i&gt;in the Windows-&amp;gt;Run interface.&lt;/li&gt;&lt;li&gt;Make a registry backup by selecting the upper node in the tree on the left panel, and selecting File-&amp;gt;Export. Make sure to add a date to the file, so that you now how long it was since the backup was made.&lt;/li&gt;&lt;li&gt;Navigate the left tree to HKEY_CURRENT_USER/Software/Microsoft/Office/12.0/Visio/Application.¹&lt;/li&gt;&lt;li&gt;On the right panel, find the "SingleInstanceFileOpen" value. Double click it, and change it's data from "1" to "0".&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Just one thing. This will increase memory usage by Visio, since each document now has to run a full application.&lt;/div&gt;&lt;hr /&gt;&lt;div&gt;¹ - &lt;i&gt;This applies to the 2007 version of Visio. Other versions might store the value somewhere else, so if you are running something different, try Edit-&amp;gt;Search and look for SingleInstanceFileOpen, but make sure this is a Visio value.&lt;/i&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-6060924070793602960?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/6060924070793602960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/04/opening-visio-2007-docs-in-individual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6060924070793602960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6060924070793602960'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/04/opening-visio-2007-docs-in-individual.html' title='Opening Visio 2007 docs in Individual Windows'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-1038524285501344805</id><published>2010-04-19T19:09:00.000-03:00</published><updated>2011-12-17T20:23:53.991-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Deep'/><title type='text'>What Every Computer Scientist Should Know About Floating-Point Arithmetic</title><content type='html'>&lt;a href="http://docs.sun.com/source/806-3568/ncg_goldberg.html"&gt;Nice article&lt;/a&gt; about float points. Too bad the reading is complex and slow, but I recommend it to every programmer out there.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-1038524285501344805?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/1038524285501344805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/04/what-every-computer-scientist-should.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1038524285501344805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1038524285501344805'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/04/what-every-computer-scientist-should.html' title='What Every Computer Scientist Should Know About Floating-Point Arithmetic'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-8450783953841519112</id><published>2010-03-26T16:20:00.000-03:00</published><updated>2011-12-17T20:25:19.517-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Enabling ICS</title><content type='html'>I'm on fire this week. Another small help for our everyday use that I decided to post here since it took me quite a while to find it on the net.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was trying to enable ICS (Internet Connection Sharing) on Windows Vista and always got this error message:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"An error occurred while Internet Connection Sharing was being enabled.&lt;br /&gt;(null)"&lt;br /&gt;&lt;br /&gt;Well, I Googled it and found &lt;a href="http://forums.techguy.org/networking/799417-internet-connection-sharing-problem.html"&gt;this post&lt;/a&gt;&amp;nbsp;which gave the solution, which is to enable the following services:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Application Layer Gateway Service&lt;/li&gt;&lt;li&gt;Network Connections&lt;/li&gt;&lt;li&gt;Network Location Awareness (NLA)&lt;/li&gt;&lt;li&gt;Plug And Play&lt;/li&gt;&lt;li&gt;Remote Access Auto Connection Manager&lt;/li&gt;&lt;li&gt;Remote Access Connection Manager&lt;/li&gt;&lt;li&gt;Remote Procedure Call (RPC)&lt;/li&gt;&lt;li&gt;Telephony&lt;/li&gt;&lt;li&gt;Windows Firewall&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;In my case, the Windows Firewall was the&amp;nbsp;culprit. It's not ideal to have to have Windows Firewall running just to enable ICS, because I already have Symantec Firewall protecting me, so I hope Microsoft correct this sometime in the future.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-8450783953841519112?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/8450783953841519112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/03/enabling-ics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8450783953841519112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8450783953841519112'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/03/enabling-ics.html' title='Enabling ICS'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-2208704889516015966</id><published>2010-03-23T19:11:00.000-03:00</published><updated>2010-03-23T19:11:02.410-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google'/><title type='text'>Google in China</title><content type='html'>All this stuff about Google standing up to China's government,&amp;nbsp;Chinese&amp;nbsp;hackers et cetera has left only one question in my mind: why Google's front page is different in China?&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_mGql6Et46Z0/S6k8TW6KORI/AAAAAAAAAEg/0oBkwqbLQvU/s1600-h/chinese_google.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="275" src="http://3.bp.blogspot.com/_mGql6Et46Z0/S6k8TW6KORI/AAAAAAAAAEg/0oBkwqbLQvU/s640/chinese_google.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-2208704889516015966?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/2208704889516015966/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/03/google-in-china.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/2208704889516015966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/2208704889516015966'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/03/google-in-china.html' title='Google in China'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_mGql6Et46Z0/S6k8TW6KORI/AAAAAAAAAEg/0oBkwqbLQvU/s72-c/chinese_google.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-9209947306299784786</id><published>2010-03-23T16:40:00.000-03:00</published><updated>2010-03-23T16:41:46.443-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>What happened to File Assossiaction under Vista, Seven?</title><content type='html'>Back to my help-you-do-it articles...&lt;br /&gt;&lt;br /&gt;One thing bothered me for a while: our dear Microsoft removed the &lt;i&gt;file associations &lt;/i&gt;item that was under the Tools Menu.What the hell? I never quite understood why MS does that sometimes. Information Architecture is very important, and regrouping items might make things better for the user. However, those grouping and organizations should reflect what the user (us!) &lt;i&gt;believes&lt;/i&gt;&amp;nbsp;to be the right way to sort the information.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_mGql6Et46Z0/S6KPAkVaIOI/AAAAAAAAAEA/7GKbF-HzUYI/s1600-h/FolderOptionsVista.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_mGql6Et46Z0/S6KPAkVaIOI/AAAAAAAAAEA/7GKbF-HzUYI/s320/FolderOptionsVista.jpg" width="265" /&gt;&lt;/a&gt;&lt;/div&gt;I mean, when asked the question, "where is the right place to put &amp;lt;&lt;i&gt;something&lt;/i&gt;&amp;gt;&lt;this&gt;?", the answer is usually "where most users think it will be!". So Microsoft, where do *you* think your users look for file associations? Where it has been for more than a decade, under the Tools menu!&lt;/this&gt;&lt;br /&gt;&lt;br /&gt;When I was looking for it, to fix an association that another badly planned application decided to break, I&amp;nbsp;immediately went to the Folder Options, under the Tools Menu and looked for the association, which was no longer there.&lt;br /&gt;&lt;br /&gt;Before I panicked I decided to&amp;nbsp;Google&amp;nbsp;it, and found out that the associations are now under a specific application called &lt;i&gt;Default Programs&lt;/i&gt;, under the Control Panel.&lt;br /&gt;&lt;br /&gt;The Default Programs application is a more user-friendly version of the old File Associations tab. It lets the user change the default program that will open an file (based on the extension, as it's the custom in Windows), change the association between file extensions and programs, set the autoplay defaults, and even use a profile-like thing to rapid switch configurations for associations (which is done in order to enable the user to quick return to a Microsoft setting, of course).&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_mGql6Et46Z0/S6kCDzpdNjI/AAAAAAAAAEI/oZVXE9hdwIY/s1600-h/default_programs_menu.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="145" src="http://4.bp.blogspot.com/_mGql6Et46Z0/S6kCDzpdNjI/AAAAAAAAAEI/oZVXE9hdwIY/s200/default_programs_menu.jpg" width="200" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_mGql6Et46Z0/S6kCiMPqu4I/AAAAAAAAAEQ/HiQpKu7fXTA/s1600-h/file_associations.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/_mGql6Et46Z0/S6kCiMPqu4I/AAAAAAAAAEQ/HiQpKu7fXTA/s200/file_associations.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;So far, so good. If you need to reconfigure your file associations, you should look at this wizard.&lt;br /&gt;&lt;br /&gt;HOWEVER, where is the "advanced" button? None. Microsoft thinks all of us, users (even those with a Enterprise Version of Windows Vista) are dumb. So there's no way to change how the application is executed, like, for example, which parameters would be provided when calling a program to open a certain file. in my case, I was simply trying to tell windows that Java jar files are opened by calling java -jar JARFILE.&lt;br /&gt;&lt;br /&gt;Well, enough&amp;nbsp;complaining. How do we do it? There are two shell utilities, ASSOC and FTYPE, that enables us to do it. If changing the place of the interfaces was a bit unfortunate, I must say that the new solution is way better. ASSOC and FTYPE lets us create a N to N association between file types and extensions, and it's much more clean than the way it worked with the old interface.&lt;br /&gt;&lt;br /&gt;You must take two steps in any order when defining the associations:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Define the File Type&lt;/b&gt;&lt;br /&gt;A file type is a kind of "profile" for your file (I think &lt;i&gt;file&lt;/i&gt; &lt;i&gt;class&lt;/i&gt;&amp;nbsp;would be an even better name).&amp;nbsp;You name it anything you'd like and informs how it's opened. On my Java JAR example:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #cccccc;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;FTYPE jarfile="C:\aplic\Java\jre6\bin\javaw.exe" -jar "%1" %*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;where %1 is the filename that Windows will gladly pass to your application and %* tells windows to "pass everything else to the program the way you received it". The last one doesn't make much sense in Windows, but the truth is that the shell will also use this list to open files, so if you simply type the filename on the prompt, you end up opening the file.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Create the Association&lt;/b&gt;&lt;br /&gt;Now, for the association itself,&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="background-color: #cccccc;"&gt;ASSOC .jar=jarfile&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;which is quite intuitive: you tell Windows to threat files with .jar extension as jarfiles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-9209947306299784786?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/9209947306299784786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/03/what-happened-to-file-assossiaction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/9209947306299784786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/9209947306299784786'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/03/what-happened-to-file-assossiaction.html' title='What happened to File Assossiaction under Vista, Seven?'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_mGql6Et46Z0/S6KPAkVaIOI/AAAAAAAAAEA/7GKbF-HzUYI/s72-c/FolderOptionsVista.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-637986178929467358</id><published>2010-03-09T17:29:00.001-03:00</published><updated>2010-03-23T16:45:19.622-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Chrome'/><title type='text'>Sorry Chrome</title><content type='html'>&lt;a href="http://3.bp.blogspot.com/_mGql6Et46Z0/S6kaIpg1aJI/AAAAAAAAAEY/aambr5r5Kq0/s1600-h/blog_tool_overlay_error.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/_mGql6Et46Z0/S6kaIpg1aJI/AAAAAAAAAEY/aambr5r5Kq0/s320/blog_tool_overlay_error.jpg" width="164" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Should I be surprised that Chrome doesn't work with this GOOGLE website?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-637986178929467358?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/637986178929467358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/03/sorry-chrome.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/637986178929467358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/637986178929467358'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/03/sorry-chrome.html' title='Sorry Chrome'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_mGql6Et46Z0/S6kaIpg1aJI/AAAAAAAAAEY/aambr5r5Kq0/s72-c/blog_tool_overlay_error.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-7737801430044879519</id><published>2010-03-09T17:27:00.001-03:00</published><updated>2011-03-18T11:14:40.347-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Elements and Attributes in XML</title><content type='html'>Today I got myself wondering about when to use differences and attributes in XML. The general&amp;nbsp;understanding&amp;nbsp;is that the question is very&amp;nbsp;philosophical, depending on how your system is designed and, even more, on how you &lt;i&gt;understand the data in your application&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;However, the subject isn't new and there are a lot of articles on the web that already deal with the issue. So, instead of repeating what other, more experienced people already wrote, I'd rather appoint readers in the right direction:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://w3future.com/html/stories/elemvsattrs.xml"&gt;Elements vs. Attributes&lt;/a&gt; in &lt;a href="http://w3future.com/"&gt;w3future&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-7737801430044879519?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/7737801430044879519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/03/elements-and-attributes-in-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/7737801430044879519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/7737801430044879519'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/03/elements-and-attributes-in-xml.html' title='Elements and Attributes in XML'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-4868130887759857585</id><published>2010-02-12T11:37:00.001-02:00</published><updated>2010-08-05T12:11:03.505-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Wave'/><title type='text'>What About Google Wave?</title><content type='html'>I'm a technology enthusiast. Let me rephrase that: I'm a &lt;i&gt;software&lt;/i&gt;&amp;nbsp;enthusiast.&amp;nbsp;Every time&amp;nbsp;I can lay fingers on a new piece of software, I do. I have installed and run VirtualBox on my computer, just for the sake of it; I use Cygwin daily. I don't need but use OneNote because the concept is cool. I'm currently learning Powershell scripting and my navigator of choice is Chrome, just because Google decided to use &lt;i&gt;processes&lt;/i&gt;&amp;nbsp;instead of &lt;i&gt;threads&lt;/i&gt;. And, of course, when Google Wave was announced at Google I/O, I couldn't wait to put my hands on it!&lt;br /&gt;&lt;br /&gt;At first I was, of course, astonished. Google delivered almost everything the presentation first promised, which was indeed a lot. At first look, I found the tool to be very similar to a web forum. I even guess that was one of the goals, uniting the community activity of forums to email. As a tool, everything was sleek and had that "Google touch", which means good quality, a lightweight interface, strange coloring, etc. The site makes extensive use of AJAX to offer a seamless interface and dynamic loading of data. The load time for the items are as expected: good as long as they aren't cluttered with posts.&lt;br /&gt;&lt;br /&gt;The best features are the phenomenal integration with YouTube! and Gears, the possibility to upload files to a persistent location which makes sharing that more easier (even though I haven't really discovered the size limit for each file) and the formating, which is very present, so users are encouraged to write visually rich "articles". Finally, some of it's real-time features can add something to the experience, even though I think that is far from being one of the product's best qualities.&lt;br /&gt;&lt;br /&gt;But, whereas technically Google Wave stands out as a very polished tool filled with features, conceptually, it's flawed. Google aimed high and large: Wave was going to replace e-mail, forums, IM, etc -- almost every well established electronic communication tool out there. And the application had a list of features to make up for each of those tools that we use. Problem is, as it's usually the case with swiss-knives kinds of software (or any product, for that matter), Wave accomplishes almost none of the &lt;i&gt;replacements&lt;/i&gt; it proposed itself to:&lt;br /&gt;&lt;br /&gt;When compared to forums, you will discover that not being "public" makes Wave less than useful. It's cool to discuss about that new movie with your friends, but community boards will enable you to get a different point of view every now and them, so important to discussions.&lt;br /&gt;&lt;br /&gt;And then Wave should replace e-mail. E-mails chains are like stacks of information. Everyone adds something to the top, and you "can't" change what already has been done (on some cases, e-mail is more a tree, because of simultaneous replies, but that doesn't happens very often). Wave, however, threats information like a "live" document, which is compatible with the Collaboration Age (or &lt;i&gt;Collaboration Wave&lt;/i&gt;, as one might call...). So what you said&amp;nbsp;yesterday&amp;nbsp;may change today, or even cease to exists. It's confusing. There's a feature that tries to solve (&lt;i&gt;patch&lt;/i&gt;) that, called "history", but it's like a pain to use it to check what you missed. On a e-mail, you just have to scroll-down the screen a bit and there it's, that last piece of info that you forgot to read. On Wave's History, you will keep going back and forth until you discover what was there but isn't anymore.&lt;br /&gt;&lt;br /&gt;And IM? Well, Google shouldn't even have proposed that. IM works because you have a small icon on your desktop that you can double-click in order to get a list of contacts and start talking with whoever is online. It's &lt;i&gt;that&lt;/i&gt;&amp;nbsp;simple. On wave, to IM, you use the IM panel, which is just like a sized-down version of Google Talk... So, why would you? Isn't it easier to Google Talk anyway?&lt;br /&gt;&lt;br /&gt;All things said, I must add that the worst part of Google Wave is the problem that, for a dynamic application, the topics are treated very statically. Let's say you send your pals an e-mail about that latest game for Playstation. You start talking how it reminded you of a certain movie, and before you know, your friends started talking about movies. After a while, the subject changes slightly, after another friend adds that &lt;i&gt;this actor was once arrest for drug use, &lt;/i&gt;and then you're discussing the lives of the famous. That's is a bit chaotic, indeed, but so are conversations. They rarely ever turns into what we wanted in the first place... once they begin, they become live things that change whenever something different is said, because that's the way the brain works, by making free association of ideas. When you try to have this same conversation in Wave, however, things get a bit confusing. Since Waves are so clearly &lt;i&gt;persistent&lt;/i&gt;, you look at them that way. You start a Wave about a trip to Europe, you hope people only talk about that in there, which doesn't happens. Someone ends up saying something about a bar or restaurant, someone remembers about another one in your own city, and all the sudden your Wave about Europe is now arranging a dinner with your friends. And worse, since you can post anywhere (Waves are flattened-down trees), the subjects are intertwined. One can argue that this would resemble our thinking process even better than e-mail, but as a tool, it gets messy.&lt;br /&gt;&lt;br /&gt;All-in-all, Google has offered us a nice product, with nice features, that is useless only because all its older brothers are more effective at what it does.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-4868130887759857585?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/4868130887759857585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/02/what-about-google-wave.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4868130887759857585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4868130887759857585'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/02/what-about-google-wave.html' title='What About Google Wave?'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-1588840874949896114</id><published>2010-01-21T17:40:00.000-02:00</published><updated>2010-03-23T16:45:41.053-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mainframe'/><category scheme='http://www.blogger.com/atom/ns#' term='COBOL'/><title type='text'>Why COBOL Is Bad For Your Health</title><content type='html'>&lt;span style="font-size: 13px;"&gt;&lt;i&gt;Before you think that I'm going to continue one of the eternal developers discussions like Windows x Linux, or C# x Java or even OGL x DX, &lt;/i&gt;&lt;b&gt;&lt;i&gt;I'm not&lt;/i&gt;&lt;/b&gt;&lt;i&gt;. COBOL is a useful language and will remain that way for a very long time. It has and keeps serving its purpose, which is to be a language&amp;nbsp;targeted&amp;nbsp;at non-programmers, mostly business analysts, with very few or none programming knowledge whatsoever. What I'm about to state here are the deficiencies of COBOL: being business oriented has its cost and COBOL pays dearly for it.&amp;nbsp;Also appreciate that I have good knowledge over COBOL, Mainframe, and Batch architecture. However, I was groomed in C/C++ and specialize in distributed systems, so I have a reasonable understanding&amp;nbsp;of both worlds.&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;Recently a fellow in my team asked me why I &lt;i&gt;hated&lt;/i&gt;&amp;nbsp;COBOL so much. To keep things short, my answer was that I did not hate COBOL at all, but I thought that there were better languages which could do COBOL work better; I stated that COBOL syntax might be easy and simple, however, COBOL programs are semantically obscure and can often lead very bad algorithms. I'm now going to explain why I think that.&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: 13px;"&gt;Remember that I'm not a doom-sayer. COBOL isn't dead, nor is it going to die. It has its purpose, and it does it well enough. People will keep learning COBOL for a long time now, and many enterprises will&amp;nbsp;continuously&amp;nbsp;grow their mainframe platform.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: 13px;"&gt;So, without further ado, let's give you my reasons why I believe that &lt;b&gt;COBOL is bad for your health:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;SECTION A - CODE SAFETY:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;I. All Variables Are Global&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;It probably goes without saying (at least to any weathered, non-COBOL programmer), that you shouldn't use global variables in your programs. Globals are &lt;i&gt;bad for your health&amp;nbsp;&lt;/i&gt;because it's hard to predict their value, the reason for that beings that every single instruction inside the program might modify it.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;If your program has less than two hundred lines &lt;b&gt;and&lt;/b&gt; variables follow good naming rules &lt;b&gt;and&lt;/b&gt; if you're not using &lt;i&gt;redefines&lt;/i&gt;, maybe you can find out where the variable is accessed and predict its value. But in a world where the average COBOL program has way more than ten times that number of lines, you are in for a very hard "mind compiling" experience.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Moreover, there's a have a side-effect of variable cramming. Whenever a programmer needs to extend or fix the source of a COBOL program, instead of using the variables that already are there (since he can't know where the given variable is&amp;nbsp;accessed), he declares a new variable. The effect of this is that the source end up having more variables than effectively necessary and gets even harder to read. Add to that the fact that COBOL doesn't allow variables to be declared within procedure code (like old C), and now you have this programmer hell: many variables whose declaration are very far on the code from their use spot, which means a lot of scrolling up and down the source.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;II. Variables Aren't Type Safe&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;&lt;/b&gt;Type safety is a very complex subject. Many languages that are perceived as type safe actually aren't -- C/C++ can cast anything to void, and void can be cast to anything -- but COBOL goes way beyond that when it gives programmers REDEFINES. REDEFINES allows anything to be seem as a different type at compile time, and is, in many ways, a cast.&amp;nbsp;One can argue that C/C++ presents us with a similar structures with &lt;i&gt;unions&lt;/i&gt;. However, for some reason, C/C++ programs hardly ever use unions, preferring to have a &lt;i&gt;bytestream&lt;/i&gt; that is then copied to a new instance of a certain type.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Besides, COBOL also have "untyped" variables, called group items. Group items in COBOL are similar to &amp;nbsp;C &lt;i&gt;structs&lt;/i&gt;, being a definition of a group of variables that are &lt;i&gt;aligned together&lt;/i&gt;&amp;nbsp;in the memory. However, in COBOL, those group items doesn't have a defined type, and the compiler allows that any date be moved to such group or from the group. There is no &lt;i&gt;runtime&lt;/i&gt; boundary checking&amp;nbsp;as well, so you can easily overflow the area. What COBOL does for you instead is area truncating. It's&amp;nbsp;completely&amp;nbsp;left to the programmer the&amp;nbsp;responsibility of knowing the types fit.*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;II. Variables Aren't Really Typed&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;This one will probably be the most polemic point here. COBOL use a typing system that includes mainly two types of variables, &lt;i&gt;numeric&lt;/i&gt;&amp;nbsp;and &lt;i&gt;text&lt;/i&gt;. Numeric variables can be of COMPUTATIONAL type, which means that they allow numeric data but such data is stored on a different way -- compacted. The first criticism here is that, for a language called 3GL, COBOL, exposes a lot of the underlying implementation to its programmer, which has to know the differences between compacted COMPUTATIONAL data and "common". Of course, there are historical factors that led to this implementation, namely, the fact that storage was way more expensive when COBOL was conceived. But using this as an excuse only proves that COBOL is obsolete and should be dumped.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;SECTION B - Code Structure&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;I. Where You Write Your Code Matters&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;COBOL still inherits a lot from punched-card days. In COBOL, code can only be contained between column 8 and 72, and column 7 is reserved for "indicators", that can help you inform the compiler that the following line is a commentary or a continuation from the previous line.&amp;nbsp;Add to that the fact that some commands need to start on what COBOL calls AREA B. Area B starts at the column 11.&amp;nbsp;This means that you have only 61 characters to input commands, which are very long in nature already (you need a least 11 characters to write an attribution, for example). And remember that variables tends to have lots of prefixes and suffixes, because the COBOL scope member operator OF is never used.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;II. Periods Are Both Scope And Statement Terminators&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Another one of COBOL strange behaviors that will make you shiver. In COBOL, you can&amp;nbsp;finish statements with a period ("."). You &lt;i&gt;can&lt;/i&gt;, because most of the time you don't need to. &lt;i&gt;Most of the time&lt;/i&gt;, because sometimes they are necessary. Already confused? Well, it gets worse. In COBOL, you also close scope with a period. So, if you begin an IF construct and stick a period just after the first statement, the scope is terminated and whatever comes afterwards is considered outside from the IF.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;So, if you decided to stick periods after all sentences, you can't. So you decide to abandon periods, and be on the safe, never ending a loop or scope&amp;nbsp;accidentally... but, just like we said, you can't. &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;III.&amp;nbsp;Idiosyncrasies&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;COBOL is a champion when it comes to idiosyncrasies. For example, assignments in COBOL are written as MOVE variable TO variable. Moving is usually conceived as taking something from one place and putting it somewhere else, but assignment works by copying the value of a certain variable to the value of another one, and that's exactly what the MOVE operator does in COBOL.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;i&gt;&lt;b&gt;In sum...&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;There are a lot of reasons why COBOL should be avoided at your enterprise. Sure, you can have a person trained in COBOL in less than a week, but how long will you take to remove bugs from his code? How many bugs will appear in the future? COBOL is a counter-productive language, that encourages bad developers to write bad code.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;&lt;i&gt;* COBOL has evolved during the years, and so have the compilers. I wouldn't be surprised if there was a compiler directive that allowed such checking to be made, but I must say that I never saw anyone using it.&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-1588840874949896114?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/1588840874949896114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2010/01/why-cobol-is-bad-for-your-health.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1588840874949896114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1588840874949896114'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2010/01/why-cobol-is-bad-for-your-health.html' title='Why COBOL Is Bad For Your Health'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-8188584492653363579</id><published>2009-10-02T17:44:00.000-03:00</published><updated>2009-10-02T17:44:07.223-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='ShellScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Bash'/><title type='text'>Variable Scoping In Bash Functions</title><content type='html'>Quick and dirty, people. Today I was testing some complex bash scripts that we wrote on my current project assignment -- those which should have been a python or pearl script to begin with -- and bumped into a problem concerning functions and variable scope.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since I'm mainly a C* programmer (C, C++ and C#), my shellscript looks too much like a common program, admittedly. This means that I use a lot of functions. But there's a catch: variables used in bash are automatically global. So, if I execute the portion of code below:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function test()&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;value=123&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;echo $value&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;value=321&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo $value&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;test &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo $value&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I will get the following output:&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;321&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;123&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;123&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Which isn't what I intended. So, I found this nice command that was secret to me, called "&lt;i&gt;local&lt;/i&gt;". Variables in bash &lt;b&gt;can&lt;/b&gt; be declared, and it's scope can be determined by using this command. So, the following script:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function test()&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;local value=123&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;echo $value&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;value=321&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo $value&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;test&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo $value&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Which would produce:&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;321&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;123&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;321&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Which would be exactly what I desired.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-8188584492653363579?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/8188584492653363579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2009/10/variable-scoping-in-bash-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8188584492653363579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/8188584492653363579'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2009/10/variable-scoping-in-bash-functions.html' title='Variable Scoping In Bash Functions'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-4626184798278736169</id><published>2009-08-19T12:52:00.003-03:00</published><updated>2010-04-30T11:57:37.672-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Review'/><category scheme='http://www.blogger.com/atom/ns#' term='Hardware'/><category scheme='http://www.blogger.com/atom/ns#' term='Rant'/><title type='text'>ThinkPad T400</title><content type='html'>Today I got my "new" &lt;i&gt;&lt;span class="goog-spellcheck-word"&gt;Lenovo&lt;/span&gt; &lt;span class="goog-spellcheck-word"&gt;ThinkPad&lt;/span&gt; T400&lt;/i&gt; as part of a hardware upgrade program from &lt;span class="goog-spellcheck-word"&gt;Accenture&lt;/span&gt;. Every 3 years (in my case, 2,5) &lt;span class="goog-spellcheck-word"&gt;Accenture&lt;/span&gt; upgrades our notebooks, since, of course, they get aged somewhat fast after intense use. And, in my case, they also get outdated because customers like cutting-edge technology, and cutting-edge technology needs cutting edge hardware to be developed upon.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, I got this business oriented&lt;i&gt; &lt;span class="goog-spellcheck-word"&gt;Lenovo&lt;/span&gt; &lt;span class="goog-spellcheck-word"&gt;ThinkPad&lt;/span&gt; T400&lt;/i&gt;. And I've decided to blog about it, because I'm tired of complaining to the walls (or to my girlfriend). Considering just the hardware, this notebook is top value. Good &lt;span class="goog-spellcheck-word"&gt;HD&lt;/span&gt; (160GB 7400RPM), nice RAM (3GB), the case seems sturdy, and the battery life is amazing. Besides that, the screen has a cool lamp that lights the keyboard, in case you have to type in complete darkness and can't find the keys. Cool, but not sure if it's useful.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, for the rant. &lt;span class="Apple-style-span" style="text-decoration: underline;"&gt;The keyboard plainly sucks&lt;/span&gt;. I have no better term so, sorry purists, but this is it: the keyboard sucks. Every key that isn't the default QWERTY has a terrible placement. &lt;span class="goog-spellcheck-word"&gt;Lenovo&lt;/span&gt; has put a lot of work into making this notebook very small, and reducing keyboard's size occupation was probably #1 concern. to achieve this, some keys are way smaller than the others, like, for example, the Windows Key, which is narrower than the rest, may escape your fingers (if you type on such a hurry as I do).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The worse, however, remains for the "&lt;span class="goog-spellcheck-word"&gt;Fn&lt;/span&gt;" and &lt;span class="goog-spellcheck-word"&gt;ESC&lt;/span&gt; key. &lt;span class="goog-spellcheck-word"&gt;Fn&lt;/span&gt;, for those who are new to the notebook world, is a special function key that works similarly to &lt;span class="goog-spellcheck-word"&gt;CTRL&lt;/span&gt; or ALT -- you need to hold it and press a certain key to access special notebook functions. The &lt;span class="goog-spellcheck-word"&gt;Fn&lt;/span&gt; key was placed just below the left-shift key, just where the &lt;span class="goog-spellcheck-word"&gt;CTRL&lt;/span&gt; should be. Now for those who, like myself, use the&amp;nbsp;&lt;i&gt;side&lt;/i&gt; of the small finger to hold the &lt;span class="goog-spellcheck-word"&gt;CTRL&lt;/span&gt;, this is a nightmare. &lt;span class="goog-spellcheck-word"&gt;Fn&lt;/span&gt; has much less function than &lt;span class="goog-spellcheck-word"&gt;CTRL&lt;/span&gt;, but the key is in a more reachable place.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In my case, the worse part is that I use a lot of &lt;span class="goog-spellcheck-word"&gt;CTRL&lt;/span&gt;+Right and &lt;span class="goog-spellcheck-word"&gt;CTRL&lt;/span&gt;+Left to skip words when typing, but on the &lt;span class="goog-spellcheck-word"&gt;Lenovo&lt;/span&gt;, &lt;span class="goog-spellcheck-word"&gt;Fn&lt;/span&gt;+Right and &lt;span class="goog-spellcheck-word"&gt;Fn&lt;/span&gt;+Left skips a track on whatever multimedia player is running (it's a Windows' multimedia key). I still haven't learned how to disable this function.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also, the &lt;span class="goog-spellcheck-word"&gt;ESC&lt;/span&gt; key is sitting on the top of the board, &lt;b&gt;above the F1 key&lt;/b&gt;. I find myself reaching for &lt;span class="goog-spellcheck-word"&gt;ESC&lt;/span&gt; and hitting F1 instead, which usually means opening Help. It's annoying. Since &lt;span class="goog-spellcheck-word"&gt;ESC&lt;/span&gt; is a big part of Windows, this is almost worse than control. Luckily, I use it less than I thought and it's easier to get used to it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally there is the Track Point in the middle of the keyboard. This one is hard to decide -- there are people who loves it, but on my opinion, I have the touch pad, thank you very much. My complain is that I end up touching it when travelling over the keyboard. This is annoying, but if it was the only problem, I wouldn't care about it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For those of you using a Desktop, think how awful would it be if you couldn't change the keyboard, if you were stuck with a &lt;span class="goog-spellcheck-word"&gt;ESC&lt;/span&gt; in a wrong position. Now, think about it, but without a mouse. Sounds like hell, doesn't it?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-4626184798278736169?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/4626184798278736169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2009/08/thinkpad-t400.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4626184798278736169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4626184798278736169'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2009/08/thinkpad-t400.html' title='ThinkPad T400'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-1979427437617040634</id><published>2009-01-19T16:50:00.000-02:00</published><updated>2009-01-19T17:01:34.695-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual SourceSafe'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Quick Tip: SourceSafe Internet Plug-in</title><content type='html'>Hello crowd,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I've AFK (at least, in a blog sense) for quite a while but now I think I will have more free time. I'll begin this new year with a quick tip:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I use Visual SourceSafe a lot -- it's the our default's SCM solution -- and I've ran into a problem some time ago: I wanted to use the internet (&lt;span class="Apple-style-span" style="font-style: italic;"&gt;HTTP)&lt;/span&gt; version of the program. The reason for that was that our VSS database was stored on a Windows XP machine it's impossible to connect more than 10 simultaneos people to share in those OS. So, I thought that maybe the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;HTTP &lt;/span&gt;version of the plugin wouldn't have such restriction. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was wrong.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, problem is that I didn't know how the plugin worked:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;First, the plugin &lt;span class="Apple-style-span" style="text-decoration: underline; font-style: italic; -webkit-text-decorations-in-effect: underline; "&gt;is only for Visual Studio&lt;/span&gt;, which means that visualization through the VSS client still is done through Windows Folder Sharing.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;IIS HTTP has the same limitations as WFS.&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;The plugin is configured on the Options-&gt;Tools menu in Visual Studio, under Source Control -&gt; Plugin Selection, which enables one to choose between common (WFS) or internet (HTTP) communication.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Of all the info on this post, the third one is the most important, since after I configured the plugin (clicking such option on a message box that poped-up), I took me almost a day to find how to turn back to the WFS plugin.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-1979427437617040634?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/1979427437617040634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2009/01/quick-tip-sourcesafe-internet-plug-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1979427437617040634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1979427437617040634'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2009/01/quick-tip-sourcesafe-internet-plug-in.html' title='Quick Tip: SourceSafe Internet Plug-in'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-6315207606468279881</id><published>2008-11-21T16:33:00.000-02:00</published><updated>2008-11-21T17:17:01.152-02:00</updated><title type='text'>Do you have to know English to be a Programmer?</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;This one comes from a large chain of events, and since I like continuity, I am posting about it. This question, “Do you have to know English to be a Programmer?” was a subject on a blog post, &lt;/span&gt;&lt;a href="http://hype-free.blogspot.com/2008/10/should-we-use-english.html"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US"&gt;http://hype-free.blogspot.com/2008/10/should-we-use-english.html&lt;/span&gt;&lt;/a&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US"&gt;. It was sppoted by me on Scott Hanselman’s blo&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US; mso-fareast-language:PT-BR"&gt;g. It is a big question, and a very important one at that. &lt;/span&gt;&lt;span lang="EN-US"   style="line-height:115%; font-family:&amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;mso-fareast-font-family:&amp;quot;Times New Roman&amp;quot;; mso-bidi-Times New Roman&amp;quot;;mso-ansi-language:EN-US;mso-fareast-language: PT-BRfont-family:&amp;quot;;font-size:10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;As you should know (just by looking at my right sidebar), I am a Brazilian, which means my language is Portuguese (which should be called “&lt;i style="mso-bidi-font-style:normal"&gt;brasilianese&lt;/i&gt;” or something), and I began learning English when I was only six years old. I have been interacting with the language ever since.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;Therefore, my knowledge of English is prior to my knowledge of programming, which makes my opinion less relevant in the matter somehow. However, why did I learn English in the first place? I think it was about the same reason that would lead a programmer to learn it – I loved to play video games back in my childhood, and those only came in English. Programmers, I believe, also learned because of a similar fact, &lt;i style="mso-bidi-font-style:normal"&gt;software usually come in English&lt;/i&gt;. There are exceptions – mainly for those who live in more developed countries or regions, like Europe. There are better efforts at software localization nowadays, and that means a lesser necessity in dealing with non-native language.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;Nevertheless, I must come back to the phrase – “&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US"  style="mso-bidi- line-height:115%;mso-ansi-language:EN-USfont-size:8.0pt;"&gt;Do you have to know English to be a Programmer?” I think that such question is very gray, since we have not stated what is “know” and what is “Programmer”. If anyone who writes a hello world or a simple script is to be considered a programmer, then, &lt;i style="mso-bidi-font-style:normal"&gt;in my opinion, &lt;/i&gt;the answer is &lt;i style="mso-bidi-font-style:normal"&gt;no&lt;/i&gt;, you do not have to know English for that. But if I rephrase the question:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="apple-style-span"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span lang="EN-US"  style="mso-bidi-line-height:115%; mso-ansi-language:EN-USfont-size:8.0pt;"&gt;Do you have to be able to read some English to be a good programmer?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US"  style="mso-bidi-line-height:115%;mso-ansi-language:EN-USfont-size:8.0pt;"&gt;The answer is a very big YES! Why:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpFirst" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US"  style="font-family:Symbol;mso-fareast-font-family: Symbol;mso-bidi-mso-ansi-language:EN-US;mso-fareast-language: PT-BRfont-family:Symbol;"&gt;&lt;span style="mso-list:Ignore"&gt;·&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US"  style="mso-bidi-line-height:115%;mso-ansi-language: EN-USfont-size:8.0pt;"&gt;Main technologies researches that happen worldwide are conducted in English. Researches make this choice, because their product needs to have a reach as large as possible. Sure, you could wait for someone to translate a given book or article, but good programmers should know about newer technologies as soon as possible, to be ahead of competition.&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US; mso-fareast-language:PT-BR"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US"  style="font-family:Symbol;mso-fareast-font-family: Symbol;mso-bidi-mso-ansi-language:EN-US;mso-fareast-language: PT-BRfont-family:Symbol;"&gt;&lt;span style="mso-list:Ignore"&gt;·&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US"  style="mso-bidi-line-height:115%;mso-ansi-language: EN-USfont-size:8.0pt;"&gt;Translations are, often, very poor (&lt;i style="mso-bidi-font-style:normal"&gt;all your bases are belong to us&lt;/i&gt;) and small variances can lead to big mistakes.&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US; mso-fareast-language:PT-BR"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom:0cm;margin-bottom: .0001pt;mso-add-space:auto;text-indent:-18.0pt;line-height:normal;mso-list: l0 level1 lfo1"&gt;&lt;span lang="EN-US"    style=" font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi- mso-ansi-language:EN-US;mso-fareast-language:PT-BRfont-family:Symbol;font-size:10.0pt;color:black;"&gt;&lt;span style="mso-list:Ignore"&gt;·&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US; mso-fareast-language:PT-BR"&gt;As an engineer, I love standardization, and I’d choose English as the one. Some could argue about the fact that Spanish is one of the most widespread languages in the world, but I guess they’re missing the fact that many Spanish programmers already know English, while the inverse isn’t true.&lt;/span&gt;&lt;span lang="EN-US"    style="font-family:&amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-Times New Roman&amp;quot;; mso-ansi-language:EN-US;mso-fareast-language:PT-BRfont-family:&amp;quot;;font-size:10.0pt;color:black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpLast" style="margin-bottom:0cm;margin-bottom:.0001pt; mso-add-space:auto;text-indent:-18.0pt;line-height:normal;mso-list:l0 level1 lfo1"&gt;&lt;span lang="EN-US"    style="font-family:Symbol;mso-fareast-font-family: Symbol;mso-bidi-mso-ansi-language:EN-US; mso-fareast-language:PT-BRfont-family:Symbol;font-size:10.0pt;color:black;"&gt;&lt;span style="mso-list:Ignore"&gt;·&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US; mso-fareast-language:PT-BR"&gt;Most computer languages are in English (actually, I don’t know of any in another language).&lt;span class="Apple-style-span" style="font-size: 48px; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;Communication is very import in this age, and we need a language that enables a standard effective one. On computer-side, this one seems to be XML (which, by-the-way, is in English). The human counterpart is English. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;However, I do not mean to say that there are not good programmers who cannot understand English. Every rule has exceptions, and this one is no exception (unless there is a exception… wait…).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language:EN-US;mso-fareast-language: PT-BR"&gt;What do you think?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-6315207606468279881?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/6315207606468279881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2008/11/do-you-have-to-know-english-to-be.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6315207606468279881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/6315207606468279881'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2008/11/do-you-have-to-know-english-to-be.html' title='Do you have to know English to be a Programmer?'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-167417682324463462</id><published>2008-10-22T05:00:00.000-02:00</published><updated>2008-10-22T12:44:37.940-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Excel Tips &amp; Tricks I - Removing Duplicates</title><content type='html'>&lt;div style="text-align: justify;"&gt;And one more article is blooming now. For a time I've been thinking about this specific article: how to do some [basic] stuff in Excel. (I call it 'basic' because you probably will use it very constantly.) Stuff that is actually helpful, and simple to do -- not like the previous article that was a bit more complex than first intended -- but actually so simple that you need not be an Excel expert to do it.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;First of all, why I should be talking about Excel? I'm specialized in software engeneering, so maybe I should keeping talking about scripting or maybe even programming. But the truth is that Excel is the most useful tool in my computer, way above any IDE that I have here or scripting tool or whatever.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Why? Excel is capable of scripting, for one thing. Second, there's no more intuitive way of organizing data for a human beam than using a bidime&lt;/div&gt;&lt;div&gt;nsional table. Finally, Excel can help us format this data in a very professional (which means "pretty") way, automatically.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;I. Removing Duplicates&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That said, one of the bests uses for excel is to gath&lt;/div&gt;&lt;div&gt;er data... maybe records from a report, maybe names from a list, whatever. This data often contains duplicates that need to be removed so that the analisys can be made. There are many different ways to remove those duplicates -- and in Excel 2007 Microsoft has finally included a functionality that does this for us.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But since most of us still use Excel 2003 or less, it's very important to know how to best do this. So, here's a very simple tutorial:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;1. Define the Key Column&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The first step is to define which column(s) will be used in the duplicated comparison. Let's ilustrate: you have a employee list. On column A is the employee name, on B his last name, on C his carrer level name and on D his montly wage. You know for a fact that someone screwed up the report and there are duplicates records -- the same employee appears more than once on the list. It's your purpose to create SERIAL NUMBER&lt;/div&gt;&lt;div&gt;S for your employees, but first you will need to clean-up the list.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, you also expect to have duplicates first names in your organization, after all, we are talking about a lot of people. So to determine that th&lt;/div&gt;&lt;div&gt;e record is a duplicate of a previous one? You will have to join the Last Name and the First Name to create a third column. This column will be called your KEY column, and it's where we check for duplicates.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://4.bp.blogspot.com/_mGql6Et46Z0/SP4oj1g0IZI/AAAAAAAAABc/3n3xLI0RGWw/s400/excel1.1.bmp" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" border="0" alt="" id="BLOGGER_PHOTO_ID_5259686010940563858" /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Example Sheet&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;In our example, the "KEY" column is the concatenation of both NAME and SERIAL NUMBER. We create this in the E column. To concatenate both values, you can either use the CONCATENATE function or just the join operator (&amp;amp;); I preffer the latter, so your cells should have the following formula: &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;=B2&amp;amp;A2&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;...which is self-explanatory. This column should not have duplicates -- and this is how you ensure that:&lt;/div&gt;&lt;div style="text-align: left; "&gt;&lt;ul&gt;&lt;li&gt;Sort your KEY column (E) in Ascending Order. &lt;/li&gt;&lt;li&gt;Create another column, labelled DUPLICATED?, which should compare if a given item from column E is equal to the previous one, using the formula:&lt;br /&gt;&lt;br /&gt;=E2=E1&lt;br /&gt;&lt;br /&gt;Resulting in true for whatever lines are duplicates from the first one.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;No you can filter you sheet to select only duplicated lines:&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_mGql6Et46Z0/SP84-7nqYaI/AAAAAAAAABk/KUmS7rk8KL8/s1600-h/excel1.2.bmp"&gt;&lt;img src="http://3.bp.blogspot.com/_mGql6Et46Z0/SP84-7nqYaI/AAAAAAAAABk/KUmS7rk8KL8/s400/excel1.2.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5259985543599120802" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Before filtering...&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_mGql6Et46Z0/SP85pbnaUvI/AAAAAAAAABs/vK0mQ7Z2ipk/s1600-h/excel1.3.bmp"&gt;&lt;img src="http://1.bp.blogspot.com/_mGql6Et46Z0/SP85pbnaUvI/AAAAAAAAABs/vK0mQ7Z2ipk/s400/excel1.3.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5259986273742508786" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; " /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;...and after filtering.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;Now, all you have to do is exclude the duplicated lines. To do this, select the first line (in the example, click on "Henry"), then, holding both CTRL and SHIFT, press "down" &lt;span class="Apple-style-span" style="text-decoration: underline;"&gt;once&lt;/span&gt;, which should select all cells in A. Now, hold SHIFT only and press "space". This will select the whole line (even empty cells). Right-click the selecion and choose "Delete Row". &lt;/li&gt;&lt;li&gt;Clear the filter and the duplicated will have disappeared.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;That's all for this tip. It's quite easy to do this when after you did it two or three times, and it's handy. Users of Excel 2007 might even preffer to remove duplicates this way since you will see exactly what you are removing.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next week I will post another tip, this time on coloring odd lines in a document.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-167417682324463462?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/167417682324463462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2008/08/excel-tips-tricks-i.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/167417682324463462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/167417682324463462'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2008/08/excel-tips-tricks-i.html' title='Excel Tips &amp; Tricks I - Removing Duplicates'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_mGql6Et46Z0/SP4oj1g0IZI/AAAAAAAAABc/3n3xLI0RGWw/s72-c/excel1.1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-9090135088272342019</id><published>2008-09-06T17:37:00.000-03:00</published><updated>2008-09-06T18:05:08.826-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet Explorer'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Microsoft Always Think We Default To "Stupid"</title><content type='html'>While I write my next real blog post, a minor rant (and something to remember when you are developing an application):&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Microsoft newer products, since the complete widespreading of Internet, which would begin by the end of the last century, are PARANOID. First of all, they assume the user is a complety newbie that will do everything wrong. Secondly, they assume everything outside (and, sometimes, inside) the computer that can be harmful &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;will be&lt;/span&gt;. In other words, MS has closed all doors to your computer that &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;they&lt;/span&gt; could imagine, so that no hacker could exploit them. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Of course, all this paranoia accomplished nothing. MS browsers, OSes and Applications are still vunerable to exploits. But it also made the life of the user (us!) much more difficult -- we have to click a lot of pop-ups to let our applications make anything deemed harmful, like downloading a file from the internet or modifying the system register. But today, I've come to the best example of how this untrusting paranoia can be paradoxal:&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I use MS Project server on my projects and today I decided to try to integrate it with my Outlook 2007. So I navigate to the Project portal and browse to the web page where I can download the plugin. Naturally, this is a ActiveX plugin that is &lt;span class="Apple-style-span" style="font-style: italic;"&gt;unsafe&lt;/span&gt; accordingly to Microsoft, so when I click the button, I get this message box:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://1.bp.blogspot.com/_mGql6Et46Z0/SMLsffwPhNI/AAAAAAAAABU/pzxpamDgmzU/s400/unsafe+addin.bmp" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" border="0" alt="" id="BLOGGER_PHOTO_ID_5243012942056621266" /&gt;&lt;/div&gt;&lt;div&gt;Now, MS asks me to disable all that security paranoia, and just be careful. See the deadlock they've created?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-9090135088272342019?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/9090135088272342019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2008/09/microsoft-always-think-we-default-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/9090135088272342019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/9090135088272342019'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2008/09/microsoft-always-think-we-default-to.html' title='Microsoft Always Think We Default To &quot;Stupid&quot;'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_mGql6Et46Z0/SMLsffwPhNI/AAAAAAAAABU/pzxpamDgmzU/s72-c/unsafe+addin.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-4888873829550881364</id><published>2008-08-07T14:12:00.000-03:00</published><updated>2008-09-06T17:50:46.006-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='VBScript'/><category scheme='http://www.blogger.com/atom/ns#' term='LOC'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>How To Count Lines Of Text (LOC) in Documents</title><content type='html'>Suppose you have a (large) number of files and you want to know how many lines of text each contains. In computer programming that number is know as Lines-Of-Code or LOC and is a measurement of code complexity. Or maybe you are a writer or editor and separates chapters of a book in different files. Or maybe you have this data sample that came in plain text files and you need to know how many entries (records) each sample has.&lt;br /&gt;&lt;br /&gt;There are, of course, many ways to do it. The most straightforward one is to simply open each file on your preferred text-editor, be it notepad, notepad++, UltraEdit or whatever and then use CTRL-END to go to the end of the text, then simply look at the current line number.&lt;br /&gt;&lt;br /&gt;This option is ok for a small set of files, say, ten or fifteen. But if you have a larger set, fifty or more, it probably will take too much time to do it. So, let's look at alternatives:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:130%;"&gt;I. Using a DOS Batch&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This option is simple and very quick to build. Experienced VBScript writers will prefer the next one since it's more flexible, but common users should default to this. They are very similar and have about the same basic result.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Basics: &lt;/span&gt;The DOS Script is a scripting format for DOS (which now is called the Windows Command Prompt). Old timers will remember dealing with .bat files in the old DOS days, usually to pass parameters during program call. But, in fact, DOS bat files could do much more even back then, and now they are a very handy tool to any windows user that doesn't want to deal with the intrinsics of VBS programming.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Restrictions: &lt;/span&gt;Can only be applied to non-formatted files.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Downsides: &lt;/span&gt;It can only count the lines. VBScript solution might apply filters, etc.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Recommended: &lt;/span&gt;If all you need is the total number of lines for each file. &lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How to:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A DOS bat is a text file with the .bat extension (for instance, &lt;span style="font-style: italic;"&gt;example.bat&lt;/span&gt;) that contains DOS native commands. The bat is purely interpreted -- it's as if each command is being typed separately by the user on the command line shell. To use it, open a text file on your favorite &lt;span style="font-weight: bold;"&gt;text&lt;/span&gt; editor (notepad, UltraEdit, notepad++, etc) and save it with the .bat extension &lt;span style="font-style: italic;"&gt;(countLOC.bat&lt;/span&gt;). It's easier saving the file on c:\ so that we can access it easily from the command prompt. The first example will only count the lines of a single text file:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;countLOC.bat (1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ol  style="font-family:courier new;"&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;@echo off&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;REM The following line sets delayed expansion, which is used to&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;REM &lt;/span&gt;&lt;span style="font-size:85%;"&gt;make sure variables have dynamic value.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;SETLOCAL ENABLEDELAYEDEXPANSION&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;REM The following FOR loop reads the file line by line&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;FOR /F "tokens=*" %%j in (data\text.txt) do (&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;    set /a numLines=!numLines!+1&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;echo data\text.txt !numLines!&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;To ran the script above, you will need to open the DOS command prompt (now simply called  &lt;span style="font-style: italic;"&gt;command prompt), &lt;/span&gt;and type the name of the script:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Open the DOS prompt (Start → Run, "cmd").&lt;br /&gt;&lt;/li&gt;&lt;li&gt;First switch to the disk partition where the files are by typing the letter of the partition followed by a colon, like "c:", then enter.&lt;/li&gt;&lt;li&gt;If your shell tells you you're on a different folder, just type "cd \", which will bring you to the root.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Run the program by typing its name on the prompt:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;c:\&gt;countLOC&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;Now, let's examine the code. The first line disables echo, which means that commands itselves won't be displayed on the screen, only their output. Remove this line if you want to debug the bat, but keep it afterwards so that display is kept clean.&lt;br /&gt;&lt;br /&gt;The lines 2 and 3 begin with REM, which is short for REMARK. Use it as a commentary mark (anything following REM is ignored). &lt;span style="font-style: italic;"&gt;SETLOCAL&lt;/span&gt; in line 5 does what the commentary section explains: on DOS bat, if you declare a variable (which is done through a SET command), the variable is &lt;span style="font-style: italic;"&gt;static&lt;/span&gt;. It means that it cannot be modified during execution of commands such as the FOR loop.&lt;br /&gt;&lt;br /&gt;Finally, it's necessary to understand the FOR command. FOR is a very handy tool that enables script writers to do repeating tasks a certain number of times. It's help is very comprehensive (type &lt;span style="font-style: italic;"&gt;c:\&gt;for /?&lt;/span&gt;) if you want a description of its uses. The most interesting format is /f, which uses files (or text, actually) as input variables. The command will scan the file, "data\text.txt", line-by-line. Usually, this would be used in composition with another command, to extract some information from the file. In our case, though, we use the code on line 9 that will increment the numLines variable when executed.&lt;br /&gt;&lt;br /&gt;The /a option in SET tells the command to interpret its input as a aritmethic expression, so line 9 adds one to numLines. If you ran the above script, you will see a output like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;C:\&gt;countLOC.bat&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;data\text.txt 9&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The next goal is to do this with all the files inside a certain folder. Take a look at the next version:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:courier new;font-size:85%;"&gt;countLOC.bat (2)&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;@echo off&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;REM The following line sets delayed expansion, which is used to make sure variables&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;REM have real dynamic value.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;SETLOCAL ENABLEDELAYEDEXPANSION&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;REM Get DIR from input&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;SET DIR=%1&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;for /f "tokens=*" %%i in ('dir /b /a-d %DIR%') do (&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;    for /f "tokens=*" %%j in (%DIR%\%%i) do (&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;        set /a &lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;numLines&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;=!&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;numLines&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;!+1&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;    )&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;    echo %%i !&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;numLines&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;!&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"&gt;)&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;I've highlighted the differences. As you can see, we've &lt;span style="font-style: italic;"&gt;nested&lt;/span&gt; the FOR loop in another FOR loop. What I'm going to do here is to repeat our previous loop for each file in a given folder. I use as an argument to FOR the command &lt;span style="font-style: italic;"&gt;dir /b %DIR%&lt;/span&gt;, which pass the output from &lt;span style="font-style: italic;"&gt;dir&lt;/span&gt; command as a text file to FOR, so each file in the folder is read. The /b switch tells DIR to run in bare mode, which just output files name, without header or trailer and the /a-d tells it to &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; display directories.&lt;br /&gt;&lt;br /&gt;Finally, I've "parametrized" the folder name. DOS bath can receive arguments from the command line through %1, %2, etc. So, the user must pass the folder name as an argument to the DOS bat the folder name, which is c:\data in our example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;C:\&gt;countLOC data&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;asd.txt 7&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;cassi.txt 10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBD_All.txt 8926&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SourceSafe.txt 8927&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The script is ready. All you have to do is copy the solution from &lt;span style="font-style: italic;"&gt;countLOC.bat (2)&lt;/span&gt; and save it with this name. In case you want to learn more about DOS scripting, point your browser to &lt;a href="http://www.robvanderwoude.com/batchfiles.html"&gt;Rob's van der Woude Scripting Page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:130%;"&gt;II. Use a VBScript&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Using a scripted language to do it is probably the best way to go, since you can customize this solution to whatever you want. This solution is based on a article by &lt;a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1012.mspx"&gt;Hey Scripting Guy&lt;/a&gt;, from MSDN. I've used it more than once, to count LOC from source files and records from data files.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The basics: &lt;/span&gt;You will need to write a very simple VBScript to do it. VBScript isn't the best scripting language out there, sure, but has a great advantage -- any Windows installation comes with it. To 'program', just open your prefferred text editor (we love text editors, don't we?) and sabe the file as something.vbs (as usual, "something" is anything you want). Then double click this file in Windows Explorer -- it will be compiled and ran.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_mGql6Et46Z0/SJt5dIh9jhI/AAAAAAAAABE/txTzx0XaAQA/s1600-h/geek.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_mGql6Et46Z0/SJt5dIh9jhI/AAAAAAAAABE/txTzx0XaAQA/s320/geek.gif" alt="" id="BLOGGER_PHOTO_ID_5231908933534060050" border="0" /&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;"Compiled?", you ask. Yes, VBScript is, oddly enough, a compiled language. &lt;/span&gt;&lt;span style="font-style: italic;"&gt;This means that your code is first fed into a compiler, generating a 'binary' of some sort (not necessarily native machine code) before it runs.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Restrictions: &lt;/span&gt;Can only be applied to non-formatted files.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Downsides: &lt;/span&gt;VBScript programming is a bit complex for newbies.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Recommend: &lt;/span&gt;&lt;span&gt;If y&lt;/span&gt;ou want to apply some filters on the file, like verifying if a line is a comment, etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How to:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So, let's write this program. First you must understand that, to access files and other Operational System functions, VBScript will use a "component" from windows. It doesn't really matter what that object is, but if you are interested, just google it. To create this object, write this on the file:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;countLOC.vbs (1):&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Set fso = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will create a object named fso (short for file system object) which we'll use to access files and stuff. Let's say now that you want to open a file named "text.txt", which resides in "c:\data".&lt;span style="font-style: italic;"&gt; &lt;/span&gt;All you have to do is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;countLOC&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.vbs (2):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Set fso = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:courier new;"&gt;Set objTextFile = fso.OpenTextFile("c:\data\text.txt", 1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will give you access to the objTextFile, which you will use to manipulate the text file itself. Looking at the arguments (the stuff enclosed in parenthesis), you will notice a '1' being passed. This tells &lt;span style="font-style: italic;"&gt;fso &lt;/span&gt;that the file is to be openend as read-only, preventing the script from messing up with your text. Now we need to count the lines from text.txt. We do that by reading until the end of the file and then checking how many lines were read:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;countLOC.vbs (3):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;Const ForReading = 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Set fso = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Set objTextFile = fso.OpenTextFile("c:\data\text.txt", &lt;span style="font-weight: bold;"&gt;ForReading&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;objTextFile.ReadAll&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Wscript.Echo(objTextFile.Line)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the code above, we made two modifications. First, the number that tells &lt;span style="font-style: italic;"&gt;fso&lt;/span&gt; that the file is for reading only was replaced by a constant, so that our code becomes more readable. Second, we read the whole file using the method &lt;span style="font-style: italic;"&gt;ReadAll &lt;/span&gt;and then printed, through the use of &lt;span style="font-style: italic;"&gt;Wscript.Echo&lt;/span&gt;, the number of the current line of the file. Since we read the whole file, the line printed will be the last one. The code above is the skeleton of what we will be using to create the report containing all the files number of line. The first difference is that we'll get a list of all the files in the folder and then we will analyzed each one of then. To do so, we will use interaction loops in our script. The second difference is that we will output the result to a file instead of pop-ups. It's easy but, if you are not really interested in learning the hows and whys, skip until the last code listing.&lt;br /&gt;&lt;br /&gt;The way to retrieve the file listing from the folder is to use the method &lt;span style="font-style: italic;"&gt;fso.GetFolder("folderPath")&lt;/span&gt;, which returns a folder object, and the use this object to retrieve the listing. We iterate through the listing by using For Each loop:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;countLOC.vbs (4)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ol&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-style: italic;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;On Error Resume Next&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;Const ForReading = 1&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic; font-weight: bold;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;Set fso = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;' Open an output file to write results. Existing files will be overwritten.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;Set reportFile = fso.CreateTextFile("c:\FileList.txt", True)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;' Get the file listing for the given folder&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;Set folder = fso.GetFolder(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;"&lt;/span&gt;c:\data&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;' iterate through the the files&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;For Each fileIdx In folder.Files&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    ' Open the file using the name from folderIdx (folder index)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    Set objTextFile = fso.OpenTextFile("c:\data\" &amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;fileIdx&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;.Name, ForReading)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    objTextFile.ReadAll&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    ' Output to the reportfile&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;reportFile&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;.WriteLine(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;fileIdx&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;.Name &amp;amp; ";" &amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;objTextFile.Line&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;Next&lt;/span&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;' Close the report file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;reportFile&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;.Close&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;As you can see, we made many modifications. Line 1 informs the script that, in case of an error during the &lt;span style="font-style: italic;"&gt;For Each &lt;/span&gt;loop, it should resume on the next item. Line 6 creates the output file and line 9 creates a &lt;span style="font-style: italic;"&gt;folder &lt;/span&gt;object that can be used to access the file listing. Line 12 begins the loop, which sets a variable fileIdx to each file in the folder. As you can see in lines 12 and 18, &lt;span style="font-style: italic;"&gt;fileIdx.Name &lt;/span&gt;returns the name of the file.&lt;br /&gt;&lt;br /&gt;This is the gist of it. The script access a folder, "c:\data", iterate through all files in this folder and outputs each file LOC to "c:\FileList.txt". But we want to make this into a real tool, right? So what's wrong? Well, the script need to be edited everytime you want to change the folder that contains the files or the name to the report. So let's parametize those:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;font-family:courier new;font-size:85%;"&gt;&lt;span style="font-style: italic;font-family:courier new;"&gt;countLOC.vbs (4)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;On Error Resume Next&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Const ForReading = 1&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' Get first parameter as the foldername&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;sFolder = WScript.Arguments.Item(0)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' Second parameter is the report name&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;sReport = WScript.Arguments.Item(1)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;If sFolder = "" Or sReport = "" Then&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    Wscript.Echo "Invalid Syntax. Expected: countLOC.vbs folderName reportName"&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    Wscript.Quit&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;End If&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' Create a file system object that will help us acessing files&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Set fso = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' Open an output file to write results. Existing files will be overwritten.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Set reportFile = fso.CreateTextFile(sReport, True)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' Get the file listing for the given folder&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Set folder = fso.GetFolder(sFolder)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' iterate through the the files&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;For Each fileIdx In folder.Files&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    ' Open the file using the name from folderIdx (folder index)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    Set objTextFile = fso.OpenTextFile(sFolder &amp;amp; "\" &amp;amp; fileIdx.Name, ForReading)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    objTextFile.ReadAll&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    ' Output to the reportfile&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    reportFile.WriteLine(fileIdx.Name &amp;amp; ";" &amp;amp; objTextFile.Line)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Next&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;' Close the report file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;reportFile.Close&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt; Lines 5 and 7 load the arguments from the command line. Lines 9 through 12 test to see if the parameters are passed correctly. To use the code above, you will have to open the command prompt (Start → Run, "cmd") and type&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;c:\&gt;countLOC folder output&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Where &lt;span style="font-style: italic;"&gt;folder&lt;/span&gt; is the path of the folder that contains the files you want to analyze and &lt;span style="font-style: italic;"&gt;output&lt;/span&gt; is the name of the report.&lt;br /&gt;&lt;br /&gt;Now, a seasoned VBScript writer can re-adapt the code above and instead of using a &lt;span style="font-style: italic;"&gt;ReadAll&lt;/span&gt;, read it line-by-line and check if the line is empty or not, if it's a comment or not, etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-4888873829550881364?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/4888873829550881364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2008/08/how-to-count-lines-of-text-loc-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4888873829550881364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/4888873829550881364'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2008/08/how-to-count-lines-of-text-loc-in.html' title='How To Count Lines Of Text (LOC) in Documents'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_mGql6Et46Z0/SJt5dIh9jhI/AAAAAAAAABE/txTzx0XaAQA/s72-c/geek.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5521512899202663630.post-1941471082612986475</id><published>2008-07-29T11:40:00.000-03:00</published><updated>2010-04-19T19:13:58.194-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='introduction'/><title type='text'>Presentation 1.0</title><content type='html'>I must say that I've been stalling beginning this web site for a few months. Keeping a real web site or a blog up-to-date is a lot of work. You HAVE to post weekly or more, or the few visitors you get won't return.&lt;br /&gt;&lt;br /&gt;Secondly, you have to work on a good layout. This means knowing a lot of HTML (which incidentally, I do), choosing the right place to host and have at your disposition a number of free hours which none of us, computer geeks, have. That is, unless we decide we can stop playing that addictive game every night -- a thing that probably won't happen.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Third, and most important of all, you have to choose subject(s) carefully. &lt;/span&gt;This is difficult. It's easy to stray from what you should be talking about (your blog presentation) and begin a discussion over what type of coffee you like or your favorite supermodel.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_mGql6Et46Z0/SI8xvnOIsbI/AAAAAAAAAA8/qxNIzT1kRzk/s1600-h/42009_drichardsbluebikini01_122_1196lo.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5228452386452320690" src="http://4.bp.blogspot.com/_mGql6Et46Z0/SI8xvnOIsbI/AAAAAAAAAA8/qxNIzT1kRzk/s320/42009_drichardsbluebikini01_122_1196lo.jpg" style="cursor: pointer; display: block; margin: 0px auto 10px; text-align: center;" /&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size: 78%;"&gt;It's no supermodel, but is my favorite&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;So, what can a Blog be about that there aren't a hundred more in the Web? That is a impossible question, mostly because if there's a subject that no one has ever thought of doing a Blog over, it must be rare. So I've decided to improve over some blogs that already exist and hope that mine is Google listed (otherwise, nobody will ever find me out).&lt;br /&gt;&lt;br /&gt;And I guess that will only happen after I have fifty posts or more, but still I'm going to try. So, to answer the question, &lt;span style="font-weight: bold;"&gt;what will this blog be about?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This blog will be a place where I'm going to post SOLUTIONS to everyday problems when using a computer.&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;Those&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;/span&gt;problems should be simple stuff that most people have to do everyday, like search for stuff on files, creating reports etc. Mainly, I'll be dealing with &lt;span style="font-weight: bold;"&gt;automation&lt;/span&gt;, by creating a number of MACROS or using scripts to solve stuff.&lt;br /&gt;&lt;br /&gt;The target audience will be the not-so-common computer user: someone who knows what a Word macro is or has heard of Linux shell scripting. However, &lt;span style="font-weight: bold;"&gt;no prior knowledge over programming, scripting or macros &lt;/span&gt;will be necessary.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;The blog won't be focused on &lt;/span&gt;tweaking or troubleshooting Windows, actual programming (even though some programming might surge as part of the solutions), or high-technology discussion (SOA, .Net or whatever). If it's not useful for a more common user, it won't be here.&lt;br /&gt;&lt;br /&gt;But don't worry if you don't find what you want in this blog. I'm deadly sure there will be thousands other web sites with whatever you seek.&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_mGql6Et46Z0/SI8w-vMpxzI/AAAAAAAAAAs/vjnGiWDk1FY/s1600-h/42009_drichardsbluebikini01_122_1196lo.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5521512899202663630-1941471082612986475?l=tekcorner.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tekcorner.blogspot.com/feeds/1941471082612986475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tekcorner.blogspot.com/2008/07/presentation-10.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1941471082612986475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5521512899202663630/posts/default/1941471082612986475'/><link rel='alternate' type='text/html' href='http://tekcorner.blogspot.com/2008/07/presentation-10.html' title='Presentation 1.0'/><author><name>Bruno Brant</name><uri>http://www.blogger.com/profile/16623201036572688380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://bp0.blogger.com/_mGql6Et46Z0/R5v58nw5ZZI/AAAAAAAAAAU/NSDIqHxbUMQ/S220/DSC05088.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_mGql6Et46Z0/SI8xvnOIsbI/AAAAAAAAAA8/qxNIzT1kRzk/s72-c/42009_drichardsbluebikini01_122_1196lo.jpg' height='72' width='72'/><thr:total>1</thr:total></entry></feed>
