<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Visual Basic Team : Sophia Salim</title><link>http://blogs.msdn.com/vbteam/archive/tags/Sophia+Salim/default.aspx</link><description>Tags: Sophia Salim</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Community Interview with Sophia Salim (Beth Massi)</title><link>http://blogs.msdn.com/vbteam/archive/2008/10/29/community-interview-with-sophia-salim-beth-massi.aspx</link><pubDate>Wed, 29 Oct 2008 19:00:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8974269</guid><dc:creator>VBTeam</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/8974269.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=8974269</wfw:commentRss><description>&lt;p&gt;This past month we've been posting &lt;a href="http://blogs.msdn.com/vbteam/archive/tags/Interview/default.aspx" target="_blank"&gt;interviews with the team&lt;/a&gt; from our Italian Visual Basic MVP &lt;a href="http://community.visual-basic.it/Alessandro/" target="_blank"&gt;Alessandro Del Sole&lt;/a&gt;. This time we have Sophia Salim, a Tester on the VB Compiler. I'm very happy to see Sophia reach out to the community and am looking forward to more &lt;a href="http://blogs.msdn.com/vbteam/archive/tags/Sophia+Salim/default.aspx" target="_blank"&gt;interesting posts from her here&lt;/a&gt;. I'm always interested in what really goes on inside that compiler.&lt;/p&gt;  &lt;p&gt;Check out the &lt;a href="http://msdn.microsoft.com/en-us/vbasic/bb735849.aspx" target="_blank"&gt;Visual Basic Team page for pictures&lt;/a&gt; and bios and visit the &lt;a href="http://msdn.microsoft.com/en-us/vbasic/default.aspx" target="_blank"&gt;home page of the Visual Basic Developer Center&lt;/a&gt; for a link to all &lt;a href="http://blogs.msdn.com/vbteam/archive/tags/Interview/default.aspx" target="_blank"&gt;these interviews&lt;/a&gt; as well.&lt;/p&gt;  &lt;p&gt;Here's the interview with Sophia:&lt;/p&gt;  &lt;p&gt;1. Nice to meet you Sophia Salim! Let&amp;#8217;s begin by asking a simple question: where are you from?&lt;/p&gt;  &lt;p&gt;Karachi, Pakistan&lt;/p&gt;  &lt;p&gt;2. We all know that you&amp;#8217;re a Visual Basic Team member, but could we know something more about your role inside the Team?&lt;/p&gt;  &lt;p&gt;I am working as an SDET for the VB compiler team&lt;/p&gt;  &lt;p&gt;3. What&amp;#8217;s your favorite Visual Basic feature regarding the language and/or the IDE?&lt;/p&gt;  &lt;p&gt;It has to be XLINQ!!&lt;/p&gt;  &lt;p&gt;4. How long have you been working for Microsoft and what was your occupation before joining the VB Team?&lt;/p&gt;  &lt;p&gt;2 years (almost) &amp;#8230; It has been software engineering ever since I finished school&lt;/p&gt;  &lt;p&gt;5. Why do you think VB is such a great language?&lt;/p&gt;  &lt;p&gt;Because you can literally use it out of the box. It is so easy to learn, and you can do amazing things even with the most basic knowledge. &lt;/p&gt;  &lt;p&gt;6. Have you ever been to Italy?&lt;/p&gt;  &lt;p&gt;Nope, but I would love to go &lt;/p&gt;  &lt;p&gt;7. Would you like to tell us something about your life outside the office (how do you like to spend your free time, what do you like to do when/if you go out in the evening or when you&amp;#8217;re at home and so on)?&lt;/p&gt;  &lt;p&gt;It mostly revolves around friends, but nothing beats reading a good book over a hot cup of coffee&lt;/p&gt;  &lt;p&gt;8. Who is your favorite musician?&lt;/p&gt;  &lt;p&gt;These days it is Coldplay &lt;/p&gt;  &lt;p&gt;9. What&amp;#8217;s your favorite food?&lt;/p&gt;  &lt;p&gt;Chocolate, esp. the darker kind&lt;/p&gt;  &lt;p&gt;Thank you very much for taking time to answer these questions and letting us know something more about you!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8974269" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Beth+Massi/default.aspx">Beth Massi</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Sophia+Salim/default.aspx">Sophia Salim</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Interview/default.aspx">Interview</category></item><item><title>Orcas introduces the IF operator - a new and improved IIF (Sophia Salim)</title><link>http://blogs.msdn.com/vbteam/archive/2008/03/11/if-operator-a-new-and-improved-iif-sophia-salim.aspx</link><pubDate>Wed, 12 Mar 2008 08:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8166127</guid><dc:creator>VBTeam</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/8166127.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=8166127</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;One of my all time favorite features in C# and CPP has been the conditional operator (?:). The brevity and elegance introduced by this operator in the code is unparalleled. We had &lt;strong&gt;IIF&lt;/strong&gt; in all the previous versions of VB.net, which was not an operator in the true sense (It was a call to a function). But now with Visual Studio 2008, we have taken an &amp;quot;i&amp;quot; from this function and promoted it to operator status. &lt;strong&gt;&amp;quot;IF&amp;quot; &lt;/strong&gt;can now be used instead of &lt;strong&gt;&amp;quot;IIF&amp;quot;&lt;/strong&gt;. It provides full functionality of the IIF function with some very interesting additions of its own, including short-circuiting. It even comes in two flavors: the &lt;strong&gt;ternary flavor&lt;/strong&gt; which mimics the functionality of the IIF function while adding some more to it, and the &lt;strong&gt;binary flavor&lt;/strong&gt; which introduces a new sort of comparison/assignment. Before I start getting too vague, I will just delve into the details of how to use the greatness called the &lt;strong&gt;IF operator&lt;/strong&gt;!&lt;/p&gt;  &lt;p&gt;Note: I will touch only the ternary flavor in this blog, and will follow up with the binary if operator and other interesting examples for if in blogs to come.&lt;/p&gt;  &lt;p&gt;The first and most basic use of IF is the universal &amp;quot;compare, choose and assign&amp;quot; which is the functionality of conditional operators, and the iif function. The following are the definitions of the three operands of IF(TestExpression, TruePart, FalsePart):&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;&lt;strong&gt;TestExpression, &lt;/strong&gt;is any expression that produces a boolean value or a value convertible to boolean. With option strict on the expression needs to produce a value that is either boolean or has a widening conversion to boolean.&lt;/li&gt;      &lt;li&gt;&lt;strong&gt;TruePart, &lt;/strong&gt;is the return value of the IF operator if the test expression above evaluates to true. Note that the return &lt;strong&gt;type&lt;/strong&gt; of the operator is decided based on the wider of the types of the truepart and the falsepart, e.g, if the truepart is an integer and the falsepart is a decimal, then decimal which is the wider of the two types will be the return value's type. For details on type conversions and for a list of wider and narrower types, please &lt;a href="http://msdn2.microsoft.com/en-us/library/k1e94s7e(VS.80).aspx"&gt;refer here&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;strong&gt;FalsePart,&lt;/strong&gt;&amp;#160; is the return value of the IF operator if the test expression evaluates to false. Here in lies the short-circuiting. If the test expression evaluates to true, the FalsePart is just &lt;strong&gt;ignored. &lt;/strong&gt;The compiler will not touch it. It will not evaluate it. So as long as your test expression is true, you can do null references here, call functions on objects that do not actually exist, or anything that the parser will let you get away with. It will just not be evaluated. (Please do not think that I am recommending you to do any of the afore-mentioned evils, but as long as your test expression remains true you can get away with this). This can be very useful while calling a function on a variable which may not be instantiated, You can simply do:&lt;/li&gt;      &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Dim return &lt;/span&gt;= &lt;span style="color: blue"&gt;If&lt;/span&gt;(var &lt;span style="color: blue"&gt;Is Nothing&lt;/span&gt;, foo1(), var.foo())&lt;/pre&gt;
    &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/ol&gt;
&lt;/ol&gt;

&lt;p&gt;Now lets look at some code that shows the ternary flavor of the IF operator&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Module &lt;/span&gt;Module1
    &lt;span style="color: blue"&gt;Public Class &lt;/span&gt;Number
        &lt;span style="color: blue"&gt;Private &lt;/span&gt;_RealPart &lt;span style="color: blue"&gt;As Double
        Public Property &lt;/span&gt;RealPart() &lt;span style="color: blue"&gt;As Double
            Get
                Return &lt;/span&gt;_RealPart
            &lt;span style="color: blue"&gt;End Get
            Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As Double&lt;/span&gt;)
                _RealPart = value
            &lt;span style="color: blue"&gt;End Set
        End Property


        Private &lt;/span&gt;_ComplexPart &lt;span style="color: blue"&gt;As Double
        Public Property &lt;/span&gt;ComplexPart() &lt;span style="color: blue"&gt;As Double
            Get
                Return &lt;/span&gt;_ComplexPart
            &lt;span style="color: blue"&gt;End Get
            Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As Double&lt;/span&gt;)
                _ComplexPart = value
            &lt;span style="color: blue"&gt;End Set
        End Property


        Public Sub New&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;pRealPart &lt;span style="color: blue"&gt;As Double&lt;/span&gt;, &lt;span style="color: blue"&gt;Optional ByVal &lt;/span&gt;pComplexPart &lt;span style="color: blue"&gt;As Double &lt;/span&gt;= 0.0)
            _RealPart = pRealPart
            _ComplexPart = pComplexPart
        &lt;span style="color: blue"&gt;End Sub

        Public Overrides Function &lt;/span&gt;ToString() &lt;span style="color: blue"&gt;As String
            Return If&lt;/span&gt;(_ComplexPart = 0.0, _RealPart.ToString(), _
                      _RealPart.ToString &amp;amp; &lt;span style="color: #a31515"&gt;&amp;quot; + &amp;quot; &lt;/span&gt;&amp;amp; _ComplexPart.ToString() &amp;amp; &lt;span style="color: #a31515"&gt;&amp;quot;i&amp;quot;&lt;/span&gt;)
        &lt;span style="color: blue"&gt;End Function
    End Class

    Sub &lt;/span&gt;Main()
        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;i &lt;span style="color: blue"&gt;As New &lt;/span&gt;Number(1)
        &lt;span style="color: green"&gt;'The If operator looks checks the number to see if it is real or complex, and prints accordingly
        &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;NumberPrinter = &lt;span style="color: blue"&gt;Function&lt;/span&gt;(arg &lt;span style="color: blue"&gt;As &lt;/span&gt;Number) arg.RealPart.ToString &amp;amp; &lt;span style="color: #a31515"&gt;&amp;quot; + &amp;quot; &lt;/span&gt;&amp;amp; arg.ComplexPart.ToString() &amp;amp; &lt;span style="color: #a31515"&gt;&amp;quot;i&amp;quot;
        &lt;/span&gt;Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;i is a real number:&amp;quot;&lt;/span&gt;)
        Console.WriteLine(&lt;span style="color: blue"&gt;If&lt;/span&gt;(i.ComplexPart = 0.0, i.RealPart.ToString(), NumberPrinter(i)))

        &lt;span style="color: green"&gt;'Or the If operator can be moved inside the lambda to add to the elegance
        &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;j &lt;span style="color: blue"&gt;As New &lt;/span&gt;Number(1, 2)
        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;NumberPrinter2 = &lt;span style="color: blue"&gt;Function&lt;/span&gt;(arg &lt;span style="color: blue"&gt;As &lt;/span&gt;Number) &lt;span style="color: blue"&gt;If&lt;/span&gt;(arg.ComplexPart = 0.0, arg.RealPart.ToString(), _
                                                        arg.RealPart.ToString &amp;amp; &lt;span style="color: #a31515"&gt;&amp;quot; + &amp;quot; &lt;/span&gt;&amp;amp; arg.ComplexPart.ToString() &amp;amp; &lt;span style="color: #a31515"&gt;&amp;quot;i&amp;quot;&lt;/span&gt;)
        Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;j is a complex number:&amp;quot;&lt;/span&gt;)
        Console.WriteLine(NumberPrinter2(j))

        &lt;span style="color: green"&gt;'You can also use the short-circuiting feature of the if operator
        &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;k &lt;span style="color: blue"&gt;As &lt;/span&gt;Number
        Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;k does not have any value, so we print j again:&amp;quot;&lt;/span&gt;)
        Console.WriteLine(&lt;span style="color: blue"&gt;If&lt;/span&gt;(k &lt;span style="color: blue"&gt;Is Nothing&lt;/span&gt;, j.ToString, k.ToString))
        k = &lt;span style="color: blue"&gt;New &lt;/span&gt;Number(3, 4)
        Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;And now for k with a value:&amp;quot;&lt;/span&gt;)
        Console.WriteLine(&lt;span style="color: blue"&gt;If&lt;/span&gt;(k &lt;span style="color: blue"&gt;Is Nothing&lt;/span&gt;, j.ToString, k.ToString))

    &lt;span style="color: blue"&gt;End Sub

End Module
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Notice how short-circuiting is used in the above code when k does not have a value (the first call). The call to a method from a null object is never evaluated.&lt;/p&gt;

&lt;p&gt;For those addicted IIF users wondering if they can still use the legacy IIF function in Orcas, the answer is &lt;strong&gt;yes. &lt;/strong&gt;We still support IIF, but with all the amazing things that you can do with the &lt;strong&gt;IF operator, &lt;/strong&gt;why would you want to keep on typing those extra &amp;quot;i&amp;quot;s? And while you explore the many, many things that you can do with IF, I will be writing and posting more IF code and then some more! Until then,&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;blog_next = &lt;span style="color: blue"&gt;If&lt;/span&gt;(bIFoundMoreInterestingScenarios, blogDelvingIntoIF, blogUnknown)&lt;/pre&gt;

&lt;p&gt;If you know what I mean :)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8166127" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Sophia+Salim/default.aspx">Sophia Salim</category></item></channel></rss>