Tuesday, 23 October 2007

log4net troubles one among several

After having successfully used log4net to implement a new proxy client ( used nUnit tests to test) I now find myself in some difficulty. Because to test the proxy even further I want to run another program, which uses my Dll to talk to the server.

My first problem is of course that programs are never as loosely coupled as one could wish, and therefore I had to remove some hard coded references from the new test program.

Now that the tests actually run my code, I have a problem with configuring the log4net framework.

First thing is to study the application configuration file a bit, Visual Studio allows you to create a file called app.config by right clicking on the solution title in the solution explorer (the thing usually on the right). This file will then be copied to the bin dir, with the proper name, when the solution is compiled (link).

Solution:
The thing that should be remember is to add the following line somewhere its sure to be called before the log is used:

log4net.Config.XmlConfigurator.Configure()

At least if you are configuring the log4net in the app.config file.

Thursday, 18 October 2007

Sets created by sql joins

Sorry, no explanation only a link to somebody who does explain, with diagrams:

http://www.codinghorror.com/blog/archives/000976.html

Tuesday, 9 October 2007

There Ain't No Such Thing As Plain Text.

Encoding, is always a funny thing when you debug distributed application (also client server architectures). For the simple reason, that you test output from the client, might not look the same from the servers point of view, since there might be differences in the encoding.

So remember to think about, what happens to you request string. remember the following example:

Make a string in any given language:

String testString = "Test string";

to print this to the console, use:

System.out.println(testString) <- println uses a default encoding to print it, the bytes in memory.

When the testString goes through several steps, before it is reached by a server.
First et will be encoded to go on the network (socket), and decoded again by the server. There is therefore 3 different places, that a single debug output, can be different from the what the server actually saves.

The following article describe the very basics of encoding, do you self a favor and read it, or something similar.

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Its easy and very understandable.

Wednesday, 26 September 2007

Drop down list in Excel

I always have a hard time remembering how to make dropdown lists in Excel, her is a nice tutorial of how to do it:
Excel dropdown

And when you make a mistake, as me, this tutorial shows how to edit the list.

edit dropdown

Thursday, 20 September 2007

Playing with sockets in vb.net

I am having trouble with sockets. I send a message and want to retrieve some information. Until now I thought that it was the receive which gave me the problems, but in fact the problem arrives before. Cause the send method throws a SocketException with the text “The attempted operation is not supported for the type of object referenced”.

nb = s.Send(ByteSend, ByteSend.Length, SocketFlags.Peek)

Now this doesn’t really help me. So I looked for the Error code, which were 10045. Looking in the error code list (link) gave me the following additional knowledge (or whatever you want to call this message) :
Windows Sockets Error Codes:

WSAEOPNOTSUPP 10045
Operation not supported.
The attempted operation is not supported for the type of object referenced. Usually this occurs when a socket descriptor to a socket that cannot support this operation is trying to accept a connection on a datagram socket.


Now did that help. I ended giving up on the code so I cant really tell you what the solution is. But for reference, I choose to publish this post anyway. Sorry

Wednesday, 18 July 2007

got on the train of rails

Now its finally time for me starting to read the "Agile Web Development with Reails 2nd ed" so I can be updated at bit on how this rails works, not that there is any job related interest yet, just a wish to try and learn (and to code my secret project).

Anyway to start somewhere I just downloaded ruby 1.8.6 from www.ruby-lang.org where there also is an excellent tutorial called "ruby in 20 min" try it, its nice and fast (link).

Unittesting private methods

I found something that throws an exception in a private method, to make sure I correct it, and it keeps corrected, I would like to write a couple of tests for that method. But its private, so how do I go..

I read the following article, which do describe it for Java, but the same problems apply for vb.net (except I dont know if .net reflection allows one to access private methods like java)
Testing Private Methods with JUnit and SuiteRunner

As you will see, there is no nice way to do it, so I think I will try to rethink the design, and then see if I really need to test a private method.

Finishing with a quote:
In general, you don't want to break any encapsulation for the sake of testing (or as Mom used to say, "don't expose your privates!")

By Dave Thomas and Andy Hunt, in their book Pragmatic Unit Testing.