Continuous Integration in Munich
November 23, 2011 on 3:57 pm | In Uncategorized | No CommentsHardy Erlinger, the head of .NET Developers Group München, has just confirmed my session in Munich, Germany. I will be speaking about Continuous Integration in .NET at January 17th. The meeting will take place probably as usual in Firma TESIS at Baierbrunner Str. 15, 81379 München. Start 18:00. Details will be available at the group website www.munichdot.net. Acha, the talk will be in German!
Continuous Integration in .NET book MEAP update
January 21, 2010 on 6:11 pm | In Uncategorized | No Comments
There are two new chapters available at Manning MEAP site. The third one about build process automation (with MSBuild) and the forth one about choosing the right CI server (covering CCNet, TeamCity and TFS 2010).
And wow the book is third on this weeks bestselling early access titles. Juhu!
Everyone is entitled to broad opinion
October 26, 2008 on 8:18 pm | In Uncategorized | No CommentsI had an interesting dispute with my colleague weather to use only qualified type names in code or not. He insisted that we should not use the using directive to introduce a namespace but to write the fully qualified name every time it is necessary. I had quite opposite opinion but I agreed to give it a try. So I started to write
public class MyClass { public static void Main() { System.Console.WriteLine("Foo"); } }
instead of
using System; public class MyClass { public static void Main() { Console.WriteLine("Foo"); } }
Unfortunately over time it proofed no value to me. I was not happy with this rule, but I thought I’ll consult the brother audience for opinion before I start a holly war against something that I might not fully understand.
I decided to give stackoverflow.com a try. It is quite new Q&A Service dedicated specially for software developers. I write my question I was given a flood of answers. Some better, some worse. Some hitting the bottom line, some pouring “divine knowledge” of individuals that think they know things better.
Nevertheless the discussion on stackoverflow.com helped my back my opinion. Give it a try!
MTS 2008, Warsaw, Poland
October 12, 2008 on 10:28 pm | In Uncategorized | No CommentsMicrosoft Technology Summit 2008 (8th and 9th November), the biggest Microsoft technology event in Poland went quite well. It was my first MTS and I was trying not to expect anything special. And indeed I haven’t experienced anything earth shaking but altogether it was quite interesting and a good investment of time. I surely learned a few new things and meet interesting people there. I was astonished by the sheer number of attendees that gathered in there. I presume the old communist “castle” in the center of Warsaw the “Palace of Culture and Science” was the only place to accommodate this whole crowd, but it is not a cushy place. It’s big and cold and far from perfect to host a technology event like that. And well… despite the overwhelming size of this place, you almost have to eat you lunch on the floor, because there was no eno
ugh tables
But I passed the 70-543 Exam there and gained the Microsoft Certified Professional Developer in ASP.NET title. So altogether it was a full success!
What null smaller than 0? Adventures with nullable types in .NET
September 9, 2008 on 9:14 pm | In Uncategorized | No CommentsLets say we have two nullable integers like this:
int? i = null; int? j = 0;
Is null smaller than 0
Console.WriteLine(i < j);
False – no it is not.
So probably null is greater than 0
Console.WriteLine(i > j);
False – no it is not greater as well.
All right! So null is equal 0. It has to be, JIT has no other choice, right?
Console.WriteLine(i == j);
Well False too! This two little fellows are not equal too. What? Is it raining frogs and we about to experience Armageddon?
No! We have to use Nullable.Compare() and we will by back in normal world:
switch (Nullable.Compare(i, j)) { case -1: Console.WriteLine("i < j"); break; case 1: Console.WriteLine("i > j"); break; case 0: Console.WriteLine("i == j"); break; }
0 is a little more than null. null is less than 0. null equals null and 0 equals 0.
Uff!
Enum Factory
August 10, 2008 on 9:16 pm | In Uncategorized | 2 CommentsI have a little tip for you. Let’s say you have an enumeration. You need a enumeration constant out of string variable. simply use System.Enum.Parse(). Here a small Snippet Compiler source code.
using System; using System.Collections.Generic; public class MyClass { public enum FooBar { Foo, Bar, FooBar }
public static void Main() { WL(FooBarFactory("Foo")); RL(); } public static FooBar FooBarFactory(string init) { try { return (FooBar)System.Enum.Parse(typeof(FooBar), init); } catch { // Do something throw; } } #region Helper methods private static void WL(object text, params object[] args) { Console.WriteLine(text.ToString(), args); } private static void RL() { Console.ReadLine(); } private static void Break() { System.Diagnostics.Debugger.Break(); } #endregion }
Aiding your work with Visual Studio Code Snippets
April 16, 2008 on 7:35 pm | In Uncategorized | 2 CommentsI’ve bin writing //TODO comments in my code every time wondering what pattern have we agreed upon in our team. Was it a
// TODO Recipient Priority Sender, Message
or
// TODO Priority Sender Recipient, Message
or something else.
Today I thought: who am I to remember all those dentils? Do I have something to help me with this burning problem?
Well I have. The name is Visual Studio Code Snippet. It in a XML file that describes a quickly insertable text. With such XML description I will by able to write only a word “todo” in my VS and everything else will happen automagically. There will by a nicely highlighted input places allowing me to navigate with a Tab key to complete my //TODO comment.
Here is how to create such file:
1. create a XML file with snippet extension
2. the root element name is CodeSnippets
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <!--Insert code snippets here--> </CodeSnippets>
3. insert one or more code snippets in a tag named CodeSnippet
<CodeSnippet Format="1.0.0"> <Header> <!--Header tags--> </Header> <Snippet> <!--Snippet tags--> </Snippet> </CodeSnippet>
4. define your header
<Header> <Title>ToDo Comment</Title> <Shortcut>todo</Shortcut> <Description>Inserts todo comment</Description> <Author>Marcin Kawalerowicz</Author> </Header>
The Shortcut tag is interesting. With this tag you will by able to define a short cut that will trigger your snippet. After this definition you will by able to write simply “todo” in your VS, then press Tab key an the magic will happen.
5. Define your Snippet
<Code Language="CSharp"> <![CDATA[// TODO $Recipient$ $Prio$ $Sender$, $Message$]]> </Code>
6. Do you see the variables between $ you have to declare them too
<Declarations> <Literal> <ID>Sender</ID> <ToolTip>ToDo sender</ToolTip> <Default>??</Default> </Literal> <Literal> <ID>Recipient</ID> <ToolTip>ToDo recipient</ToolTip> <Default>??</Default> </Literal> <Literal> <ID>Prio</ID> <ToolTip>Priority</ToolTip> <Default>0</Default> </Literal> <Literal> <ID>Message</ID> <ToolTip>Message</ToolTip> <Default>!</Default> </Literal> </Declarations>
7. Voila you are ready. You have to import this file to Visual Studio using Tools -> Code Snippet Manager… and the Import… button.
Now press Ctrl+K+X and you can browse to your new snippet or write simply “todo” and press Tab to see something like this:
Here is a complete code of our snippet (with NOTE comment snippet a a bonus
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title> - NOTE Comment </Title> <Shortcut>note</Shortcut> <Description>Inserts note comment</Description> <Author>Marcin Kawalerowicz</Author> </Header> <Snippet> <Declarations> <Literal> <ID>Message</ID> <ToolTip>Message</ToolTip> <Default>!</Default> </Literal> <Literal> <ID>Sender</ID> <ToolTip>Sender</ToolTip> <Default>??</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[// NOTE $Sender$, $Message$]]> </Code> </Snippet> </CodeSnippet> <CodeSnippet Format="1.0.0"> <Header> <Title> - ToDo Comment </Title> <Shortcut>todo</Shortcut> <Description>Inserts todo comment</Description> <Author>Marcin Kawalerowicz</Author> </Header> <Snippet> <Declarations> <Literal> <ID>Sender</ID> <ToolTip>ToDo sender</ToolTip> <Default>??</Default> </Literal> <Literal> <ID>Recipient</ID> <ToolTip>ToDo recipient</ToolTip> <Default>??</Default> </Literal> <Literal> <ID>Prio</ID> <ToolTip>Priority</ToolTip> <Default>0</Default> </Literal> <Literal> <ID>Message</ID> <ToolTip>Message</ToolTip> <Default>!</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[// TODO $Recipient$ $Prio$ $Sender$, $Message$]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
I’m sure you don’t care…
January 12, 2008 on 10:54 am | In Uncategorized | No Comments
… but I’m very glad so I share
I’ve just became a MCTS – Microsoft Certified Technology Specialist in ASP.NET. I passed the 70-536 and 70-528 (with quite good marks). Now I’m starting to learn to became Professional Developer (exam 70-547). Wish my luck!
Language doesn’t matter
December 31, 2007 on 12:27 am | In Uncategorized | 1 Comment
My father is a land-surveyor (geodesist if you will). Nowadays he uses a notebook for his field measurements, but there was a time when he used a scientific calculator. Recently he’s notebook went dead, so he wanted to move back to his Casio scientific calculator. But, ups! Not in use for a while the battery ran out and the geodetical programs are gone. So I have to type my old programs back to the small computer. I thought I’ll share one of them as a example that programming language does not matter. What matters is how you use it and how well others could use your work. So let my share small app that I wrote back in high school for my fathers Casio fx-4500P Scientific Calculator.
A"X":B"Y":C"X":D"Y"
G=A:H=B:I=D
P=0
Lbl 1
{E}"X":{F}"Y"
E=0=>Goto 2 ∆
P=P+C*(F-B)
A=C:B=D:C=E:D=F
Goto 1
Lbl 2
P=(P+C*(H-B)+G*(I-D))/2
P:"P"▲
Voila! You can calculate a polygon field. So quit the holly "C# vs VB" war. Both are good. Very good
It’s not magic – it’s floating point math
December 26, 2007 on 4:29 pm | In Uncategorized | No CommentsPlease remember that 3 / 12 is not always 0.25!
Take this example:
int i = 3; Console.WriteLine(i / 12);
You will get 0. I admit it could by a little confusing at first but I assure you, there is nothing wrong in the way JIT thinks. We dividing an integer over a… integer. What we are getting? Well, of course an integer! Is it not what you expected? How to fix this? Well the easiest way is to:
int i = 3; Console.WriteLine(i / 12.0);
You will get 0.25. Why? Well 12.0 is a double so the whole equation will by a double. You can check this easily with:
object o = i / 12; Console.WriteLine(o.GetType()); o = i / 12.0; Console.WriteLine(o.GetType());
So we all have to pay for strong typing and it is in your best interest to remember that!
By the way
int i = 3; int zero = 0; Console.WriteLine(3 / 0); Console.WriteLine(3 / zero); Console.WriteLine(3.0 / zero); Console.WriteLine(3.0 / 0);
3/0 won’t compile. 3/zero will throw an exception. 3.0/zero and 3.0/0 compile an run without a problem, they return +Infinity.
Oh, and one more thing (from my financial world of knowledge). 10% equals sometimes 11%!
int fullPrice = 100; float discount = 0.1F; Int32 finalPrice = (int)(fullPrice * (1-discount)); Console.WriteLine("The discounted price is ${0}.", finalPrice);
You will find this and other examples in good article about Floating Point in .NET.
Powered by WordPress with Pool theme design by Borja Fernandez.
Text © Marcin Kawalerowicz. Hosting CODEFUSION.


