Apr 27, 2010
VSTS 2010: CodeContracts Issue
- http://social.msdn.microsoft.com/Forums/en/codecontracts/thread/5cb13a3e-811c-45f9-b7a8-09c39979acd6
Mar 4, 2010
Job Invitation Dear
"We have a high growth of demand fordevelopment. A lot of projects are using this technology now. Much more are coming. You have a chance to join the newly formed expertise excellence department that will incorporate the technology experience in it. If you are keen of this technology it is the high time to jump in and take part in tremendous growth of expertise"
Do you feel excited?
Do you feel challenged?
Do you see opportunities?
Me? No, I do not! Do you know why?
Well, the famous Joel Spolsky said about it a lot already. You see, there should be something in the job post. There should be something in the employer, you know? I do not mean that everyone should strive for uniqueness, but trust me - if your company is able to interest someone to work for them only by using the job invitation then they probably can hire anyone to work with you.
Remember the quote in the beginning? How about this one?
"We have a high growth of demand fordevelopment [in the universe]. A lot of projects are using this technology now [in the universe]. Much more are coming [guess where to? to the universe]. You have a chance to join the newly formed expertise excellence department [in the universe] that will incorporate the technology experience in it. If you are keen of this technology it is the high time to jump in and take part in tremendous growth of expertise [in the universe]"
Does it sound somehow differently? You see, nothing has changed since I added the company name (the universe). The context did not change. The meaning left the same. There should be a difference. It just should be. If it does not, you lose. Because this is just the name, the name of your company is the only thing that makes your company different. This is it.
Jan 24, 2010
User Interface Design and Architecture
- Presentation Zen and the book's web site (www.presentationzen.com)
- "The Inmates Are Running the Asylum" by Alice Cooper
Update: 04/10 - Added "color" articles' links
Aug 20, 2009
Test more, document less
- testers study functionality by using it, not making guesses from documentation
- we reduce risks failing the deadlines by performing additional verification
- we reduce risks of deployment failures, as we do it more often
- testing takes the same time as it would take it we did regular "develop, then verify" process
- now we can think how we can make our documentation more efficient, so it would not go on retirement
Aug 19, 2009
Open Source and Commercial Software
One of the "benefits" of commercial products sounds similar to the following:
commercial product has support so I know whom to contact when I will be trouble (be sure you will %99), while open source has no support
OK, while this may be true think of the followin please: do you compare equal products. I can think of both products as equal when I have commercial product on one side and open source product with active development on the other. Assuming open source is in active development I can conclude it has the very support we did not saw earlier, hasn't it?
The other argument, again:
commercial product has support that can promise me a deadline...
Yeah, guys, do you really think that something is different with planning in open source software? I guess not. The planning is done as we usually do for our projects. Same ideas applies to the mighty commercial software we tend to buy instead of using the one that is useful and at no cost.
Anyway, it is your choice. Just think of it, please.
Nov 13, 2008
Double Dispatch Principle or the "Shit Hits the Fun"
The other day I was thinking about Double Dispatch Principle and it's benefits and came up with the following code sample:
public class Air
{
}
public class Fun
{
public void Run(Air air)
{ }
}
public class Sheet : Air
{
public void Hit(Fun theFun)
{
theFun.Run(this);
}
}
public class Program
{
public void Process()
{
var theFun = new Fun();
new Sheet().Hit(theFun);
}
}
Oct 14, 2008
Tricky Path.Combine Thing
About 10 minutes I needed to understand the problem. Luckily I had tests. It appears, that Path.Combine works funny. Here are a comple of examples:
- If you do Path.Combine("../Tests/", "/123.xml") the result will be "/123.xml"
- If you do Path.Combine("../Tests/", "123.xml") the result will be "../Tests/123.xml"
- Finally, if you do Path.Combine("../Tests", "123.xml") the result will be "../Tests\123.xml"
Oh, frankly speaking, I would really like to have Path.Combine("../Tests/", "/123.xml") give me "../Tests/123.xml" or, at least, "../Tests//123.xml" and even "../Tests\123.xml" would be fine.
For now, I have to remember funny point #1 and will try to do #2 and #3 all along.
Oct 7, 2008
XML in .Net: Frequently Asked Questions
XML Team started to blog about most difficult things in System.XML. The list of posts below:
- Exceptions About Invalid Literals in XML - FAQ on XML in .Net - Part 1
- Working with XML Fragments - FAQ on XML in .Net - Part 2
Hope this helps!
Test Requirements First
Today I found a post about The Compare Contract by BCL Team. In brief, one of the customers complained about the breaking changes made in SP1 compared to RTM version. Actually, the ComparedTo method of the StringWrapper class was changed which affected sorting behavior.
It appeared that ComparedTo method was implemented incorrectly. Therefore, it was decided to change it. MSDN describes several requirements that must be met by a particular implementation of IComparable<T> interface.
I see this as a big bonus for any developer implementing IComparable<T> interface. Even before starting to implement the method you can write very strict Unit Tests that will help you to implement a method that will satisfy common requirements for any sorting algorithm.
As you see, you can end up with 5 unit test. If you will use MbUnit, for example, you can employ Row Tests to specify more precise requirements for your interface implementation very easy.
For example I ended up with 15 tests. It took me about 15 minutes. Here they are:
namespace CompareToContract.UnitTests
{
using MbUnit.Framework;
[TestFixture]
public class StringWrapperTests
{
[RowTest]
[Row("")]
[Row("value")]
[Row(null)]
public void CompareTo_SameValue_ShouldReturnZero(string value)
{
StringWrapper wrapper = new StringWrapper() { Value = value };
Assert.AreEqual(wrapper.CompareTo(wrapper), 0, "A.CompareTo(A) should return 0.");
}
[RowTest]
[Row("", "")]
[Row("value", "value")]
[Row(null, null)]
public void CompareTo_AnotherEqualValue_ShouldReturnZero(string value1, string value2)
{
StringWrapper a = new StringWrapper() { Value = value1 };
StringWrapper b = new StringWrapper() { Value = value2 };
Assert.AreEqual(a.CompareTo(b), 0, "A'value'.ComparedTo(b'value') should return 0.");
}
[RowTest]
[Row("", "", "")]
[Row("value", "value", "value")]
[Row(null, null, null)]
public void CompareTo_AandBandCequal_ShouldReturnZero(string value1, string value2, string value3)
{
StringWrapper a = new StringWrapper() { Value = value1 };
StringWrapper b = new StringWrapper() { Value = value2 };
StringWrapper c = new StringWrapper() { Value = value3 };
Assert.AreEqual(a.CompareTo(b), 0, "A'value'.ComparedTo(B'value') should return 0.");
Assert.AreEqual(b.CompareTo(c), 0, "B'value'.ComparedTo(C'value') should return 0.");
Assert.AreEqual(a.CompareTo(c), 0, "A'value'.ComparedTo(C'value') should return 0.");
}
[RowTest]
[Row("1", "2")]
[Row("value1", "value2")]
[Row(null, "1")]
public void CompareTo_IfAComparedToBReturnValueThenBComparedToA_ShouldReturnSameValueButDifferentInSign(string value1, string value2)
{
StringWrapper a = new StringWrapper() { Value = value1 };
StringWrapper b = new StringWrapper() { Value = value2 };
Assert.AreEqual(a.CompareTo(b), -1 * b.CompareTo(a), "a.ComparedTo(b) should equal to -1 * b.ComparedTo(a).");
}
[RowTest]
[Row("1", "2", "3")]
[Row("value3", "value2", "value1")]
[Row("value1", "value2", "value3")]
public void CompareTo_IfAComparedToBReturnsValueWithTheSameSignAsBComparedToCThenACompareToC_ShouldReturnValueWithTheSameSign(string value1, string value2, string value3)
{
StringWrapper a = new StringWrapper() { Value = value1 };
StringWrapper b = new StringWrapper() { Value = value2 };
StringWrapper c = new StringWrapper() { Value = value3 };
int abResult = a.CompareTo(b);
int bcResult = b.CompareTo(c);
int acResult = a.CompareTo(c);
Assert.IsTrue(Math.Sign(abResult) == Math.Sign(bcResult), "A.ComparedTo(B) should have the same sign as B.ComparedTo(C).");
Assert.IsTrue(Math.Sign(abResult) == Math.Sign(acResult), "A.ComparedTo(C) should have the same sign as A.ComparedTo(B).");
}
}
}
The old implementation of CompareTo completed with 10 succeeded and 5 failed tests. While implementation provided by BCL Team completed with all 15 succeeded. This way I can trust this implementation of CompareTo method.
Conclusion
Test your requirements before you right the code. This will minimize your time and efforts to understand (remember all the time) requirements of implementation and will help you to write the code you need, not the code you can write.
Hope this helps!
Aug 26, 2008
WCF+WSE Using Anonymous Certificate Security
I am not an expert in neither WCF nor WSE, however, recently I have been busy implementing WCF service that could be consumed by WSE client. And the requirement for this was to use Anonymous For Certificate Security protection of messages.
As always I started from Google... However, after spending about 4 to 6 hour I get nothing except examples that was not working.
Therefore, here, I decided to describe the implementation of, both, service and client.
Anonymous for Certificate Security In a Nutshell.
Basically, to protect your messages with certificates you need to do a number of things:
- first of all, you need to have certificate (*.cer file) and private key for it (*.pfx file)
- second, you need to install certificate (*.cer file) on a client computer - which will be used to connect to your WCF service into LocalMachine certificate store
- then, you need to install both certificate (*.cer file) and private key (*.pfx) file on a server where WCF service will be installed into the LocalMachine certificate store
- lastly, on a server where WCF service will be installed you need to grant an identity, under which WCF will be running, permissions to access your certificates' private key
The way Anonymous for Certificate Security mechanisms work is very simple - the same way as Encryption Algorithms with Open Key works. The certificate (*.cer file) will be used by client as public key to sign and encode his requests to the service and decode response from the service. The service, in it's turn, will be using private key (*.pfx file) to encode / decode messages.
In this way, it will be impossible to give client a fake service, because only service has private key. However, anything can be a client of a service as soon as it encodes and decodes messages using public key (*.cer file).
WCF Service Implementation.
In order to connect WSE and WCF could understand each other they need to talk the same security protocol. Therefore, I set message security version of service binding to "WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10".
Also, made service and client both you MTOM messaging. Message version should be set to "Soap11WSAddressingAugust2004" by the reason explained earlier.
Next things you need to do is to configure your service behaviour, of course. This is very simple to do as well. You need to add
After this is done, you need to configure your service interface to use message contract and create request and response messages for every method on your service interface. Then implement your service. If something was not configured properly your service will not run.
WSE Client Implementation.
First of all, you need to create a proxy for you WCF service. This is very simple to accomplish using wseWsdl3.exe utility that will be installed along with WSE3.0 installation package.
After you did that, you need to create a WSE policy to access WCF service. You can do in configuration file or in code. It does not matter. What you need to do is to configure AnonymousForSecurity assertion and configure your proxy to use certificate you installed as credentials to access WCF service.
Do not forget to configure WSE to use MTOM messaging as well.
Links
There are lots of resources on the web that can give you some food for thought when dealing with peculiarities of this integration including Microsoft Forums and personal blogs. However, I would recommend to check WCF Security Guidance on CodePlex. This is the place where you will find a lot of information about WCF security and How-Tos.
Hope this helps!