tag:blogger.com,1999:blog-11118537851505092872019-03-16T01:32:24.731-07:00The Technology NestAbdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-1111853785150509287.post-24918336564912432442012-08-02T04:43:00.000-07:002013-05-09T11:25:40.776-07:00Post/Email-3: Events in .NET<div dir="ltr" style="text-align: left;" trbidi="on">Today, a friend of mine asked a question on facebook:<br /><blockquote>Any body knows why wouldn't the selectionChanged event be fired? <br />I'm trying to change the text of a textBlock once I scroll to the next item in a pivot page</blockquote>When I came into the scene, so to speak, another person had supplied the fix for the issue like so:<br /><blockquote>hmm in xaml u have to call your function SelectionChanged="thisPivot_SelectionChanged" and your textblock gets changed... <br /><pre class="brush: csharp">&lt;controls:Pivot<br /> Title="MY APPLICATION"<br /> SelectionChanged="thisPivot_SelectionChanged"<br /> Name="pivot"&gt;</pre></blockquote><br />Then I started talking to my friend, and here’s how our conversation went:<br /><a name='more'></a><br /><blockquote><strong>Me:</strong><br />So, you fixed the issue!<br /><br /><strong>Friend:</strong><br />I had to call the event in the xaml code too.<br />I didn't know about that<br /><br /><strong>Me:</strong><br />"call the event in xaml"?<br />what do you mean by that?<br /><br /><strong>Friend:</strong><br />hmmm, yes<br />this line was missing: SelectionChanged="thisPivot_SelectionChanged"<br /><br /><strong>Me:</strong><br />you can't "call an event from xaml"!<br />here you "wire up" the event "SelectionChanged" to the event handler "thisPivot_SelectionChanged" <br />and you can do this from code or from xaml<br /><br /><strong>Friend:</strong><br />"wire up"<br />that's new for me!<br /><br /><strong>Me:</strong><br />what did you do before this?<br /><br /><strong>Friend:</strong><br />nothing<br />just defined the handler<br /><br /><strong>Me:</strong><br />ah, ok. and you just expected it to magically know when to fire (or rather when to be called)<br /><br /><strong>Friend:</strong><br />yes yes :P<br /><br /><strong>Me:</strong><br />would you like me to give you a little explanation about events in .NET?<br /><br /><strong>Friend:</strong><br />yeah, of course!<br /><br /><strong>Me:</strong><br />ok, so could you first tell me what do YOU know about events in .NET?<br /><br /><strong>Friend:</strong><br />I know the concept <br />events are fired along the application <br />handlers must be defined to handle a specific event we need to handle to achieve some task in our app<br /><br /><strong>Me:</strong><br />ok, that's good</blockquote><br />Now, here’s my simple overview on events in .NET:<br /><br />Events, as their name suggests, are a mechanism in .NET that allows for an object to inform (notify) of something that happened to it (or in it) to a subscribing party (some other object that "declares an interest" in such a "thing"). An example of this is a "Pivot" object that has a "SelectionChanged" event, which means that it can notify subscribing objects when the selected pivot item changes.<br />this is allowed in a "loosely coupled" manner, meaning that although the subscriber has to know on which object it is subscribing, but the object that defines and fires the event doesn't have to know who is "listening" to the event<br /><br />Moreover, the subscriber doesn't have to "wait" for the event. It just declares that it is interested in it, by providing an "event handler" (and in this case we say that it is "listening" to the event). When an event gets fired, all listening objects are notified, and their "event handlers" are called.<br /><br />Each event has a corresponding "signature" that its handlers have to follow. A SelectionChanged event can be declared like so:<br /><pre class="brush: csharp">public event EventHandler&lt;SelectionChangedEventArgs&gt; SelectionChanged;</pre>which means that any handler for this event has to have the following signature: <br /><pre class="brush: csharp">void Event_Handler_Name(object sender, SelectionChangedEventArgs args)</pre>So, we have a couple of parameters:<br />a “sender” object, which would be the object that fired the event; <br />and an “event argument”, which is an object that generally derives from "EventArgs”, and is used to send relevant information about the event to the subscribing objects.<br />the syntax to subscribe to an event is like so:<br /><pre class="brush: csharp">object.Event+=EventHandler;</pre>(e.g. pivot.SelectionChanged+=thisPivot_SelectionChanged;)<br />it's what happens when you say Event="EventHandler" in xaml<br />At this point, my friend asked:<br /><blockquote>where to write it in the code? <br />in the constructor? <br /><br /><strong>Me:</strong><br />yeah, you can put it in the constructor if you want to make it available since the creation of the object, but you can do it inside any method you want<br /><br />let's say that you don't want to start subscribing to the event only if the user clicks a certain button. in that case, you put it inside the event handler of the button click event (subscribing to an event, in the event handler of another event. not confusing at all&nbsp; )</blockquote>now, to "fire" an event, the object that defines it does something like this:<br /><pre class="brush: csharp">handler=SelectionChanged;<br />if(handler!=null)<br />&nbsp;&nbsp; handler(this, new SelectionChangedEventArgs{SelectedItem=selected});</pre>so you notice a couple of things here.<br />first, the event is "copied" to a variable. This is done so that you don't get weird behavior if some object subscribes to the event while it's being fired. don't worry too much about this part<br />second, this copy (called handler in my code), is checked to see if there are any objects listening to the event (in which case the variable would be different than null)<br />then, the event is "fired", by calling handler and passing to it the "sender" of the event (in our case we put "this" meaning that it's the current object, which is logical), and the “event args” parameter which contains information about the event (in the case of a SelectionChanged for example, it can be the "Selected Item")<br /><br />so, to recapitulate, an object defines an event (and gives it a corresponding event handler signature), interested objects listen to that event by declaring an event handler with the specified signature, which gets called when the event is fired<br />simple as that </div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com26tag:blogger.com,1999:blog-1111853785150509287.post-52837818349793754722012-06-09T04:56:00.000-07:002012-06-11T03:14:36.961-07:00Post/Email-2: Views, ViewModels and Composition<div dir="ltr" style="text-align: left;" trbidi="on"><br />Recently a friend of mine asked me the following question on Facebook:<br /><br /><blockquote>brother, hope i am not disturbing you. had a question. if i have mutliple tab items in one page in y silverlight app, while each tab serves different functionalities, would it be all right if i write separate view models for all of the tab items, and i expose this view models as properties from one view model and bind the page's datacontext to that main viewmodel?</blockquote><br /><a name='more'></a><br />and my answer was:<br /><br /><blockquote>I think this is a good strategy. It's actually what I think to be the best practice, because you're enforcing separation of concerns by putting the different functionalities in different classes :)<br /><br />You can go even further and simplify your view, by having each tab implemented as a UserControl, and just instantiating them in xaml and assigning the appropriate ViewModel to their DataContext ;)</blockquote><br />The first part of the answer is straightforward. The second part, however, brought another question from my friend:<br /><br /><blockquote>thanks for your answer. My conception regarding user control is not very clear. Lets say my user control has two text boxes and one button. its ready and available in toollbox for use.now when i drag and and drop it one view i cant just access those elements inside it anymore, then how can I bind any property from my view model to any of the element(e.g.text box) of that control. What my question is that, as you suggested and what I know is that user control makes reusable elements. But the fact is for example we have a textbox,that's a control too. But when we use it we have access to it's text and other properties. And suppose in our custom user control we had some sort of properties too(which is may be a content of a textbox inside it) that I need to bind, I just don't get the way of doing it.<br /><br />to be more specific lets say i have a string property in my viewmodel, i have a textbox in my user control. the datacontext of the usercontrol is set to the viewmodel. now i want to bind the text property of the text box to the string property in the viewmodel. how can i do that?</blockquote><br />and following is my (kind of long) answer:<br /><br />let's say your page's view model is "MainViewModel", and you have "TabOneViewModel" and "TabTwoViewModel", and let's say that TabOneViewModel contains a property called "Message" that you want to bind to a TextBlock. Now, if you want to use my approach with a separate UserControl for each tab, you would have something like TabOneView, which has a TextBlock bound to the Message property as follows:<br /><br /><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">Text</span><span class="kwrd">="{Binding Message}"</span><span class="kwrd">/&gt;</span></pre><br />and in your MainView (which has MainViewModel as its DataContext), you would have something like:<br /><br /><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">MyControls:TabOneView</span> <span class="attr">DataContext</span><span class="kwrd">="{Binding TabOneViewModel}"</span><span class="kwrd">/&gt;</span></pre><div class="csharpcode"><br /></div>This is enough to wire up your binding, and here's why:<br />when you set the DataContext on some element, you have direct access to its properties inside of that element (like when you set the MainViewModel as the DataContext for the page and have its properties available inside the whole page).<br />So, when you set the DataContext for the TabOneView to be the TabOneViewModel, you'll have access to all its properties (including the Message property).<br /><br />Long story short: you'll only need to set one binding on the MainView, which is the binding for the DataContext.<br /><br /><a href="http://lh4.ggpht.com/-Fhy-3fySaCI/T9MzuVGvbYI/AAAAAAAACdI/Bh8SPsJY1l4/s1600-h/New_document_1-rect3759-1-782%25255B30%25255D.png"><img alt="New_document_1-rect3759-1-782" border="0" height="220" src="http://lh6.ggpht.com/-7D-vcVTswzE/T9MzvqSEA3I/AAAAAAAACdQ/GMIdLSKiOXs/New_document_1-rect3759-1-782_thumb%25255B28%25255D.png?imgmax=800" style="background-image: none; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="New_document_1-rect3759-1-782" width="400" /></a><br /><br />If by any chance you needed more customization, or say, if you want to reuse the TabOneView in a different context, and have to add a certain property to it which you set differently in the different usage scenarios, then you can define custom DependencyProperties on the TabOneView and bind to those.<br /><br />If the functionalities in the different tabs are really separate, meaning that each ViewModel is self-contained, and you don't have some code-behind that needs to access elements from different tabs, then you should have no problem applying this approach.<br /><br />Hope this helps.</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com1tag:blogger.com,1999:blog-1111853785150509287.post-88122558740949251392012-06-07T15:50:00.000-07:002012-06-09T06:36:55.524-07:00Post/Email–1: MVVM Light messaging, order of register and send is important<div dir="ltr" style="text-align: left;" trbidi="on">&nbsp; <br />Recently a friend of mine asked me the following question on Facebook. I started writing a few sentences, which turned into a few paragraphs and before I knew it I was writing a very long reply. Then, something Scott Hanselman <a href="https://twitter.com/shanselman/status/208607212594147328" target="_blank">said on twitter</a> came to mind:<br /><blockquote>"Every email you send is a blog post you didn't write. Stop writing emails.”</blockquote>Because of this, I intend to write these “Post/Email” (or “Post over Email”) blog posts whenever someone asks me a question, so that other people would benefit from them :)<br />Here we go, with this question from my friend Saad Galib on facebook:<br /><blockquote>...is it at all possible to pass data between ViewModels using MVVM light messaging without ViewModelLocator? Because in a blog i read that that some class needs to register for a message before it is sent to receive it. Right now i have no locator. i send a message from ViewModel-1 bound to page 1 and then navigate to page 2 which in turn creates viewmodel 2 and in that viewmodel's constructor i register for that kind of messages(broadcasted from viewmodel1)....but its not working....:(<br />and this i definitely not satisfying the condition i read as i mentioned above. is there any work around?</blockquote>The short answer is: no. The "no" here isn't because of the ViewModelLocator itself, but rather because of what you mentioned later about the order in which the subscription and broadcast are done. <br />The Messenger implementation in MVVM Light is simple and straightforward. When you register an object to some event, it adds it to a dictionary; and when that particular event is sent, it goes through the corresponding objects in the dictionary and notifies them (by calling the corresponding registered action). Therefore, when an object subscribes to a certain event, it only gets notified of those instances of the event which occur <strong>after </strong>it has subscribed. Which is the logical thing to do.<br />I'm not aware of anything in MVVM Light that would help with your particular situation, but there are other, maybe not so elegant, methods to transmit data between objects in a loosely coupled way. One of them, which I used myself but I'm not sure whether it's a good practice or not, is to have some sort of "buffer" where an object can put some data for other objects to take out at some point in time (in my particular scenario, I used a class "Pipe" with a static member "Data" that I set in one VM and consume in the other).<br />Hope this helps</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com2tag:blogger.com,1999:blog-1111853785150509287.post-67441770788589589192012-02-21T08:53:00.002-08:002012-02-21T09:18:36.261-08:00What are Generics in .NET?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;"><a href="http://3.bp.blogspot.com/-FZiRk6cLv6o/T0PMwerDpFI/AAAAAAAACKo/vP1EsDCL5a4/s1600/.NET+Generics.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="http://3.bp.blogspot.com/-FZiRk6cLv6o/T0PMwerDpFI/AAAAAAAACKo/vP1EsDCL5a4/s1600/.NET+Generics.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="60" src="http://3.bp.blogspot.com/-FZiRk6cLv6o/T0PMwerDpFI/AAAAAAAACKo/vP1EsDCL5a4/s320/.NET+Generics.png" width="320" /></a><span style="font-family: inherit;">A little while ago, a friend of mine on Facebook asked me to explain to him what generics in .NET were. As I thought this might interest more than one friend, which it did, I decided to put it in a "note" on Facebook. That was before I started this blog, so now I decided to post it here, hopefully so that more people would find it useful.</span></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><span style="font-family: inherit;">Generics</span> in the .NET Framework is a programming technique that allows you to create a "generic" (meaning that it's not tied to a specific type) class, structure or method. The type, which is in this&nbsp;case "an argument",&nbsp;is specified when that element is used. What's interesting, and this is another advantage of Generics in .NET, is that you can restrict that type by specifying, for example, that it has to implement a&nbsp;certain interface or have a parameterless constructor.<br /><br /></div><div style="text-align: justify;">This concept allows for more type safety (the type is known when the generic element is being used), while promoting reuse (you create an element that's not tied to a specific type).</div><a name='more'></a><br />An example of Generics, which is very popular, are Generic Collections, that came with the introduction of Generics in .NET 2.0. In the earlier version of .NET (1.x), there were non-generic collections, meaning that those collections would hold "Object" types, allowing the following: <br /><div style="font-family: consolas; font-size: 11pt; margin: 0in;"><br /><span style="color: #2b91af;">ArrayList</span>&nbsp;collection&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: #2b91af;">ArrayList</span>();</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">collection.Add(<span style="color: #a31515;">"string"</span>);</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">collection.Add(1);</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">collection.Add(<span style="color: blue;">new</span>&nbsp;<span style="color: blue;">float</span>[10]);</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><br/>This may seem to have the advantage to be "flexible" but it has many disadvantages, like having to cast the types back when retrieving them: <br /><div style="font-family: Calibri; margin: 0in;"><br /><span style="font-family: inherit;"><span style="color: #2b91af;">int</span>&nbsp;i= (<span style="color: #2b91af;">int</span>) collection[1];</span></div><span style="font-family: inherit;"> </span><br /><br />And you have to know which element contains which type, and that can prove to be hard. Also, cases when you would need such a collection that can hold any "Object" aren't that common. <span style="font-family: inherit;"> </span><br />And here come the "Generics" to the rescue. You can use, for example,&nbsp;the <span style="color: #2b91af;">List</span>&lt;T&gt; to hold objects of type "T". <span style="font-family: inherit;">e.g:</span><br /><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: consolas; font-size: 11pt; margin: 0in;"><br /><span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">string</span>&gt;&nbsp;stringList&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">string</span>&gt;();</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">stringList.Add(<span style="color: #a31515;">"Hello"</span>);</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">stringList.Add(<span style="color: #a31515;">"World!"</span>);</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">stringList.Add(2);&nbsp;<span style="color: green;">//&nbsp;this&nbsp;causes&nbsp;a&nbsp;compile-time&nbsp;error</span></div><div style="font-family: consolas; font-size: 11pt; margin: 0in;"><span style="color: blue;">string</span>&nbsp;world&nbsp;=&nbsp;stringList[1];&nbsp;<span style="color: green;">//&nbsp;no&nbsp;need&nbsp;for&nbsp;the&nbsp;cast&nbsp;since&nbsp;the&nbsp;type&nbsp;is&nbsp;known</span></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><br/>Another example of generics, other than in collections, would be something like: </div><div style="font-family: consolas; font-size: 11pt; margin: 0in;"><br /><span style="color: blue;">int</span>&nbsp;Compare&lt;T&gt;(T&nbsp;first,&nbsp;T&nbsp;second)&nbsp;<span style="color: blue;">where</span>&nbsp;T:<span style="color: #2b91af;">IComparable</span>&lt;T&gt;</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">{</div><div style="font-family: consolas; font-size: 11pt; margin: 0in 0in 0in 0.375in;"><span style="color: blue;">return</span>&nbsp;first.CompareTo(second);</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">}</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><br />Now, this Compare method can compare any two objects (of the same type) which implement the IComparable interface (that defines the CompareTo method), which in turn makes for another good example of generics <br /><br /><div style="font-family: Calibri; margin: 0in;"></div><div style="font-family: Calibri; margin: 0in;"></div><div style="font-family: consolas; font-size: 11pt; margin: 0in;"><span style="color: blue;">public</span>&nbsp;<span style="color: blue;">interface</span>&nbsp;<span style="color: #2b91af;">IComparable</span>&lt;T&gt;</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">{</div><div style="font-family: consolas; font-size: 11pt; margin: 0in 0in 0in 0.375in;"><span style="color: blue;">int</span>&nbsp;CompareTo(T&nbsp;other);</div><div style="font-family: consolas; font-size: 11pt; margin: 0in;">}</div><br /><div style="text-align: justify;">Now, if you've not used generics before, maybe thinking they were hard, I hope you got a glimpse at how powerful this feature is and how useful it can be; and more importantly, how "not so hard after all" it is. So, what are you still doing here?! go make yourself some generics ;)</div></div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com43tag:blogger.com,1999:blog-1111853785150509287.post-78561861197461222712012-02-19T05:01:00.000-08:002012-02-19T05:03:20.041-08:00Is Silverlight Dead?<div dir="ltr" style="text-align: left;" trbidi="on"><br />"To <strong>Silverlight</strong> or Not to <strong>Silverlight</strong>!" That my dear reader is a question I've grown accustomed to hear! Here's part of a little chat I had with a friend on Messenger a couple of days ago: <br />&nbsp; <br />"Friend" says: <br /><blockquote>yes that's exactly what i meant !<br />btw , <strong>is Silverlight dying</strong>?</blockquote>"Me" says: <br /><blockquote>nah, it's having a headache that’s all<br />(from all the people who are saying it's dying )</blockquote>"Friend" says: <br /><blockquote>haha, i see&nbsp; <br /><a name='more'></a></blockquote>I've had this conversation over and over and over again for the past few months. Now, I love to be "<strong>DRY</strong>" (i.e: Don't Repeat Yourself. Which, as Scott Hanselman always says, is ironic since you have to "repeat yourself" and explain what DRY itself means every time you use it :P). Anyways, as I’ve replied to this question so many times, I thought I’d refactor my opinion on this subject into a post and reference it whenever I need to. That’s what we developers do after all ;) <br />&nbsp; <br />For the previous conversation, here’s what I replied with: <br />"Me" says: <br /><blockquote>People who don't understand what Silverlight is really about are the ones who think it's dead. Because those who do know what it is all about, understand that what's important isn't "<strong>Silverlight</strong> as a browser plugin" per se, but it's <strong>XAML</strong>, it's <strong>DataBinding</strong>, it's <strong>MVVM</strong>, and it's the new way of doing user interfaces on the Microsoft stack. You have <strong>WPF</strong>, <strong>Silverlight</strong> for the browser (which, I admit, we don't know if Microsoft is going to keep developing any further, but we do know it will at least be supported for a while), we have Silverlight for <strong>WP7</strong>, and last but not least <strong>XAML</strong> metro style apps for <strong>Windows 8</strong> (now even with <strong>C++</strong>).</blockquote>If you’re a “<strong><a href="http://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn't_read">TL;DR</a></strong>” person, this should be enough for you. If, however, you want to read more of my ramblings on the subject, then, by all means, go ahead reading :)<br /><br />Now let me expand on that a little bit. But first of all, let’s define “<strong>Silverlight</strong>”, to be on the same picture. Silverlight, at least the way I see it, is a small version of the .NET framework, as a <strong>plugin</strong>, that can run in the browser, or <strong>Out-Of-Browser</strong>. It sprang from <strong>WPF</strong>, where at some point it was called “<strong>WPF/E</strong>” (or WPF Everywhere), starting as a subset then being developed independently. However, features were going back and forth between <strong>WPF</strong> and <strong>Silverlight</strong>. The main thing it took from <strong>WPF</strong> was <strong>XAML</strong>, and the new way of making user interfaces in the desktop using declarative markup. It has the same main features, including DataBinding, templating, styling, resources, and so on. It is simply what’s called a “xaml platform”.<br /><br />With this “definition”, you can see that “plugin”, and “browser”, only appear once or twice. Keep that in mind for later ;)<br />Personally, I was in favor of saying that “nah, Silverlight is not dead!”, and I have my reasons for that, and here are a couple of them: <br /><br />First of all, <strong>nobody from Microsoft said it’s dead</strong>; though I admit, no one from the company said it ain’t either!. Now, If you pay close attention, you’ll notice that most of the “Silverlight Is Dead” posts are from the online Tech news websites, who mostly only see what’s trending and panic when a technology isn’t mentioned in a Microsoft event :P The rest of the posts are for people saying pretty much the same things as I am ;)<br /><br />Second, and most importantly, is the<strong> huge investment in Silverlight</strong> made both by <strong>Microsoft</strong>, where you see it taken to the Windows Phone, and used a lot with <strong>Azure</strong> (even the Azure admin website is in Silverlight!), <strong>other companies</strong> especially those in online media, who have developed their own immersive experiences using <strong>Silverlight</strong>.<br /><br />Remember I said “<strong>was in favor</strong>”, which suggests that I changed my mind. Which I indeed have. Now, “<strong>I just don’t care</strong>”. I don’t care if Silverlight dies (even though, deep down, I still believe it’s not ;) ), because I came to understand that <strong>it’s not about Silverlight “the browser plugin”, but it’s about the platform capabilities, it’s simply about XAML.</strong> <br /><br />This is not a post about <strong>how AWESOME XAML is </strong>(maybe there would be a dedicated post for that, who knows ;) ), but those who used one of the xaml platforms and tried to move to another xaml platform, know that <strong>their skills translate seamlessly</strong>. You just have to learn the differences in the APIs, and the platform capabilities, and <strong>you’re set on your way to success</strong>.<br /><br />An example of this is when <strong>Windows Phone </strong>first came out. The tagline for that time was: <strong>“If you’re a Silverlight developer, you’re automatically a WP developer”</strong>. Another example, that we’re seeing these very days, is with Windows 8 Metro Style Applications using XAML, where even C++ devs can now jump in and enjoy a better presentation framework.<br /><br />So, “<strong>Is Silverlight Dead?</strong>”, hmm, maybe, and maybe not. The point is: “<strong>It Doesn’t Matter!</strong>”. If you’re a Silverlight Developer, you’re “<strong>by definition</strong>” a “<strong>xaml developer</strong>”, which means you’re <strong>WPF</strong>, <strong>WP7 </strong>and <strong>Windows 8 Metro Style developer </strong>;) Now ain’t that <strong>AWESOME </strong>:D</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com11tag:blogger.com,1999:blog-1111853785150509287.post-49682298440638005552011-12-22T23:42:00.001-08:002011-12-27T11:47:13.542-08:00Microsoft gives YOU an opportunity you shouldn’t miss!<div dir="ltr" style="text-align: left;" trbidi="on">I have great news! It seems my <a href="http://www.abdoumoumen.net/p/land-job-at-microsoft-series.html">series</a> is going to be put to work at last! It’s rather fortunate that I got it done just in time for this AWESOME opportunity ;)<br /><br />Are you a student from the MEA region who’s graduating this year (well, even if you’ve recently graduated, I think you should go for it. Worked for me ;) )? Are you ready to have the exact same opportunity I had? DO YOU WANT TO WORK FOR MICROSOFT?! Of course YOU DO ;)<br /><br />Anyways, enough with me rambling, and let’s cut to the chase. Here’s the announcement:<br /><br /><h2> What fuels your passion?</h2>Deciding where to start your career can be as nerve-wracking as it is exciting. Maybe you don’t know exactly what you want to do. Maybe you don’t even have a technology background. Fortunately, Microsoft will help you to build a career that evolves along with your interests and passions. <br /><h2> Jump right in to the deep end</h2>That’s a phrase we hear a lot from people during their first week at Microsoft. And with good reason. From day one, you’ll plunge headfirst into engaging, meaningful projects. Your team members and managers will help you get up-to-speed in no time. It’s a thrilling way to start your career—and it’s only the beginning. Now take the first step. <br /><div align="center"><span style="font-size: small;">Visit our website at </span><a href="http://www.microsoft.com/university"><span style="font-size: small;">www.microsoft.com/university</span></a> </div><div align="center"><span style="font-size: small;">to learn more about our</span> </div><div align="center"><span style="font-size: small;">Full-Time &amp; Internship <b>Software Development</b> and <b>Software Development in Test</b> Positions</span> </div><div align="center"><span style="font-size: small;"><b><u><span style="color: red;">Apply by </span><span style="color: red;">January 15</span> </u></b><u>to be considered for our</u></span> </div><div align="center"><b><u><span style="font-size: small;">Dubai Interview Event</span></u></b> </div><div align="center"><b><u><span style="font-size: small;">March 5-8, 2012</span></u></b> </div><div align="center"><strong><u><span style="font-size: small;"></span></u></strong>&nbsp; </div><h2> Important information:</h2><ul style="text-align: left;"><li>Information on applying, Microsoft Benefits, including complete relocation, US work visa sponsorship and other perks are available at <a href="http://www.microsoft.com/university">www.microsoft.com/university</a> </li><li>University recruiters at Microsoft review resumes with the following topical areas in mind: </li><ol><li>Academic Record,&nbsp;</li><li>Relevant Work Experience,</li><li>Leadership&nbsp; </li></ol><li>Please note we are seeking Software Development Full Time &amp; Intern candidates. NOTE:<u>Full Time candidates must be graduating Dec. 2011 – August 2012. Candidates with graduation dates after August 2012 would be considered for internships.</u> </li><li>Travel &amp; Accommodations will be covered by Microsoft </li></ul><br /><h2> <u>Update:</u></h2>So, many people keep asking the same question: “How do we apply?!”, which, I have to admit, is a very valid question. Here’s the answer:<br /><ol><li>Go to the website: <a href="http://www.microsoft.com/university">http://www.microsoft.com/university</a></li><li>Explore the opportunities under </li><ul><li>“<a href="http://careers.microsoft.com/careers/en/us/graduate-jobs.aspx">Graduate Jobs</a>&nbsp;=&gt; <a href="http://careers.microsoft.com/careers/en/us/grad-software-jobs.aspx">Software Development</a>”&nbsp; and,</li><li>“<a href="http://careers.microsoft.com/careers/en/us/internships.aspx">Internships</a>&nbsp;=&gt; <a href="http://careers.microsoft.com/careers/en/us/tech-software-internships.aspx">Software Development</a>” </li></ul><li>Click “<span style="color: #ffc000;"><strong>&gt;&gt; APPLY NOW</strong></span>” which is in the “orange box” in the left side.</li><li>Follow the steps to complete your application.</li></ol></div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com23tag:blogger.com,1999:blog-1111853785150509287.post-29020783486977091422011-12-21T12:58:00.001-08:002012-02-26T01:49:38.096-08:00Landing a Job At Microsoft, Part3: The In-Person Interview, Impress Them!<div dir="ltr" style="text-align: left;" trbidi="on">I know it’s been a while since the first 2 posts, but I’m finally getting around to writing the 3rd part of this series, which I hope is helping you, dear reader, to prepare yourself to get your dream job ;)<br /><br />So, after <a href="http://www.abdoumoumen.net/2011/10/landing-job-at-microsoft-part1-resume.html">writing your rock star resume</a>, and after <a href="http://www.abdoumoumen.net/2011/11/landing-job-at-microsoft-part2-phone.html">making a great first impression in your phone interview</a>, you should be asked to do an <strong>in-person interview</strong>, or rather in-person interview<strong><u>s</u></strong> (as I had 4 of them ;) ). This is what you’ve been working for in the first two steps of the process. An <strong>opportunity</strong> to tell your <strong>story </strong>in your own words, to <strong>demonstrate </strong>your skills, to <strong>meet </strong>the people involved and to <strong>ask </strong>any questions <strong>YOU </strong>have.<br /><a name='more'></a>In the email I got from Microsoft congratulating me for making it to the <strong>last stage </strong>of the process, they gave me some useful resources to prepare for my interview. Here’s the list:<br /><ul><li><a href="http://careers.microsoft.com/careers/en/us/interviewtips-be-prepared.aspx" target="_blank">Interview Tips : Be Prepared (Microsoft Careers Website)</a> (I’ll discuss some of those later) </li><li><a href="http://www.amazon.com/Programming-Interviews-Exposed-Secrets-Programmer/dp/047012167X" target="_blank">Programming Interviews Exposed: Secrets to Landing Your Next Job, 2nd Edition</a> </li><li><a href="http://www.amazon.com/Introduction-Algorithms-Thomas-H-Cormen/dp/0262033844" target="_blank">•“Introduction to Algorithms” by Thomas Cormen</a> </li><li><a href="http://www.amazon.com/Algorithms-Parts-1-4-Fundamentals-Structures/dp/0201314525" target="_blank">“Algorithms in C++” by Robert Sedgewick</a> </li><li><a href="http://www.amazon.com/Testing-Computer-Software-2nd-Kaner/dp/0471358460" target="_blank">“Testing Computer Software” by Cem Kaner</a> </li><li><a href="http://www.amazon.com/How-Break-Software-Practical-Testing/dp/0201796198" target="_blank">“How to Break Software” by James A. Whittaker</a> </li><li><a href="http://cslibrary.stanford.edu/" title="http://cslibrary.stanford.edu/">Stanford CS Education Library</a> </li><li><a href="http://ocw.mit.edu/index.htm" title="http://ocw.mit.edu/index.htm">MIT Open Courseware videos</a></li></ul>Now, these are all good resources, but I’m not writing this post only to list them like this :P Instead, I’m going to give my own <strong>story</strong>, and how I prepared for my own interviews.<br /><br />You’ll notice that the resources mentioned above are for <strong>both Software Development Engineer (SDE)</strong>, and <strong>Software Development Engineer in Test (SDET)</strong>. This is because I had to interview for both positions. Big surprise is, I didn’t know much about what’s the job of an SDET until then :P<br /><br />So, as soon as (well, actually before) I got the email I started working on my preparations. First thing I did was to <strong>check out the “job descriptions” </strong>(more&nbsp;specifically <strong>what they’re looking for </strong>in someone who’s interviewing for the positions) for both positions again. Here’s the <a href="http://careers.microsoft.com/careers/en/us/grad-software-jobs.aspx">link</a>.<br /><br />As you take a look at the lists of “<strong>qualifications</strong>”, you can see that there are some items that are <strong>common </strong>for both positions. These include:<br /><ul><li>Excellent programming skills. Experience with object oriented programming languages, preferably C, C++, and/or C# </li><li>Familiarity with data structures and algorithms</li></ul><br />So I started with those two. I’ve already been working on my graduation project using C#, so I didn't&nbsp;have to do much there, but I started <strong>reviewing data structures and algorithms </strong>and dusting off my <strong>C programming skills</strong>. At this point, you should be rightfully asking “<strong>How did you do that?</strong>”. My answer follows.<br /><br /><h2> Studying/Refreshing/Reviewing</h2><br />The best thing I should have done was to <strong>read some of the aforementioned books</strong>. Unfortunately I didn’t have any of them, and I couldn’t buy one either; not to mention that there wasn't that much time!. The second best thing I could do was to use my <a href="http://letmegooglethatwithbingforyou.com/">Googling-with-Bing</a> skills to <strong>find good refreshment courses </strong>on <strong>Data Structures and Algorithms</strong>. I found what I was looking for in <a href="http://www.cs.auckland.ac.nz/software/AlgAnim/ds_ToC.html">this course from Auckland University</a>. It starts with Programming Strategies and touches on many things including <strong>Data Structures</strong>, <strong>Searching </strong>and <strong>sorting</strong>. I found it quite useful. I hope it would be the same for you. As I was going through the course (quite rapidly, by the way, since I didn’t have much time), I was also trying to <strong>implement the stuff I was learning </strong>about in C. 2 birds with one stone :D<br /><br />As I was advancing through the course, and to avoid getting bored with theory, I started testing my skills with <strong>real programming interview questions</strong>. Googling with Bing again, I stumbled upon <a href="http://technical-interview.com/default.aspx">this website</a>, which contains A LOT of technical interview questions, including many about Data Structures and Algorithms in C/C++. Solving those problems, even the simplest ones, gave me a <strong>taste of confidence </strong>which kept me <strong>motivated </strong>to go on.<br />This website is also interesting because it contained something else I was looking for, because I knew it <strong>could appear in the interviews</strong>, which is <strong>“brain teasers”</strong>, or <strong>puzzles</strong>. They <strong>stimulate your brain </strong>and make you come up with <strong>innovating solutions </strong>to problems you’ve <strong>never faced before</strong>. Even if you didn’t have puzzles in your in-person interviews (and I didn’t), you should find them useful.<br /><br />As soon as I finished the course, I got a reminder email about my interviews. It was less than a week! and guess what? I haven’t had read anything about testing yet!! I <strong>almost panicked</strong>, but thought “<strong>what good would that bring?</strong> I should just <strong>start RIGHT NOW </strong>learning about testing, and hope for the best!”. And that was what I did. I found the book <a href="http://www.amazon.com/Testing-Computer-Software-2nd-Kaner/dp/0471358460" target="_blank">“Testing Computer Software” by Cem Kaner</a>, and started reading it as well and as fast as I could (kind of contradictive, I know, but what else could I do? :P). Anyways, the book is good, obviously, and I learned a lot from it, even though I didn’t have much time to go much deep into it.<br /><br />If you’ve never learned anything about testing, like me, I <strong>highly recommend </strong>you <strong>start right now </strong>(maybe with that particular book, or maybe an online resource. Just do it ;) ). Even if you’re not after a job in testing, it can <strong>open your horizons </strong>on new things and give you <strong>a new perspective </strong>on how testers are going to try and <strong>break your code</strong>, and maybe helps you <strong>prevent bugs </strong>from sneaking on into your code ;)<br /><br />This was my preparation. Now let’s get to the actual event, shall we?<br /><br /><h2> Scheduling</h2><br />Let’s start with the interview date. I had mine scheduled for October 5th. My flight was in October 4th’s afternoon from Algeria. 8 hours of flight time (passing by Istanbul), add to that 3 hours of difference in time zones and I was to arrive in Dubai after midnight! I tried to ask for the flight to be rescheduled, but got a negative response (they said that it was the best fit they could find :( ). Imagine my horror when my recruiter said that my interview will be at 8:30 in the morning!! Fortunately though, after replying with a terrified S.O.S, I was told that it was only an innocent mistake and that my interview is for the evening. 1:00 PM to be exact. Not a lot of time, but about enough to rest :)<br /><br /><h2> Arrival</h2><br />I got to Dubai at about 1 o’clock in the morning, but had to spend more than an hour fixing a problem with my visa, and only got to my room at the hotel after 3:00 AM. Horrified that I won’t get my rest, I couldn’t sleep until after 4 :P. Point is, it’s <strong>crucial to have a good night’s sleep </strong>before your interview. If you think your flight time is inappropriate, you should <strong>speak up </strong>to your recruiter. The guys in the recruitment team are there to <strong>ensure you have a great interview day</strong>. Fortunately for me, I woke up after 6-7 hours of sleep <strong>pretty refreshed</strong>, and <strong>in good shape </strong>for the big day :)<br /><br />Another tip that I appreciated following is to <strong>have a nice breakfast</strong>. I got up just in time to not miss mine at the hotel. Circumstances made it so that I didn’t have time for lunch afterwards, but even apart from that, having an <strong>empty stomach </strong>(that could start screaming in the middle of an interview) <strong>isn’t a good idea </strong>;)<br /><br /><h2> Dress Code</h2><br /><strong>Dress appropriately to your interview</strong>. Some interpret this as “wear a suit and tie”, but I would say “<strong>not necessarily</strong>”. Well, if they say it IS necessary, then who am I to say NOT, but if they don’t, as if they said “wear comfortably”, or “wear casually”, I would say <strong>take advantage of that </strong>and go in with what makes you <strong>comfortable </strong>(if that is “suit and tie”, then by all means ;) ), but just <strong>don’t overdo it </strong>;) (shorts and slippers aren’t such a great idea as they might seem at first :p ). I went in dark pants and a light blue shirt. Found out most of the interviewers wore similarly :)<br /><br /><h2> Getting There</h2><br />I looked for the itinerary I had to take from the hotel to Microsoft’s office in Dubai’s Internet City. Departed 2 hours before my interview’s time, most of which I spent looking around and asking for directions, while under Dubai’s VERY HOT sun, after I got out on the wrong metro station :P Miraculously, I arrived at the office just in time :D. Well, in fact I was 10 minutes early ;) <br />So, my next tip is: <strong>make sure you know your way </strong>from your hotel to where you’re going to have your interview. Take into account the <strong>traffic </strong>and always <strong>plan to arrive early</strong>, but <strong>not too early</strong>. If you do arrive too early, however, you shouldn’t go directly to your interview’s location. Go to a café, <strong>have your breakfast </strong>if you didn’t already, and <strong>relax</strong>.<br /><br />At my arrival, I met my recruiter along with 4 other interviewees. We introduced ourselves, wore name tags to identify each other and then headed to our first interviews.<br /><br />We got two interviews with Devs and two with testers. Each interview lasted 45 minutes, and we had 15 minutes of “rest”, to relax and listen to the recruiter tell us how it was to work for Microsoft :)<br /><br /><h2> Finally, the Interviews</h2><br />The interviews started with the interviewer <strong>presenting themselves </strong>and talking about <strong>what they did at Microsoft</strong>. They then would <strong>ask some questions about my resume</strong>, and some of <strong>my experiences</strong>. <br />After that, it was <strong>CODING TIME</strong>! :D In each interview I had to solve 2 to 3 problems, <strong>coding the solution on a whiteboard</strong>. Now this was something I didn’t prepare for! I knew I would have to write code, but I haven’t had written much code on a whiteboard before. I <strong>suffered </strong>from this in my first interview, and I <strong>couldn’t finish the problem </strong>I was asked to solve. Fortunately, this didn’t get to me, and I <strong>kept my cool </strong>during the following interviews. In the contrary, I <strong>used that experience </strong>to develop a <strong>strategy </strong>to make this work. I would start by <strong>asking as many clarifying questions </strong>as I could (I thought I’d asked too much, but I got the job, so that wasn’t a problem ;) ), then I would <strong>start modeling the problem</strong>, and then <strong>start coding </strong>the solution while <strong>discussing </strong>it with the interviewer (and still asking questions where necessary). All this time, I would also be <strong>thinking out loud </strong>and <strong>explaining step by step my thought process</strong>. I made sure to <strong>listen to any hints </strong>from the interviewers, and this helped me <strong>several times</strong>.<br /><br />I was very blessed to <strong>be completely at ease </strong>during all this period. I was <strong>relaxed</strong>, <strong>talked freely </strong>with my recruiter and interviewers and <strong>even had some good laughs </strong>with them. This is very important. Remember that “<strong>confidence</strong>” I talked about earlier in this post, and in the first part of the series? This is where you need it most. They want someone who’s <strong>confident in his skills</strong>. Someone who’s <strong>not afraid to tackle new challenges</strong>, and someone who’s <strong>not afraid to admit </strong>when he doesn’t know something, and who’s willing to learn.<br /><br />At the end of every interview, I <strong>asked the interviewer as many questions as I could</strong>. This is an opportunity for you to <strong>get to know what it means to work in that particular position or team</strong>, and to <strong>get a feeling of what makes these people tick</strong>, <strong>what makes them happy and motivated</strong>, and to <strong>get an insight into the company’s culture</strong>. You should try and go prepared with some questions in hand ;)<br /><br /><h2> And it’s done!</h2><br />After my last interview, I received a guide to Seattle, and warm goodbyes from my recruiter.<br /><br /><a href="http://lh4.ggpht.com/-E7eN4iTa71A/Tp8SLChQYWI/AAAAAAAAB5o/e4cgZEIsc34/s1600-h/At%252520MS%252520Dubai%25255B39%25255D.jpg"><img alt="At MS Dubai" border="0" height="350" src="http://lh5.ggpht.com/-5USyPoBJN8g/Tp8SUvaj3_I/AAAAAAAAB5w/ygyj9E8g0MM/At%252520MS%252520Dubai_thumb%25255B36%25255D.jpg?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="At MS Dubai" width="399" /></a><br /><br />A couple of days later, I emailed them my exit stamp (to show that I arrived at my home country), and the following day the big news came. <strong>I LANDED A JOB AT MICROSOFT</strong> :D<br /><br /><h2> Resources:</h2><ul><li><a href="http://careers.microsoft.com/careers/en/us/your-second-round-interview.aspx">Microsoft University Careers - Your Second Round Interview</a> (an absolutely MUST READ. goes through the whole process of the in-person interviews with great tips on how to succeed it) </li><li><a href="http://careers.microsoft.com/careers/en/us/interviewtips-be-prepared.aspx" title="http://careers.microsoft.com/careers/en/us/interviewtips-be-prepared.aspx">Interview Tips : Be Prepared</a> </li><li><a href="http://www.microsoftjobsblog.com/blog/get-your-interview-skills-in-shape">Get your interview skills in shape</a> (video) </li><li>Microsoft interview study guide <a href="http://www.microsoftjobsblog.com/blog/interview-study-guide-part-one" title="http://www.microsoftjobsblog.com/blog/interview-study-guide-part-one">Part 1</a> &amp; <a href="http://www.microsoftjobsblog.com/blog/interview-study-guide-part-two">Part 2</a> (great series from Microsoft Jobs Blog) </li><li><a href="http://careers.microsoft.com/careers/en/us/grad-software-jobs.aspx" title="http://careers.microsoft.com/careers/en/us/grad-software-jobs.aspx">Software Development Overview</a> on the Microsoft Careers website. Talks about what “qualifications” are needed for each for each of the positions. </li><li><a href="http://www.cs.auckland.ac.nz/software/AlgAnim/ds_ToC.html" title="http://www.cs.auckland.ac.nz/software/AlgAnim/ds_ToC.html">Data Structures and Algorithms (Auckland University)</a> </li><li><a href="http://technical-interview.com/default.aspx">Technical interview </a>, contains a lot of sample interview questions from coding problems to technical questions to puzzles and brain teasers. Great place to practice your skills. Best part is, it has the answers as well ;) </li><li><a href="http://www.softwareqatest.com/qatfaq1.html">Software QA and Testing Resource Center - FAQ Part 1</a> a number of questions and answers on Software QA and Testing. Very good as an intro to get to know the field and have a sense for what it involves.</li></ul><br />This concludes the series. My <strong>main purpose </strong>for these posts is to <strong>help people </strong>who intend to endeavor such an adventure. And if YOU don’t intend to, <strong>you should </strong>;) because my <strong>second purpose </strong>is to show that <strong>it isn’t impossible </strong>for YOU to <strong>land your Dream Job </strong>at your favorite company ;)<br />Many people who read the first two posts said they liked them a lot and this is what kept me writing, and I hope you liked this 3rd post as well. I also know many people who are already going through the first stages of this process, and some who started but didn’t make it. For the former I say “Good Luck”, and for the latter I say, well, “Good Luck” as well in your future endeavors, and you should never give up as new opportunities come by every now and then ;)</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com26tag:blogger.com,1999:blog-1111853785150509287.post-636005303309566242011-11-09T11:46:00.000-08:002012-02-26T01:16:13.099-08:00Landing a job at Microsoft, Part2: The Phone Interview, Make a Very Good (first) Impression!<div dir="ltr" style="text-align: left;" trbidi="on"><br />So, I’ve recently <a href="http://www.abdoumoumen.net/2011/10/microsoft-gave-me-offer-i-couldnt.html" target="_blank">posted</a> about the offer I got to work at Microsoft. Then, I started a 3 part series to talk about my experience getting the offer. <a href="http://www.abdoumoumen.net/2011/10/landing-job-at-microsoft-part1-resume.html" target="_blank">The first one</a> was about writing a <strong>good resume</strong>. In this one, I’m going to talk about the second step in the process: <strong>The Phone Interview.</strong><br /><br />In the previous blog post, I mentioned that writing a good resume is essential since it’s usually your first interaction with the company, and allows them to filter interesting profiles that match their requirements. However, as big companies get tons of resumes regularly, they usually have a second filter, and that is, usually, a Phone Interview.<br /><br />A phone interview takes usually about 30 minutes, where the interviewer would call you by phone or using Skype. They introduce themselves, tell you how the interview is going to take place, then start going through the interview questions (more on that shortly). In the end, they’ll ask if <strong>YOU</strong> have any questions (more on that later).<br /><a name='more'></a><br /><br /><br /><strong><span style="font-size: large;">Pre-Interview</span></strong><br /><br />Before the interview, there are some things that you need to prepare. First, when you’re asked to provide your availability in order to schedule the interview, make sure you’re absolutely free and that there would be nothing to distract or disturb in the times you mention. Calm and quiet, both on your nerves and in your environment, are crucial for a successful phone interview.<br /><br />If your interview is by phone, make sure you provide a backup phone (and line), preferably a landline. Remember Murphy’s Law “<strong>if something can go wrong, it WILL!</strong>”. I know, the hard way, the call kept dropping on my mobile phone. I got my interview rescheduled (lucky me :p), and in the second attempt I used a landline, and it went very well. Now, to my defense, I did try to find a second phone number but couldn’t. I should’ve tried harder :P<br /><br />If, however, your phone is through Skype, you better make sure you won’t lose internet connection that day :P Make sure you’ve paid your internet subscription and preferably have a close secondary location where you can run to and finish your interview ;)<br /><br />That was for the <strong>logistics</strong>. <strong>How about the questions</strong>?!<br /><br />The answer for that is simple: “it depends”. What it really depends on is the kind of interview you’re having. Could be purely technical, could be situational(how “<strong>would</strong>” you react to a certain situation?), could contain a lot of brain teasers, or, could be the kind of interview that I had which is called a <strong>Behavioral Interview</strong> (but which actually contained a little of all of the above). I’m not sure how it usually happens with other companies, but I was informed about what kind of interview I would be having beforehand. This was very helpful for my preparation :)<br /><br />Now, a good question would be “<strong>what’s a Behavioral Interview</strong>?”<br /><br />As I understand it, in a Behavioral Interview you’re not asked about how would you do in fictional scenarios, but instead, you’re asked about previous experiences and how did you <strong>behave</strong> in situations of stress, of conflict, or with technical difficulties. It <strong>uses past performance to predict future performance</strong>. That was how “I” understood it. Now here’s how people, who actually know what they’re talking about, define it:<br /><blockquote><br /><strong>Behavioral</strong> (experience-based or patterned behavioral) <strong>interviews</strong> are <strong>past-oriented</strong> in that they ask respondents to relate what they did in past jobs or life situations that are <strong>relevant</strong> to the particular job’s relevant <strong>knowledge</strong>, <strong>skills</strong>, and <strong>abilities</strong> required for success. The idea is that <strong>past behavior is the best predictor of future performance</strong> in similar situations. By asking questions about how job applicants have handled situations in the past that are similar to those they will face on the job, employers can gauge how they might perform in future situations. <em><a href="https://en.wikipedia.org/wiki/Job_interview#Behavioral_Questions" target="_blank">(Wikipedia)</a></em></blockquote><br />Here’s an example (from the previous source, and others) of Behavioral Questions:<br /><ul><li>Describe a situation in which you were able to use persuasion to successfully convince someone to see things your way. </li><li>Give me an example of a time when you set a goal and were able to meet or achieve it. </li><li>Tell me about a time when you had to use your presentation skills to influence someone's opinion.</li><li>Tell me about a technical question you faced in one of your project and describe what did you do about it?</li></ul><br />This is not going to be a listing of all the questions you could get (because, well, they’re endless, and this isn’t the place for them). You’ll find many on the internet just <a href="http://tinyurl.com/7bk3m3u" target="_blank">by googling “Behavioral Questions/Interview” with Bing</a> ;) (you’ll find some links about this in the resources section at the bottom)<br /><br />Now, what’s really challenging about this kind of questions is that you’ll need to remember some specifics about the <strong>situation </strong>you’re going to describe! Heck! you’re going to have to remember that you actually were in such a situation in the first place (big problem for me apparently :P)! Then you have to remember the <strong>task </strong>at hand, the <strong>actions </strong>you took and finally the <strong>outcome</strong>. <br /><br />If you could remember ALL this instantly, well, good for you! but that’s not how my brain works. As I said, I (was lucky to) have been informed about the kind of my interview beforehand, and so I had a chance to <strong>prepare</strong> for it (what I call, a fighting chance ;) ). The first thing I did was, obviously, to google it with Bing and see what the heck is this “Behavioral Interview” stuff and what kind of questions would there be. After seeing what I’ve just told you, I realized that the solutions is quite simple. Prepare a list of “<strong>stories</strong>” corresponding to <strong>a)</strong> as much of the questions that I could possibly find, <strong>b)</strong> previous experiences relevant to the job, especially those I mentioned in my resume (see?! here comes the resume again ;) )<br /><br />Apparently (I’ve just learned this), there’s a “method” for replying to such questions. From <a href="https://en.wikipedia.org/wiki/Job_interview#Behavioral_Questions" target="_blank">Wikipedia</a>:<br /><blockquote>One way individuals can prepare for behavioral type questions is to <strong>practice</strong> the STAR method. The STAR method is a structured manner of responding to a behavioral-based interview question by discussing the specific situation, task, action, and result of the situation you are describing. <br /><b>Situation:</b> Describe the situation that you were in or the task that you needed to accomplish. This should describe specifics rather than general descriptions of past behavior. <br /><b>Task:</b> What goal were you working toward? <br /><b>Action:</b> Describe the actions you took to address the situation with detail and focus on yourself. What specific steps did you take and what was your contribution? <br /><b>Result:</b> Describe the outcome of your actions. What happened? How did the event end? What did you accomplish? What did you learn? Make sure your answer contains multiple positive results.</blockquote>&nbsp; <br />As I said earlier, I also had some technical questions and brain teasers, so I had to prepare for those as well. I found it useful to just go online and look for some examples of such interview questions and answer them on my own. Some of the questions that I had are: “describe <strong>good code</strong>”, “describe <strong>bad code</strong>”, “suppose you’re here in my office, and I asked you to tell me what’s the temperature outside without you going out”, etc. <br /><strong></strong>&nbsp; <br /><strong></strong>&nbsp; <br /><span style="font-size: large;"><strong>During The Interview</strong> </span><br />&nbsp; <br />Now that you are all prepped up and ready for your interview, let’s talk about the interview itself. <br />&nbsp; <br />As I stated in the beginning, it’s critical to have a quiet environment for your interview, and to be calm and ready. There are some things you can do that would make for a better experience and hopefully for great results. <br />&nbsp; <br />Here’s a list of such things that I copy-pasted from a <a href="http://jobsearch.about.com/cs/interviews/a/phoneinterview.htm" target="_blank">great article on About.com</a>: <br /><ul><li>Don't smoke, chew gum, eat, or drink. </li><li>Do keep a glass of water handy, in case you need to wet your mouth. </li><li>Smile. Smiling will project a positive image to the listener and will change the tone of your voice. </li><li>Speak slowly and enunciate clearly. </li><li>Use the person's title (Mr. or Ms. and their last name.) Only use a first name if they ask you to. </li><li>Don't interrupt the interviewer. </li><li>Take your time - it's perfectly acceptable to take a moment or two to collect your thoughts. </li><li>Give short answers. </li><li>Remember your goal is to set-up a face-to-face interview. After you thank the interviewer ask if it would be possible to meet in person.</li></ul><br />In addition to that, you should keep a pen and paper handy. It could be quite annoying (and time consuming) to tell the interviewer that he needs to hold up a sec while you fetch something to put your notes on (like data for a brain teaser, notes for future reference). In the other hand, one thing that you don’t want to keep around is the detailed information about your experiences which we talked about earlier. A short list of achievements or particular “story titles” can help you focus and remember, but keeping the whole inventory in front of you could have the opposite effect of causing distraction and confusion. Your resume, on the other hand should be useful as the interviewers will ask about stuff you mentioned there ;).<br /><br />A couple more hints here. I’ve read, and I believe to be true, that you shouldn’t sit in one location for the whole interview. Stand up and pace around the room. This will help your blood circulation and make you sound more energetic, in contrast with the feel of laziness which would come from someone sitting “comfortably” :P. The second thing is, don’t be shy about asking your interviewer clarifying questions. Keep in mind that they’re not there to make you “fail”, they’re there to understand you and get to know you more ;)<br /><br /><br /><strong><span style="font-size: large;">After the Interview</span></strong><br /><br />At the end of your interview, your interviewer will probably ask if you have any questions for them. You should. I’ve read an article about this, and most of the interviewers are asking this and are sincere in that they really want to help you make your decision and know if the company is a fit for you, as well as if you are a fit for the company. It’s not a trick question. Don’t shy out, and don’t over-stress about this. There are some examples of possible questions that would both be beneficial for you to know more about the company, and make you seem more passionate, intelligent, whatever. I say take some of those, but more importantly see deep inside if there are some real questions that concern you and which you want answered. This is your chance ;)<br /><br />Make sure to thank your interviewer, and ask about what happens next.<br /><br />After the interview, write down or just mentally evaluate how you did in the interview. Note what you did well, and what wasn’t so well. This will help you whether you make it to the second round of interviews (in-person), or for future endeavors ;)<br /><br /><br /><span style="font-size: large;"><strong>Resources</strong>:</span><br /><ul><li><a href="http://jobsearch.about.com/cs/interviews/a/phoneinterview.htm" target="_blank">Great article on Phone Interviews (About.com</a>)</li><li><a href="http://www.interviewtips.org/phone-interview-tips/phone-interview-tips.html" target="_blank">Phone Interview Tips</a> (InterviewTips.Org)</li><li><a href="http://www.interviewtips.org/phone-interview-tips/phone-interview-tips.html" target="_blank">Ace That Phone Interview</a> (MicrosoftJobs Blog)</li><li><a href="http://microsoftjobsblog.com/blog/do-you-have-any-questions-for-me">Do you have any questions for me?</a> (MicrosoftJobs Blog)</li><li><a href="https://en.wikipedia.org/wiki/Job_interview#Behavioral_Questions" target="_blank">Behavioral Questions (Wikipedia)</a></li><li><a href="http://jobsearch.about.com/od/behavorialinterviews/a/behavioral-interview-questions.htm" target="_blank">List of Behavioral Interview Questions</a></li><li><a href="http://blog.emurse.com/2007/05/21/complete-list-of-behavioral-interview-questions/" target="_blank">Another long (maybe too long :P) list</a></li></ul></div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com16tag:blogger.com,1999:blog-1111853785150509287.post-2116447795802696212011-10-23T04:37:00.000-07:002011-10-28T05:05:28.453-07:00Landing a job at Microsoft, Part1: The Resume, Catch Their Attention!<div dir="ltr" style="text-align: left;" trbidi="on">In <a href="http://www.abdoumoumen.net/2011/10/microsoft-gave-me-offer-i-couldnt.html" target="_blank">a previous post</a>, I talked about the job offer I got to work at Microsoft. This is the first of a 3 post series where I share my experience and some tips &amp; tricks and resources that could help <strong>YOU</strong> do the same ;)<br /><br />So, The first step is your resume/CV. You have to submit a great one, since it’s the first thing they’ll get to see of you (and of your work, since it’s something <strong>YOU</strong> <strong>produced</strong>). <br /><br />However, and before going deep into how to present your resume, I would like to touch on something of the utmost importance. If you want to have a great resume, you need to <strong>HAVE a great resume</strong>. Confusing? not really. You can’t impress them with what you would/will do, and certainly not by faking it, so you better make sure to <strong>invest</strong> in yourself, and pack up a good deal of <strong>experiences</strong> and <strong>skills</strong>. This will also have the benefit of giving you more <strong>confidence</strong> in your interviews (more on that later).<br /><a name='more'></a>Your CV, or resume, is in my opinion, one of the most <strong>powerful</strong> weapons you have in your arsenal while job hunting! It’s the <strong>first</strong> interface between you and your recruiter, and will follow you through the entire process. You’ll get questions tailored according to it, and they’ll check your references to see <strong>if you really are what your resume says</strong>. This makes it a two edged blade, though. You want to show how skilled you are, but <strong>don’t overdo it and keep it relevant.</strong><br /><br />Now, let’s say that you’re armed with a number of interesting skills and experiences. We know that it’s a best practice to keep your resume to one page (2 is acceptable, 3 is nearing bad), so “<strong>what to put in there?!</strong>” is a very logical question. My answer to that is: <strong>Keep It Relevant</strong>. There isn’t, INHO, a worse resume, than one that’s an <strong>encyclopedia</strong> of everything you did or knew (or heard of!). Look with great care at what the job description or the recruitment website/announcement says, and try to match what they’re looking for with what you have. This will let them know that you “did your homework”, and will make it easier for them (or for their automatic system, as this is more and more common) to see that <strong>you’re a good fit for the job</strong>.<br /><br />After identifying what’s relevant to the job you’re applying for, you’ve answered the “what?”. Now the question is “<strong>How to present this information?!</strong>”.<br /><br />There are two situations. Either you have a template (for print or electronic documents) or a form (for a computerized system) that you HAVE TO use, in which case you don’t really have a choice; Or you are free to style your resume however you like (for print or electronic documents, or copy/paste computerized systems).<br /><br />For the latter situation, there are a lot of different examples and templates online for CVs and resumes that you can use, some are chronological, by experience, by skills, etc. However, this doesn’t mean that you can’t get <strong>creative</strong>. If you have an idea for an awesome way to present your resume, I would say: go for it. But keep in mind that “awesomeness” is relative ;)<br /><br />Let’s get a little more practical. How did I present MY resume? <br /><br />I introduced my resume, after the title and contact information of course, with a “<strong>summary</strong>” (which would technically make it a “resume’s résumé” :P). I didn’t know such a thing existed, as I’ve never seen it used here in Algeria, and I thank <a href="https://twitter.com/ClintRutkas" target="_blank">Clint Rutkas</a> from Microsoft who caught my attention to this and helped me with it.<br /><br />As [good/big] companies get TONS of applications, most recruiters “<strong>skim</strong>” the resumes at first to identify “interesting” profiles. The summary is meant to give the recruiter a quick glance at you. This is your chance to <strong>catch their attention</strong>. You should mention things that make you <strong>stand out of the crowd</strong>. Put your <strong>proudest achievement</strong>; your most <strong>valued award</strong>, and your most <strong>outstanding experience</strong> (while staying relevant). I started my resume with the following:<br /><blockquote>I'm a soon to be graduate of <b>computer science</b> that is <b>Silverlight MCTS</b> (Microsoft Certified Technology Specialist) along with a <b>Microsoft Student Partner Country Lead</b> and a world-wide Microsoft's <b>Imagine Cup Finalist</b> in embedded device programming. </blockquote>&nbsp; <br />Up to this point, I was safe. The next step I took, however, was a little risky ;). <br /><em><strong></strong></em>&nbsp; <br /><em><strong>Disclaimer: </strong>Now, I did do some research, and asking around about how to nail a resume. However, the information here is presented “as is”, with no explicit or implied warranties. All I can say is: it worked for me :p (actually, all my interviewers said they liked it ;) but then again, no warranties )</em> <br />&nbsp; <br />So, for the main section of my resume, I decided to go with my “creative side” and do something unique. What I came up with is what I call a “P-SWOT Analysis” (or <strong>Personal SWOT Analysis</strong>) :D. SWOT, as many of you might already know stands for “Strengths, Weaknesses, Opportunities and Threats”, which is, <a href="https://en.wikipedia.org/wiki/SWOT_analysis" target="_blank">according to Wikipedia</a>: <br /><blockquote>a <a href="https://en.wikipedia.org/wiki/Strategic_planning">strategic planning</a> method used to evaluate the <b>S</b>trengths, <b>W</b>eaknesses/Limitations, <b>O</b>pportunities, and <b>T</b>hreats involved in a <a href="https://en.wikipedia.org/wiki/Project">project</a> or in a <a href="https://en.wikipedia.org/wiki/Business">business</a> venture. It involves specifying the objective of the business venture or project and identifying the internal and external factors that are favorable and unfavorable to achieve that objective. </blockquote>&nbsp; <br />Needless to say that I didn’t go as far as really applying the analysis method, but the structure seemed reasonable enough, so I went with it. Apparently (and fortunately for me), it worked :D <br />&nbsp; <br />The <strong>Strengths </strong>section is, obviously, the biggest and most important. Here I put my <strong>best and most relevant experiences</strong>, along with what I’ve <strong>accomplished</strong> through them, and the <strong>skills</strong> I acquired. I practically matched one to one what they were looking for with what I had! <br />&nbsp; <br />I tried to use <strong>“Action verbs</strong>”, and I <strong>emphasized</strong> key words in my sentences. As for the order, it was mostly chronological to show <strong>evolution.</strong> Here’s an example: <br /><blockquote>- <b>Microsoft Student Partner</b> for <b>2 years</b> (2009 and 2010) then <b>MSP Country Lead </b>for<b> </b>this<b> </b>year (2011)<br /><i>Accomplishments</i>:<br />&nbsp;&nbsp; o Taught <b>C#</b>,<b> .NET </b>and<b> Object Oriented Programming</b> principals in training sessions at campus.<br />&nbsp;&nbsp; o Did a couple of <b>talks</b> in local events (TechDays Algiers, and Web Week)<br />&nbsp;&nbsp; o <b>Vice President</b> of the scientific club in my school, and head of the .NET Group in the club.</blockquote>&nbsp; <br />The <strong>Weaknesses</strong> section was both because it’s part of SWOT (obviously :P ), and because it’s good to be <strong>honest and upfront</strong> with what you know and what you don’t. I tried to make it more fun, and interesting by adding a “<em>Counter Measure</em>” to each item in the list. Here’s an example: <br /><blockquote>- Didn't have much experience speaking in English <br />&nbsp;&nbsp;&nbsp; o <i>Counter measures:</i> I jump into conversation with native speakers whenever I can.</blockquote>&nbsp; <br />In the <strong>Opportunities</strong> section, I put some paths I had in front of me and chances I might take, such as: <br /><blockquote>- <b>Bright future</b> working with Microsoft development technologies<br />- Fair <b>chance</b> to land a job at <b>Microsoft</b></blockquote>&nbsp; <br />I didn’t find any <strong>Threats</strong> to mention, so I just put the following: <br /><blockquote>- Other applicants, maybe!</blockquote>&nbsp; <br />This got me a good laugh with one of the interviewers ;) <br /><br />I did my best to keep it concise and to the point, as well as interesting. It did, however, span to two pages, which is as I said earlier, not that bad:) I tried the same for this blog post (which has also gone considerably long :P) and I hope you found it useful.<br /><br />At the end, I would like to point you to some of the great resources that I used while in the process of writing my resume:<br /><ul><li><a href="http://www.microsoftjobsblog.com/Search?q=resume" target="_blank">The Microsoft Jobs Blog</a>: awesome website that contains lots and lots of great content on writing resumes, doing interviews, life at Microsoft and more. </li><li><a href="http://microsoftjobsblog.com/top-10-resume-tips-every-student-should-know">Top 10 resume tips every student should know</a></li><li><a href="http://careers.microsoft.com/careers/en/us/resume-tips.aspx" target="_blank">Resume Tips at the Microsoft Careers website</a>: concise list of very useful tips</li></ul>(I’ll try to update this list whenever I find more useful content)<br /><br />Finally, here's <a href="http://www.abdoumoumen.net/p/resume.html">the full resume </a>that I submitted for the SDE position at Microsoft.<br />I hope this helps, and stay tuned for the next posts in the series ;)</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com84tag:blogger.com,1999:blog-1111853785150509287.post-87058063280330405042011-10-19T11:31:00.000-07:002011-12-21T15:21:57.997-08:00Microsoft gave me an offer I couldn’t refuse!<div dir="ltr" style="text-align: left;" trbidi="on">So, I received some AWESOME news recently! An offer from Microsoft for an SDE (Software Development Engineer) position in its Online Services Division :D and as the title suggests, I couldn’t refuse ;)<br /><br />As a result, I wanted to share with you, the different stages I went through in order to get this offer, along with some tips &amp; tricks and resources that could help YOU land a job at the company of your dreams.<br /><br />First, let me give you some context, and summarize the process, then I’ll try to give more details along with the tips &amp; tricks in the following posts.<br /><br />In the beginning of September, it came to my knowledge (through Facebook, oddly enough :P) that Microsoft was having a recruitment campaign in the MEA (Middle-East and Africa) region, and that there will be an event in Dubai from October 3rd to the 6th. The news mentioned the website “<a href="http://www.microsoft.com/university" target="_blank">http://www.microsoft.com/university</a>”, so I just went there and took a look around at the different “graduate” offers. It looked (very) interesting (duh!), so I decided to give it a try. I wrote a <strong>resume</strong> and submitted my application in the website. And waited …<br /><br /><a name='more'></a><br /><br />A week later, I was VERY EXCITED to receive an email from a Recruiting Coordinator from Microsoft, asking for some contact information, and my availability for a <strong>phone interview.</strong> I gave them what they asked for and they confirmed my interview for September 13th. At the specified date, I got the call, but there were problems with the line so we had to postpone it. The second attempt was on the 16th, and it went splendidly. After the interview, I considered what I did well, and what wasn’t so well, and then waited… (again :P)<br /><br />I didn’t have to wait for long though, for 3 days later, I got an email from an <strong>Interview Scheduling Specialist </strong>congratulating me on making it to the next stage: the “famous” in-person interview<strong>s </strong>(and yes, it’s plural ;) ) for both an SDE (Software Development Engineer) and an SDET (Software Development Engineer in Test). I was scheduled for October 5th. I departed to Dubai on the evening of the 4th, was there in the morning of the 5th, took some sleep and went for my interviews. I started at 1:30 PM, did 4 interviews of 45 minutes each (with 15 minutes of “rest” in between, and an additional 45 minutes waiting because there were 4 interviewers and 5 interviewees), with 2 interviews in Dev and 2 in Test. I got out at&nbsp;7 PM, went to my hotel, had dinner and started for the airport! As you can see, I did go to Dubai, but didn’t really “visit it” :’-(<br /><br /><a href="http://lh4.ggpht.com/-E7eN4iTa71A/Tp8SLChQYWI/AAAAAAAAB5o/e4cgZEIsc34/s1600-h/At%252520MS%252520Dubai%25255B39%25255D.jpg"><img alt="At MS Dubai" border="0" height="350" src="http://lh5.ggpht.com/-5USyPoBJN8g/Tp8SUvaj3_I/AAAAAAAAB5w/ygyj9E8g0MM/At%252520MS%252520Dubai_thumb%25255B36%25255D.jpg?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="At MS Dubai" width="399" /></a><br /><br />This time, there wasn’t much “waiting”. As I came back, I scanned and sent the exit stamp (which was required by the immigration at Dubai), and got the (happy) results the following day :D I got my offer, that I couldn’t refuse :)<br /><br />That was the “quick” story. In the next 3 posts, I’ll try to cover the 3 steps of the process:<br /><ol><li><a href="http://www.abdoumoumen.net/2011/10/landing-job-at-microsoft-part1-resume.html">The Resume: Catch Their Attention! </a></li><li><a href="http://www.abdoumoumen.net/2011/11/landing-job-at-microsoft-part2-phone.html">The Phone Interview: Make a Very Good (first) Impression! </a></li><li><a href="http://www.abdoumoumen.net/2011/12/landing-job-at-microsoft-part3-in.html" target="_blank">The In-person Interviews: Impress Them!</a></li></ol>Stay tuned ;)</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com4tag:blogger.com,1999:blog-1111853785150509287.post-81463074631997601482011-09-17T12:02:00.000-07:002011-09-17T12:02:33.172-07:00Bug Hunt: Chasing an obscure AccessViolationException (Silverlight)<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">So, I’m working on my graduation project, using Silverlight 4, <a href="http://compositewpf.codeplex.com/" target="_blank">Prism</a> and the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Model_View_ViewModel" target="_blank">MVVM pattern</a>. <br /><br /></div><a href="http://lh4.ggpht.com/-rA29ifTTDDg/TnTkfhydS8I/AAAAAAAABrw/CXBy2RJ_1kc/s1600-h/Bug%252520Hunting.png"><img alt="Bug Hunting" border="0" height="133" src="http://lh4.ggpht.com/-B9gyPM0zzYg/TnTjDIKXuiI/AAAAAAAABr0/MLtVCXEoxG8/Bug%252520Hunting_thumb.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="Bug Hunting" width="132" /></a><br /><br />Now, for some context on my bug:<br /><br /><a name='more'></a><br />A couple of days ago, I started implementing support for comments in my application, following the next steps:<br /><ol><li>I added the necessary entity and relationships to my Entity Data Model. </li><li>I added the corresponding CRUD operations in my domain service. </li><li>I implemented the ViewModel (ViewCommentsViewModel), and a DataTemplate as my View (ViewCommentsWindowTemplate) </li><li>I added a button in the view that has to show comments, and wired its Command property to “ViewCommentsCommand” in the corresponding ViewModel, and added an InteractionRequestTrigger to it, which is bound to an InteractionRequest on the ViewModel (ViewCommentsRequest), and shows a ChildWindow. <br />here’s the XAML for this:<br /><br /> <div class="csharpcode"><style type="text/css">.csharpcode, .csharpcode pre<br />{<br /> font-size: small;<br /> color: black;<br /> font-family: consolas, "Courier New", courier, monospace;<br /> background-color: #ffffff;<br /> /*white-space: pre;*/<br />}<br />.csharpcode pre { margin: 0em; }<br />.csharpcode .rem { color: #008000; }<br />.csharpcode .kwrd { color: #0000ff; }<br />.csharpcode .str { color: #006080; }<br />.csharpcode .op { color: #0000c0; }<br />.csharpcode .preproc { color: #cc6633; }<br />.csharpcode .asp { background-color: #ffff00; }<br />.csharpcode .html { color: #800000; }<br />.csharpcode .attr { color: #ff0000; }<br />.csharpcode .alt <br />{<br /> background-color: #f4f4f4;<br /> width: 100%;<br /> margin: 0em;<br />}<br />.csharpcode .lnum { color: #606060; }<br /></style> <a href="http://lh3.ggpht.com/-8rl22huQdzQ/TnTkh00bDvI/AAAAAAAABsY/iGKgFuSrEW0/s1600-h/image%25255B8%25255D.png"><img alt="image" border="0" height="187" src="http://lh4.ggpht.com/-rety2x4Mj0o/TnTkjbAaguI/AAAAAAAABsc/HoNS87TMOqw/image_thumb%25255B6%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="614" /></a></div></li><li>The ViewCommentsCommand’s “Execute” method retrieves the comments from the server, and “Raises” the ViewCommentsRequest.</li></ol><br />All this worked great in this particular view. However, as I wanted to add the same functionality to other parts of my project, I suddenly started getting this weird problem right after the Comments are loaded, and the InteractionRequest.Raise is called:<br /><br /><a href="http://lh6.ggpht.com/-QpeGgQaAHcg/TnTjDw-mViI/AAAAAAAABsA/BJZGlKWHATI/s1600-h/image5%25255B1%25255D.png"><img alt="image" border="0" height="56" src="http://lh4.ggpht.com/-VQJLOAFXXJs/TnTjExPohvI/AAAAAAAABsE/ftiFT__HU-A/image5_thumb.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="474" /></a><br /><br />Now, at this stage I FREAKED OUT!! what would you make of that?! And since this is encapsulating a COM error, you’ll have no stack trace or other interesting information.<br /><br />When I continue execution, I get the following error, which isn’t any better!<br /><br /><a href="http://lh5.ggpht.com/-UasLmlrnuMI/TnTjFnJ2L7I/AAAAAAAABsI/MuPv2jk4mS0/s1600-h/image13%25255B1%25255D.png"><img alt="image" border="0" height="290" src="http://lh5.ggpht.com/-dpBEIKICGbc/TnTjHK74ToI/AAAAAAAABsM/aLHZBZ8sLdw/image13_thumb.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="398" /></a><br /><br />So, what do I do? <a href="http://tinyurl.com/3cv8qjo" target="_blank">I google that with bing</a>! and search for it on <a href="http://www.stackoverflow.com/" target="_blank">StackOverFlow</a> (amazing Q&amp;A site, by the way). But that didn’t help much. This seemed to be a problem that happens randomly, and in very distinct situations. There were some people suggesting to reinstall the Silverlight 4 tools, which I did (and I even reinstalled Prism), with no avail! <br /><br />At this point, I had already put some breakpoints in my code in the Execute method for the ViewCommentsCommand. After following the execution of the program, I figured out that the ViewCommentsViewModel which I passed to the Raise method is instantiated correctly, and the Raise method returns without a problem. Therefore, my mind went into the DataTemplate, since I knew that sometimes messing up something in XAML may cause some of these obscure problems.<br /><br />True enough, just as I glanced over my template: Eureka ! I found it! and you’ll never guess what it was. Here’s a snapshot:<br /><br /><a href="http://lh5.ggpht.com/-fIzFnLSdiJY/TnTjH6SNySI/AAAAAAAABsQ/KuLSOlnJt2o/s1600-h/image21%25255B1%25255D.png"><img alt="image" border="0" height="92" src="http://lh4.ggpht.com/-yus1jQ8Xk1M/TnTjI3Q4-lI/AAAAAAAABsU/CjN5jiefMcM/image21_thumb.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="272" /></a><br /><br />WHAT! who would set a Height to “1(5)0”! what would that mean! and how could that even happen! <br /><br />But I knew! I had that Height set to “200” at some point, and it seemed bigger than I wanted to. I “tried” to set it to “150”, by selecting the 2 and replacing it by 1, then selecting the first 0 and hitting “5”. Now, my keyboard is in AZERTY layout, so I should have hit “shift+5”. And to make matters worse, I had set a keyboard binding of a feature of CodeRush, that puts the selected text between parentheses, to use the “5” keystroke! <br />However, this should’ve been “1(0)0”! How this became what it was, I cannot account for!<br />Needless to say, removing the cursed parentheses solved the problem! (yaay!) and as I felt so ashamed of myself, I decided to blog about this, hoping that it might be of value to somebody (or to a future me who might get the same problem) :)<br /><strong><u>Takeaways:</u></strong> <br /><ul><li>Make sure you NEVER mess stuff in your XAML. EVER. While waiting for more features for showing errors in the editor (*cough* VS2011 *cough*), always check (and re-check) your bindings and property setters.</li><li>CodeRush is an AWESOME tool (check <a href="http://www.abdoumoumen.net/2011/08/devexpress-coderush.html" target="_blank">my previous post</a> ;) ), but you can shoot yourself in the foot if you’re not careful. Be aware of that <em>Embed Selection </em>feature, and check your keyboard bindings (in DevExpress Options, go to IDE=&gt;Shortcuts, then Selection=&gt;Embedding).</li><li>When you encounter a weird error, It’s not the universe conspiring against you. You have DEFINITELY messed up somewhere :P. </li><li>And … However weird the bug might appear, there’s always a “Bug Hunt” for it ;)</li></ul></div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com0tag:blogger.com,1999:blog-1111853785150509287.post-60101951936179846792011-08-21T13:20:00.000-07:002011-09-30T11:57:05.966-07:00Baby Steps: CodeRush Plugin Development<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; I mentioned in my <a href="http://www.abdoumoumen.net/2011/08/devexpress-coderush.html" target="_blank">previous post</a> that I’ve grown quite some interest in<a href="http://www.devexpress.com/crx"> CodeRush from DevExpress</a>, and part of that is because of the plug-in model they have in place, which is pretty powerful, yet simple to tap into and develop refactorings, code-providers, etc.</div><div style="text-align: justify;"><div class="separator" style="clear: both; text-align: center;"><a href="http://devexpress.com/Support/Webinars/i/highlights/CodeRush-Plugins.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://devexpress.com/Support/Webinars/i/highlights/CodeRush-Plugins.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; In this post, I’m going to talk about the first CodeRush plugin I’ve ever wrote! It has a funny story, actually, where I was watching<a href="http://tv.devexpress.com/#CRPluginsTextDocTextView"> this recording of a CodeRush Feature Workshop</a>, and at some point in the webinar, an attendee asked a question about how would a particular refactoring be implemented. <a href="http://twitter.com/RoryBecker">Rory</a>, started talking about that, and how easy it would be, then <a href="http://twitter.com/MillerMark">Mark Miller</a>&nbsp;said: “<em>Well, I almost wanna right that right now! It's like, so easy to do</em>”. I thought to myself: “<em>why not?!, this is my chance! :D</em>”, and I just stopped the recording right away, opened Visual Studio and started developing my first Plugin! :) Just to be honest, as <a href="http://twitter.com/MillerMark">Mark</a>&nbsp;suggested, this is very basic, and simple. But, heck, it got me hooked!&nbsp;</div><a name='more'></a><br /><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; The basic idea for the plugin is that, sometimes, you have a portion of code that you want to change. However, you want to keep the current code maybe for reference, or just in case you needed it (or a part of it) back. To do it manually, you would&nbsp;select that portion, copy it, comment your selection (using Ctrl+k,Ctrl+c if you’re a true keyboarder :P) and then paste the code you copied. Something like this:</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh3.ggpht.com/--yqjjIOp5j4/TlFMGiurFYI/AAAAAAAABpU/d8cjQELRkMs/s1600-h/image%25255B75%25255D.png"><img alt="image" border="0" height="147" src="http://lh5.ggpht.com/-2A-0CWzy0SQ/TlFMHhzhaCI/AAAAAAAABpY/oOZ1zfPi3XA/image_thumb%25255B46%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="435" /></a></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; So, why don’t we write a CodeRush Action that does just that? Simple enough? let’s get started…</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; To create a CodeRush Plugin, you’ll need to have <a href="http://devexpress.com/Products/Visual_Studio_Add-in/DXCore/" target="_blank">DXCore</a> installed, which is an Add-in for visual studio that gives you the building blocks for developing your plug-in. If you have CodeRush or CodeRush eXpress installed, you already have DXCore. (if you don’t, stop right here, go to <a href="http://www.devexpress.com/crx">http://www.devexpress.com/crx</a> and download CodeRush Xpress, don’t argue! just go!!… but remember to come back ;) )</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Once you have that installed, you’ll have a new Menu called “<strong>DevExpress</strong>”, and from there, starts the fun :D. Click the menu, and choose “<strong>New</strong> <strong>Plugin</strong>”</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh3.ggpht.com/-KkQus0q7a3Y/TlFMIRk0j5I/AAAAAAAABpc/Z0Xdf22PlF0/s1600-h/image%25255B74%25255D.png"><img alt="image" border="0" height="233" src="http://lh5.ggpht.com/-H_X7CXr_8Ms/TlFMJf9KKPI/AAAAAAAABpg/Bep9PAhmwnQ/image_thumb%25255B45%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="272" /></a></div><div style="text-align: justify;"><br /><strong><u>UPDATE:</u></strong>&nbsp;&nbsp;&nbsp; <strong>if you're using CodeRush eXpress, you'll not be able to see the DevExpress menu. Please </strong><a href="http://www.skorkin.com/2010/08/how-to-show-the-devexpress-menu-if-it-is-not-visible/"><strong>check this post by Alex</strong></a><strong> on how to enable it ;)</strong></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; doing that, you’ll get the following window, which allows you to select your Language (we’ll use C#), Plug-in Type (we’ll use the standard), and information about the project (as in any VS project: Name, Location and Solution name)</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh6.ggpht.com/-8kJSYitUca0/TlFMKXwf-GI/AAAAAAAABpk/qhf1l_Pk1LA/s1600-h/image%25255B73%25255D.png"><img alt="image" border="0" height="290" src="http://lh4.ggpht.com/-D83gA8euM8w/TlFMLVKlUjI/AAAAAAAABpo/gXzHOiqPcUM/image_thumb%25255B44%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="465" /></a></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; </div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; by clicking OK, the wizard will give you the following screen for more options that you might want to set for your project:</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh6.ggpht.com/-xandg0-YNvg/TlFMMFZ4r8I/AAAAAAAABps/Wze-l8KyyeQ/s1600-h/image%25255B71%25255D.png"><img alt="image" border="0" height="249" src="http://lh4.ggpht.com/-P4A12DO-KMw/TlFMNE5WUbI/AAAAAAAABpw/qIfiHGMURoI/image_thumb%25255B42%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="353" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: left;">You should click OK on this screen as well, and you’ll be all set.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><strong><u>PS:</u> </strong>I have deliberately omitted to go into detail on the options that you can set in this wizard. However, if you want to delve into that, I recommend the following posts by <a href="http://twitter.com/AlexSkorkin" target="_blank">Alex Skorkin</a> ( a lead developer on CodeRush):</div><ul><li><div style="text-align: justify;"><a href="http://www.skorkin.com/2010/08/dxcore-plug-ins-overview/">DXCore plug-ins overview</a></div></li><li><div style="text-align: justify;"><a href="http://www.skorkin.com/2010/08/how-to-create-a-new-dxcore-plug-in/" target="_blank">How to create a new DXCore plug-in</a></div></li></ul><div style="text-align: justify;"><strong><u>PS2:</u> </strong>There is another way to create a plugin, which is via the <strong>File-&gt;New Project</strong> and look for <strong>DXCore -&gt; Standard Plug-in</strong> (refer to the <a href="http://www.skorkin.com/2010/08/how-to-create-a-new-dxcore-plug-in/">second post by Alex Skorkin</a> for more info)</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Visual Studio will set up your project, and add a “Plugin” element to it, which is kind of a surface where you can put the components of your plugin</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh5.ggpht.com/-FE9LrSITORw/TlFMNndlseI/AAAAAAAABp0/nDaObIZgnsQ/s1600-h/image%25255B70%25255D.png"><img alt="image" border="0" height="218" src="http://lh6.ggpht.com/-0PK_v3vKYNo/TlFMOdjj2HI/AAAAAAAABp4/bgZOBpPPueE/image_thumb%25255B41%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="240" /></a></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; You’ll get this Visual Studio designer which allows you to add components (DXCore components, in our case) to your plugin (PlugIn1.cs).</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><a href="http://lh6.ggpht.com/-h5Gcr-rWUy0/TlFMRrHWvqI/AAAAAAAABp8/6nhI9Y2ssFY/s1600-h/image%25255B69%25255D.png"><img alt="image" border="0" height="373" src="http://lh4.ggpht.com/-ZalGhrFYaK4/TlFMTASCddI/AAAAAAAABqA/-cVY9l4xcH0/image_thumb%25255B40%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="494" /></a></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; For the purpose of this plugin, we’ll add an “<strong>Action</strong>”, which is simply as the name suggests, an “action” that you can start via a keyboard shortcut (which you’ll need to set in the options, more on that later), or a menu command. for more on Actions visit <a href="http://www.skorkin.com/2010/09/dxcore-components-action/" target="_blank">this post by Alex Skorkin</a>.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Se, we add an Action, and set some properties on it, like the component&nbsp;name, the Action Name (which will appear in the shortcut settings page), and a description.</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh6.ggpht.com/-yq8pvcGW2oQ/TlFMTg_C3AI/AAAAAAAABqE/ym5kL-q8Fzk/s1600-h/image%25255B68%25255D.png"><img alt="image" border="0" height="266" src="http://lh5.ggpht.com/-8HkUXRAY_og/TlFMUlj9t-I/AAAAAAAABqI/ZVXT9U8fvZ4/image_thumb%25255B39%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="457" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; now, click on the Events icon, and double click on “Execute”&nbsp; to create and wire up its event handler in the code behind file.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">And now we get to the CODE! </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; So, the steps here are pretty simple. Get the selected portion of text from the active text editor window, make a copy and comment it out, and add the commented part to the top of the selection.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; We start off by getting the ActiveTextView, which simply represents the code editor window you’re currently in when trying to execute the plugin. We can find this in <strong>CodeRush.Documents</strong>. And one thing to note here is that, the "<strong>CodeRush</strong>” object is a key part of the API, it’s basically THE Central object that you’ll end up using all around in your plugins. It is pretty discoverable, and (most of the time) you can find your way around it, for more advanced stuff, check the documentation (or&nbsp;<a href="http://search.devexpress.com/">search it</a>)&nbsp;;). </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; So, we get the <strong>CodeRush.Documents.ActiveTextDocument</strong> and put it in a local variable. We then check if we really have an “Active Text Document”, by doing a null check on our variable.</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh3.ggpht.com/-naKjynHaBZw/TlFMVPh9tCI/AAAAAAAABqM/CKNjE2k97dc/s1600-h/image%25255B67%25255D.png"><img alt="image" border="0" height="76" src="http://lh3.ggpht.com/-R1J6ID4kTrk/TlFMWtF_CLI/AAAAAAAABqQ/d9Fjlnxjg7E/image_thumb%25255B38%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="457" /></a></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Our activeTextDocument has a particular property that we’re interested in, and that is “<strong>ActiveViewSelection</strong>”, so we grab that into a variable, and call an nice little method on it called “<strong>ExtendToWholeLines()</strong>” which, naturally enough, extends our selection to whole lines. </div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh3.ggpht.com/-WfxN-z8yqAI/TlFMYVMcDuI/AAAAAAAABqU/FXgAxvmQXzo/s1600-h/image%25255B66%25255D.png"><img alt="image" border="0" height="55" src="http://lh3.ggpht.com/-CMPvUX87Ock/TlFMZJcxYZI/AAAAAAAABqY/IBqC5mRcopQ/image_thumb%25255B37%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="388" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; You might be wondering, <em>“well, why ‘ActiveViewSelection’? aren’t we already in the active View?”</em>, and the answer is that, we’re in the active <strong>TextDocument</strong>, which can have 2 Views, when you split your editor like this:</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh4.ggpht.com/-qoSkB5A150w/TlFMaBNaPaI/AAAAAAAABqc/6yzZnXjX4uA/s1600-h/image%25255B65%25255D.png"><img alt="image" border="0" height="286" src="http://lh6.ggpht.com/-1FilM27fZqI/TlFMbm8G1vI/AAAAAAAABqg/S5ps3n4kqro/image_thumb%25255B36%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="451" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">and you can achieve this by dragging this little icon in your editor’s top right corner</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh4.ggpht.com/-STl9kdb9rjY/TlFMcswMZNI/AAAAAAAABqk/z_u2DKJ-6Bs/s1600-h/image%25255B64%25255D.png"><img alt="image" border="0" height="74" src="http://lh5.ggpht.com/-HduRwGOBC04/TlFMdaG--OI/AAAAAAAABqo/pKeJaG29gH0/image_thumb%25255B35%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="240" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">That was a long tangent, but I thought it would be useful :)</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Moving on. After we get the selection, we iterate though its “<strong>Lines</strong>” and make a comment from each&nbsp;line, and then concatenate that in a variable (commentedSelection). Now, to do that, we could directly add the “<strong>//</strong>” for a single line comment in C#, but CodeRush has a more intelligent way to do it, in a language agnostic manner, and that is through the <strong>CodeRush.Language.GetComment(string text)</strong> method, which creates a comment from a piece of text in the current language (of the active text document) like so:</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh6.ggpht.com/-wt81adaIyy4/TlFMeSPfbsI/AAAAAAAABqs/sYNGofR5ZQA/s1600-h/image%25255B63%25255D.png"><img alt="image" border="0" src="http://lh4.ggpht.com/-2WejbYt7hDY/TlFMfaOZGRI/AAAAAAAABqw/1W4Pa0AIdho/image_thumb%25255B34%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; After that, all is left to do is actually replacing the active selection with the “commentedSelection” that we just generated, followed by the selection itself:</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh5.ggpht.com/-wPbxMwS2zas/TlFMf52ASlI/AAAAAAAABq0/O4jQrCWM1N0/s1600-h/image%25255B62%25255D.png"><img alt="image" border="0" src="http://lh6.ggpht.com/-DvYRwgQotrg/TlFMgxS9RgI/AAAAAAAABq4/FgxM4RXmztE/image_thumb%25255B33%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; And... that’s pretty much about it! just hit F5 to run! this will launch a new instance of Visual Studio with the plugin that you&nbsp;created loaded into it. When the new instance is up, open/create a project and open a code file.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Now, you might be thinking: "<em>ah, OK, now what?!</em>”, well, remember what we said earlier about “Actions”? we didn’t set ours to show as a Menu command, so we’ll need to set a shortcut for it. Go to the <strong>DevExpress </strong>menu and then to <strong>Options</strong>. In here, click on “<strong>Shortcuts</strong>”, in this page, click “<strong>add a new Keyboard Shortcut</strong>”, set the key combination, select “<strong>CautiousChange</strong>” (or whatever you named your action) from the <strong>Command</strong> dropdown, and then, set the <strong>Context</strong> for this action from the TreeView below that to “<strong>Any Selection</strong>”, then hit OK to save the changes &amp; exit. The following screenshot illustrates the process:</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh3.ggpht.com/-TaECOpPJbe0/TlFMjky7uYI/AAAAAAAABq8/jfh5I4lDH3g/s1600-h/image%25255B59%25255D.png"><img alt="image" border="0" src="http://lh3.ggpht.com/-fXlMO1yJrWM/TlFMleTgaEI/AAAAAAAABrA/iNOnQG7G1WQ/image_thumb%25255B30%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Now, select a bunch of text, and hit the key combination (<strong>Ctrl+Shift+Alt+C</strong>, in my case), and see your plugin in action!</div><div style="text-align: justify;"><br /></div><div style="text-align: center;"><a href="http://lh5.ggpht.com/-44uTCwzkUto/TlFMmdN6lVI/AAAAAAAABrE/omPSFqtC4wA/s1600-h/image%25255B58%25255D.png"><img alt="image" border="0" height="400" src="http://lh3.ggpht.com/-4FRgpA3UUkY/TlFMnLexgyI/AAAAAAAABrI/roSGwM1u1NM/image_thumb%25255B29%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="345" /></a></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Pretty awesome! isn’t it?! And all that was what? 15 lines of code? Speaking of which, here’s the full code for the only method we wrote:</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><pre class="brush:csharp">private void actCautiousChange_Execute(ExecuteEventArgs ea)<br />{<br /> var activeTextDocument = CodeRush.Documents.ActiveTextDocument;<br /> if (activeTextDocument == null)<br /> return;<br /><br /> var selection = activeTextDocument.ActiveViewSelection;<br /> selection.ExtendToWholeLines();<br /><br /> var commentedSelection = Environment.NewLine + CodeRush.Language.GetComment("Old code");<br /> foreach (var line in selection.Lines)<br /> commentedSelection += CodeRush.Language.GetComment(line);<br /> commentedSelection += CodeRush.Language.GetComment("--------------");<br /><br /> selection.Text = commentedSelection + selection.Text;<br /><br /> if(selection.AnchorIsAtEnd)<br /> selection.SwapPoints();<br /> selection.Clear();<br />}<br /></pre></div><div style="text-align: justify;"><style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> </div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; As an exercise for you, dear reader, try figuring out what the last two instructions do ;)</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; And here is the link for <a href="https://github.com/AbdouMoumen/CautiousChange" target="_blank">the project on my Github</a> (which is actually my first time using GitHub! :D)</div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; </div><div style="text-align: justify;">&nbsp;&nbsp;&nbsp; Alright, I hope this made some sense to you. It’s my first tutorial in a looong time, so it might be “rough on the edges”, but I’ll try to get back my writing skills by time ;)</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Here are a few useful links for you:</div><ul><li><div style="text-align: justify;"><a href="http://www.devexpress.com/crx" target="_blank">CodeRush eXpress</a></div></li><div style="text-align: justify;"></div><li><div style="text-align: justify;"><a href="http://www.skorkin.com/" target="_blank">Alex Skorkin’s blog</a> (full of great content)</div></li><div style="text-align: justify;"></div><li><div style="text-align: justify;"><a href="http://www.devexpress.com/Rory" target="_blank">Rory Becker’s blog</a></div></li><div style="text-align: justify;"></div><li><div style="text-align: justify;"><a href="http://www.devexpress.com/Mark" target="_blank">Mark Miller’s blog</a></div></li><div style="text-align: justify;"></div><li><div style="text-align: justify;"><a href="http://tv.devexpress.com/" target="_blank">DevExpress Channel</a></div></li><div style="text-align: justify;"></div><li><div style="text-align: justify;"><a href="http://devexpress.com/Support/Webinars/" target="_blank">DevExpress Webinars</a></div></li><div style="text-align: justify;"></div></ul><div style="text-align: justify;">&nbsp;&nbsp;&nbsp;&nbsp;In the end, make sure you follow <a href="http://www.blogger.com/twitter.com/RoryBecker" target="_blank">@RoryBecker</a> (DevExpress Community Guy), <a href="http://www.blogger.com/twitter.com/MillerMark" target="_blank">@MillerMark</a> (the CodeRush Guru), <a href="http://www.blogger.com/twitter.com/AlexSkorkin" target="_blank">@AlexSkorkin</a> (the CodeRush Dev Lead), and of course, <a href="http://www.blogger.com/twitter.com/AbdouMoumen" target="_blank">@AbdouMoumen</a> (the CodeRush N00b, and yeah, that’s me :P)</div></div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com0tag:blogger.com,1999:blog-1111853785150509287.post-66897142315822459112011-08-16T00:09:00.000-07:002011-08-16T00:09:49.049-07:00DevExpress CodeRush<div dir="ltr" style="text-align: left;" trbidi="on">So, recently, I’ve been having more and more interest in <a href="http://devexpress.com/" target="_blank">DevExpress’</a>s <a href="http://devexpress.com/coderush" target="_blank">CodeRush</a> add-in for Visual Studio. I’ve had CodeRush Xpress installed for some time, but couldn’t use it well because of a certain performance issue. After fixing that issue, by disabling a couple of features that were slowing it down: I’ve been in contact via twitter with <a href="http://twitter.com/RoryBecker" target="_blank">Rory Becker</a> from DevExpress, and he gave me a lot of help with CodeRush, like using its powerful templates and so on. Since then, I found CodeRush to be very powerful productivity tool, and actually kind of fun also, and it helped me save a lot of time.<br /><br />OK, enough with the not-very-important talk. Why am I talking about this anyway? Well, that’s because I’m going to try and post about the cool stuff I find out and learn about CodeRush. Also, since I’m following some <a href="http://tv.devexpress.com/" target="_blank">DevExpress Webinars</a>, especially some of the ones about writing CodeRush Plug-Ins, I’m going to try and post about that, and comment on some examples showing the development step-by-step. CodeRush plug-in development doesn’t seem to be very hard, yet it’s very enjoyable.<br /><br />Important links:<br /><ul><li><a href="http://www.devexpress.com/" target="_blank">DevExpress</a><br /></li>
<li><a href="http://devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/" target="_blank">CodeRush</a>, <a href="http://devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/" target="_blank">CodeRush Xpress</a><br /></li>
<li><a href="http://tv.devexpress.com/" target="_blank">DevExpress Webinars</a><br /></li>
<li><a href="http://code.google.com/p/dxcorecommunityplugins/" target="_blank">CodeRush Community Plug-Ins</a></li>
</ul><br />Make sure you follow <a href="http://www.twitter.com/RoryBecker" target="_blank">@RoryBecker</a> the DevExpress Community guy, <a href="http://www.twitter.com/MillerMark" target="_blank">@MillerMark</a> the DevExpress Guru, and of course <a href="http://www.twitter.com/AbdouMoumen" target="_blank">@AbdouMoumen</a> the CodeRush novice (aka: me :) )</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com0tag:blogger.com,1999:blog-1111853785150509287.post-25238246060641290732011-06-22T04:57:00.001-07:002011-08-01T00:47:25.100-07:00A Lazy blogger is back!<div dir="ltr" style="text-align: left;" trbidi="on">Hello there! (is anybody's there at all?! :P)<br /><br />So, I've been out of the game for a LONG time! A lot of stuff had to do with that, but it's mainly because I've been&nbsp;lazy! I like my posts to be very well written and well thought of, and that calls for a considerable amount of work. On the other hand, I love bloggin! and it feels good and&nbsp;exciting to see my posts pick up interest and have more and more visitors (to whom I hope my posts would be of some help :) )<br /><br />I've had my blog up at "sos.cs-esi.com", which is gone now :P, and since I got my own domain name (cool! :D ) thanks to my dear friend "Waleed Boutemine", I've been planning to start blogging again. And since "the best time to plant an oak tree was 20 years ago, and the second best time to do that is RIGHT NOW", as the saying goes, I just woke up this morning, opened a new post and started typing :)<br /><br />I intend to write about stuff that I find interesting, mainly about technology. This includes, but is not restricted to, talking about new AWESOME technologies, explaining things that I'm learning and deemed to be worth sharing and also maybe&nbsp;some problems that I struggled with along with&nbsp;how I solved them.&nbsp;I haven't yet decided on whether to put "personal" stuff in here or have that in a separate subdomain, but I'll leave that to its time ;)<br /><br />I think this might be enough for a first post (my laziness seems to be creeping in again :P ), so have a nice day, and don't forget to <a href="http://www.twitter.com/AbdouMoumen">follow me on Twitter</a> ;)</div>Abdelmoumen BOUABDALLAHhttps://plus.google.com/117177105474535518948noreply@blogger.com2