<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8619358898227991199</id><updated>2026-01-05T18:05:13.450+02:00</updated><category term="Relax"/><category term="Books"/><category term="Programming"/><category term=".Net"/><category term="English"/><category term="Testing"/><category term="Windows"/><category term="Fun"/><category term="NUnit"/><category term="Україна"/><category term="Dependency Injection"/><category term="Fail"/><category term="Finance"/><category term="Hudson"/><category term="MSpec"/><category term="NHibernate"/><category term="NuGet"/><category term="RTF"/><category term="ServiceStack"/><category term="Sql"/><category term="Tip"/><category term="UI"/><category term="Vim"/><category term="Vista"/><category term="log4net"/><title type='text'>Ivan&#39;s Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-3767525783114954868</id><published>2012-08-26T23:19:00.000+03:00</published><updated>2012-09-25T12:00:41.116+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="ServiceStack"/><title type='text'>ServiceStack: Reusing DTOs</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;UPDATE:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
This post is no longer relevant, because these ideas were included into the heart of the ServiceStack &lt;a href=&quot;https://github.com/ServiceStack/ServiceStack/wiki/New-API&quot;&gt;New API&lt;/a&gt;. It just a pleasure to use such a great framework!&lt;/blockquote&gt;
&lt;br /&gt;
I&#39;ve recently worked on HTTP API for one of our products. As it was a bit of time&amp;nbsp;pressure, we&#39;ve decided to use &lt;a href=&quot;http://servicestack.net/&quot;&gt;ServiceStack&lt;/a&gt;&amp;nbsp;- an open source web services framework. If you didn&#39;t hear about it go ahead and &lt;a href=&quot;https://github.com/ServiceStack/ServiceStack/wiki&quot;&gt;read&lt;/a&gt;. It is simple yet very powerful, well written framework which just works and makes things done without friction. And it exists for years already (if you would ask why not we were using Web API, which was not yet released at the moment).&lt;br /&gt;
&lt;br /&gt;
I&#39;d like to share some experience gained during my work. So here is the context. The first consumer of API will be our another project having&amp;nbsp;back-end&amp;nbsp;written in C# as well. ServiceStack allows to provide clients with strongly-typed assembly reusing the same requests/responses dtos used to build service (note that no code generation is needed). In fact this is &lt;a href=&quot;https://github.com/ServiceStack/ServiceStack/wiki/Clients-overview&quot;&gt;recommended approach&lt;/a&gt; for C# clients.&lt;br /&gt;
&lt;br /&gt;
The preferred way to call web service is to utilize &lt;a href=&quot;https://github.com/ServiceStack/ServiceStack/wiki/Endpoints&quot;&gt;REST endpoints&lt;/a&gt;, which can be configured using RestService attribute per each request DTO.&amp;nbsp;Example below (&lt;a href=&quot;https://gist.github.com/3482626&quot;&gt;here is a gist&lt;/a&gt;) shows how we can call services via REST endpoints, and how DTOs are reused.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp; gutter: false;&quot;&gt;/// DTOs

[RestService(&quot;/orders/{id}&quot;, &quot;GET&quot;)]
[RestService(&quot;/orders/by-code/{code}&quot;, &quot;GET&quot;)]
[RestService(&quot;/orders/search&quot;, &quot;GET&quot;)]
public class GetOrders {
    public int? Id { get; set; }
    public string Code { get; set; }
    public string Name { get; set; }
    public string Customer { get; set; }
}

public class GetOrdersResponse {
    public Order[] Orders { get; set; }
    public ResponseStatus ResponseStatus { get; set; }
}
    
public class Order {
    public int Id { get; set; }
    public string Code { get; set; }
    public string Name { get; set; }
    public string Customer { get; set; }
}

[RestService(&quot;/orders&quot;, &quot;POST&quot;)] // to create new order.
[RestService(&quot;/orders/{id}&quot;, &quot;PUT&quot;)] // to create or update existing order with specified Id.
public class SaveOrder {
    public int? Id { get; set; }
    // Order details.
}

public class SaveOrderResponse {
    public int Id { get; set; }
    public ResponseStatus ResponseStatus { get; set; }
}


//// Rest endpoints usage

IRestClient client = new JsonServiceClient();

var orderById = client.Get&amp;lt;GetOrdersResponse&amp;gt;(&quot;/orders/&quot; + 5).Orders.Single();
var orderByCode = client.Get&amp;lt;GetOrdersResponse&amp;gt;(&quot;orders/by-code/&quot; + Uri.EscapeDataString(orderById.Code)).Orders.Single();

var searchUrl = &quot;orders/search?Name={0}&amp;amp;Customer={1}&quot;.Fmt(
    Uri.EscapeDataString(orderByCode.Name), Uri.EscapeDataString(orderByCode.Customer));

var foundOrders = client.Get&amp;lt;GetOrdersResponse&amp;gt;(searchUrl).Orders;

var createOrderResponse = client.Post&amp;lt;SaveOrderResonse&amp;gt;(&quot;/orders&quot;, new SaveOrder { /* Order details */});
int orderId = createOrderResponse.Id;
var updateOrderResponse = client.Put&amp;lt;SaveOrderResonse&amp;gt;(&quot;/orders/&quot; + orderId, new SaveOrder { /* Order details */ });
&lt;/pre&gt;
&lt;br /&gt;
Notice that dtos follow naming convention - response classes named exactly like request classes but with&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Response&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; prefix. This simplifies clients life, as it becomes obvious what response is expected. It also allows to generate &lt;a href=&quot;https://github.com/ServiceStack/ServiceStack/wiki/Metadata-page&quot;&gt;services metadata&lt;/a&gt;&amp;nbsp;automatically.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
However, there are several things that bothers me here. While I still want clients to call services via REST endpoints, I&#39;d like to have more generic and easy to follow api. Here are things that come to mind:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Whether we really need to specify Response type, while we already know what kind of request we send. Couldn&#39;t we automatically determine it by the request type?&lt;/li&gt;
&lt;li&gt;We already know urls available for given request type (from RestService attributes). It would nice if we can simplify developers life by picking and populating them automatically based on request state.&lt;/li&gt;
&lt;li&gt;We can go further and automatically determine required HTTP method.&lt;/li&gt;
&lt;li&gt;And last - for GET and DELETE request we could send additional request properties (not mapped in url template) as query parameters.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
As side effect of achieving this, we&#39;ll get another important benefit - ability to change Urls and even Http methods without breaking clients code. And this is essential for me - I&#39;m sure I would like to change some Urls while it used by our other product only (but before it goes public).&lt;br /&gt;
&lt;br /&gt;
So this is a method I&#39;d like to have:&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;IRestClient.Send&amp;lt;TResponse&amp;gt;(IRequest&amp;lt;TResponse&amp;gt; request)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
where IRequest - is just a marker interface applied to all request types, thus allowing to determine corresponding response type at compile time. And this is how our example will looks like (&lt;a href=&quot;https://gist.github.com/3483088&quot;&gt;here is the gist&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp; gutter: false;&quot;&gt;// Response types omitted.
// Note that request types now marked with IRequest&amp;lt;tresponse&amp;gt; interface.
// This allows Send method to determine response type at compile time.

[RestService(&quot;/orders/{id}&quot;, &quot;GET&quot;)]
[RestService(&quot;/orders/by-code/{code}&quot;, &quot;GET&quot;)]
[RestService(&quot;/orders/search&quot;, &quot;GET&quot;)]
public class GetOrders : IRequest&amp;lt;GetOrdersResponse&amp;gt; {
    public int? Id { get; set; }
    public string Code { get; set; }
    public string Name { get; set; }
    public string Customer { get; set; }
}
    
[RestService(&quot;/orders&quot;, &quot;POST&quot;)] // to create new order.
[RestService(&quot;/orders/{id}&quot;, &quot;PUT&quot;)] // to create or update existing order with specified Id.
public class SaveOrder : IRequest&amp;lt;SaveOrderResonse&amp;gt; {
    public int? Id { get; set; }
    // Order details.
}

//// Proposed interface

// Marker interface allowing to determine response type at compile time.
public interface IRequest&amp;lt;TResponse&amp;gt; {
}

public static class RestServiceExtensions
{
    public static TResponse Send&amp;lt;TResponse&amp;gt;(this IRestClient client, IRequest&amp;lt;TResponse&amp;gt; request) {
        // Determine matching REST endpoint for specified request (via RestService attributes).
        // Populate url with encoded variables and optional query parameters.
        // Invoke corresponding REST method with proper Http method 
        // and return strongly typed response
    }
}


//// Service usage

IRestClient client = new JsonServiceClient();

// We don&#39;t specify response type - it is determined automatically based on request type.
// We don&#39;t specify URLs or HTTP verbs - they are determined based on request state.
// We don&#39;t write boilerplate code to encode url parts. It is done automatically.

// GET /orders/5
var orderById = client.Send(new GetOrders { Id = 5 }).Orders.Single(); 

// GET /orders/by-code/Code
var orderByCode = client.Send(new GetOrders { Code = orderById.Code }).Orders.Single();

// GET /orders/search?Name=Name&amp;amp;Customer=Customer
var getOrders = new GetOrders { Name = orderById.Name, Customer = orderByCode.Customer };
var foundOrders = client.Send(getOrders).Orders;

// POST /orders
var createOrderResponse = client.Send(new SaveOrder { /* Order details */});

// PUT /orders/id
int orderId = createOrderResponse.Id;
var updateOrderResponse = client.Send(new SaveOrder { Id = orderById.Id, /* Order details */ });
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
That being said, I&#39;ve implemented such extension method for IRestService interface. You can find source code with a test in a &lt;a href=&quot;https://gist.github.com/3483193&quot;&gt;gist at github&lt;/a&gt;. There are several things missed there, but they should not be hard to implement:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Same extension for Async service.&lt;/li&gt;
&lt;li&gt;Special formatting for DateTime, List variables in url.&lt;/li&gt;
&lt;li&gt;Other opinionated decisions on how to choose url when several urls matches specified request.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Hope you find this useful. Anyway, please let me know event if it feels like completely wrong approach.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/3767525783114954868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/3767525783114954868' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3767525783114954868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3767525783114954868'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2012/08/servicestack-reusing-dtos.html' title='ServiceStack: Reusing DTOs'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-9138941227766502752</id><published>2011-08-26T18:43:00.001+03:00</published><updated>2011-08-26T18:46:47.343+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RTF"/><title type='text'>Reducing size of RTF file with image</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
We use RTF format to generate documents in our products as it is widely supported by software vendors. The bad thing about RTF files is a file size, which drastically increases&amp;nbsp;when document contains images&amp;nbsp;(compared to&amp;nbsp;the&amp;nbsp;same document saved in &quot;doc&quot; format). This becomes a big &amp;nbsp;issue when you have hundreds of thousands documents stored in a databases, and&amp;nbsp;send&amp;nbsp;them to other parties.&lt;br /&gt;
&lt;br /&gt;
As it turned out, the file size issue is not caused by RTF format itself, but by the way MS Word saves RTF files with images. When MS Word saves document in RTF format, it saves two copies of each image - original one and also a copy converted to WMF format.&amp;nbsp;Fortunately, there is way to disable such a strange behavior. You can read how at Microsoft&amp;nbsp;knowledge&amp;nbsp;base article&amp;nbsp;&lt;a href=&quot;http://support.microsoft.com/kb/224663&quot;&gt;Document file size increases with EMF, PNG, GIF, or JPEG graphics in Word&lt;/a&gt;.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/9138941227766502752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/9138941227766502752' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/9138941227766502752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/9138941227766502752'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2011/08/reducing-size-of-rtf-file-with-image.html' title='Reducing size of RTF file with image'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-7721257068120877987</id><published>2011-08-17T01:43:00.004+03:00</published><updated>2012-02-21T11:12:15.678+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="NuGet"/><title type='text'>Using NuGet to download all packages for the solution</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here I&#39;m talking about technique which allows you to &lt;a href=&quot;http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages&quot;&gt;use NuGet without&amp;nbsp;committing&amp;nbsp;packages to source control&lt;/a&gt; (which is handy in case you use Mercurial). First time I&#39;ve heard about this approach from &lt;a href=&quot;http://joseoncode.com/2011/05/31/nuget-keep-your-package-folder-out-of-your-cvs/&quot;&gt;José F. Romaniello post&lt;/a&gt;. In essence: each project within solution has a pre-build step ensuring that all packages are downloaded via NuGet.exe command line utility. While this approach works well for a small project, it has some drawbacks with large solutions:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;It forces me to insert that build step into each project within solution, which is a little bit annoying.&lt;/li&gt;
&lt;li&gt;It increases solution build time. This becomes visible for a solution containing a lot of projects. I guess that was one of the main reasons why &lt;a href=&quot;http://simoncropp.posterous.com/introducingpepitaget&quot;&gt;Simon Cropp wrote this post&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
So, do I really need to check for NuGet packages on each build? It think that checking for dependencies at CI server, and perhaps after pulling changes from source control might be enough.&lt;br /&gt;
&lt;br /&gt;
To achieve this I use a Powershell &lt;a href=&quot;https://gist.github.com/1150094&quot;&gt;script&lt;/a&gt; which looks for packages.config files within a solution and executes NuGet.exe for each of them.&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1150094.js&quot;&gt;
 
&lt;/script&gt;
&lt;br /&gt;
This script uses repositories.config file to locate packages.config files instead of searching them in file system. Obviously to make it work, repositories.config should be placed in source control and path variables should be adjusted according to the solution folders structure.&lt;br /&gt;
&lt;br /&gt;
Hope you find this post helpful. At least I&#39;ve learned some new things about powershell :). Please share your thoughts.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/7721257068120877987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/7721257068120877987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/7721257068120877987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/7721257068120877987'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2011/08/using-nuget-to-download-all-packages.html' title='Using NuGet to download all packages for the solution'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-5478927868346676581</id><published>2011-03-06T14:49:00.000+02:00</published><updated>2011-03-06T14:49:17.163+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Relax"/><title type='text'>Великий піст 2011.</title><content type='html'>Наступний тиждень доведеться холостякувати, ще й грошей залишилось 200 грн. Що ж, саме вчасно наступає Великий піст в цьому році.&lt;br /&gt;
&lt;br /&gt;
Якщо хтось теж збирається постити, то ось схема із сайту &lt;a href=&quot;http://www.sestry.ru/church/content/velpost2011/index&quot;&gt;sestry.ru&lt;/a&gt;, яка допомагає розібратися що можна їсти і коли.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEkt6UGs4mb2FkIYP-6iqMQi6vHuu9gNkV5SCUF-1XMV57vVYYHeYtBI7x3Vhr0OnY3u24o8Uj2n8RPirWcvdmqFCdOdgACoIV4W43OysComi-zNZqhZ0tqwA3JkYs1igIgLaeh05i0VCg/s1600/velpost.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; width=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEkt6UGs4mb2FkIYP-6iqMQi6vHuu9gNkV5SCUF-1XMV57vVYYHeYtBI7x3Vhr0OnY3u24o8Uj2n8RPirWcvdmqFCdOdgACoIV4W43OysComi-zNZqhZ0tqwA3JkYs1igIgLaeh05i0VCg/s400/velpost.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/5478927868346676581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/5478927868346676581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/5478927868346676581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/5478927868346676581'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2011/03/2011.html' title='Великий піст 2011.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEkt6UGs4mb2FkIYP-6iqMQi6vHuu9gNkV5SCUF-1XMV57vVYYHeYtBI7x3Vhr0OnY3u24o8Uj2n8RPirWcvdmqFCdOdgACoIV4W43OysComi-zNZqhZ0tqwA3JkYs1igIgLaeh05i0VCg/s72-c/velpost.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-3475508610842821143</id><published>2010-09-05T00:55:00.001+03:00</published><updated>2010-09-05T01:00:07.365+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="English"/><category scheme="http://www.blogger.com/atom/ns#" term="Hudson"/><category scheme="http://www.blogger.com/atom/ns#" term="MSpec"/><title type='text'>How to integrate MSpec into Hudson CI server</title><content type='html'>&lt;p&gt;If you’re find this post, you might already know what is MSpec and Hudson CI server. If not, I’ll tell you.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://http://github.com/machine/machine.specifications&quot;&gt;MSpec&lt;/a&gt; (short for Machine.Specifications) is an awesome .Net BDD style testing framework for, which allows you write tests without language noise.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://wiki.hudson-ci.org/display/HUDSON/Meet+Hudson&quot;&gt;Hudson CI&lt;/a&gt; is an open source continuous integration server, which is very easy to install and configure with a user friendly interface. It allows you continuously build you projects and verify the quality of these builds. And it has a lot of plugins, which make developing with Hudson more interesting and fun.&lt;/p&gt;  &lt;h4&gt;So what does it mean integrate and why should I do this?&lt;/h4&gt;  &lt;p&gt;MSpec has a command line runner, which can fail the build in case some tests are failing, and it can generate nice HTML report which can be placed in build artifacts. So what else do I need, and why i should bother with Hudson integration?&lt;/p&gt;  &lt;p&gt;Because dealing with tests is one of the Hudson core features. It can show you information about tests for a particular build and tests history information, such as when they started breaking, how many new tests were added, how test duration changed from build to build, etc. Hudson can also show nice history trend charts.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/_77xe419MW1k/TILAed--VoI/AAAAAAAAGiY/aDw_PSESuDg/s1600-h/TestResult8.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;TestResult&quot; border=&quot;0&quot; alt=&quot;TestResult&quot; src=&quot;http://lh3.ggpht.com/_77xe419MW1k/TILAf-2leQI/AAAAAAAAGic/CHK-ishWoP8/TestResult_thumb6.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;514&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At the screenshot above you can see the test result for a single build.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/_77xe419MW1k/TILAgXE3D4I/AAAAAAAAGig/GfY9Hf1wBFE/s1600-h/TestResultTrend4.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;TestResultTrend&quot; border=&quot;0&quot; alt=&quot;TestResultTrend&quot; src=&quot;http://lh6.ggpht.com/_77xe419MW1k/TILAhV5KpZI/AAAAAAAAGik/KI5c0h9_lB8/TestResultTrend_thumb2.png?imgmax=800&quot; width=&quot;513&quot; height=&quot;241&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At this screenshot (from another project) you can see tests trend.&lt;/p&gt;  &lt;p&gt;And the most fun feature (at least to me) is the test tracking in a &lt;a href=&quot;http://wiki.hudson-ci.org/display/HUDSON/The+Continuous+Integration+Game+plugin&quot;&gt;Hudson Continuous Integration game&lt;/a&gt; plugin, which gives points to user on improving the builds. This is my favorite plugin (ok, maybe after &lt;a href=&quot;http://wiki.hudson-ci.org/display/HUDSON/ChuckNorris+Plugin&quot;&gt;Chack Norris plugin&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/_77xe419MW1k/TILAh3YWV8I/AAAAAAAAGio/JXmMxJBtCOI/s1600-h/SoreCard4.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;SoreCard&quot; border=&quot;0&quot; alt=&quot;SoreCard&quot; src=&quot;http://lh5.ggpht.com/_77xe419MW1k/TILAi4dHaBI/AAAAAAAAGis/cSVR4QZ3kjk/SoreCard_thumb2.png?imgmax=800&quot; width=&quot;469&quot; height=&quot;158&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Would not it be great if MSpec tests will participate in such activities?&lt;/p&gt;  &lt;h4&gt;How to achieve that?&lt;/h4&gt;  &lt;p&gt;So how does Hudson know about all available testing tools for various programming languages? Of cause it doesn’t know about all of them. It works internally with JUnit xml reports, but there are many special plugins for most popular testing tool, which in fact transform testing tool output to JUnit format, thus allowing them to be used by Hudson. Unfortunately, there is no such plugin for MSpec currently. And I’m not familiar with Java to write it :)&lt;/p&gt;  &lt;p&gt;Good news is that MSpec can generate xml report (although it not as informative as i would like it to be). And we can write XSLT transformation to convert MSpec xml output to JUnit format and use it to provide test results to Hudson directly as JUnit tests.&lt;/p&gt;  &lt;p&gt;So here is such XSLT:&lt;/p&gt; &lt;script src=&quot;http://gist.github.com/565471.js?file=MSpecToJUnit.xslt&quot;&gt;&lt;/script&gt;  &lt;p&gt;So now you can transform MSpec results to JUnit output in you build script and than use it in Hudson. If you are using MSBuil you can use it XsltTransformation task to do the conversion:&lt;/p&gt; &lt;script src=&quot;http://gist.github.com/565480.js?file=MSpecToJUnitWithMSBuild.xml&quot;&gt;&lt;/script&gt;  &lt;p&gt;And finally you configure Hudson to use test results by specifying converted xml output. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/_77xe419MW1k/TILAjg41iYI/AAAAAAAAGiw/9dbLJa0cb_k/s1600-h/PublishTestResults%5B3%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;PublishTestResults&quot; border=&quot;0&quot; alt=&quot;PublishTestResults&quot; src=&quot;http://lh6.ggpht.com/_77xe419MW1k/TILAkUFqSCI/AAAAAAAAGi0/CUAvOHdGFro/PublishTestResults_thumb%5B1%5D.png?imgmax=800&quot; width=&quot;609&quot; height=&quot;118&quot; /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Additionally it is a good idea to publish MSpec HTML report. You may do that with help of &lt;a href=&quot;http://wiki.hudson-ci.org/display/HUDSON/HTML+Publisher+Plugin&quot;&gt;HTML Publisher Plugin&lt;/a&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/_77xe419MW1k/TILAlPT5qDI/AAAAAAAAGi4/SFmJ2cXmVFE/s1600-h/PublishSpecs%5B3%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;PublishSpecs&quot; border=&quot;0&quot; alt=&quot;PublishSpecs&quot; src=&quot;http://lh6.ggpht.com/_77xe419MW1k/TILAmCq7WdI/AAAAAAAAGi8/SQ4Ynms4q-A/PublishSpecs_thumb%5B1%5D.png?imgmax=800&quot; width=&quot;566&quot; height=&quot;128&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;That is all you need (except of course that you need to write build script which would run you specifications and will generate xml and html reports). At the end you may see you specifications included as usual tests in Hudson. And as a bonus you get nice HTML report:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/_77xe419MW1k/TILAnGB2z2I/AAAAAAAAGjA/dAN5EF6iGnU/s1600-h/HudsonView%5B17%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;HudsonView&quot; border=&quot;0&quot; alt=&quot;HudsonView&quot; src=&quot;http://lh3.ggpht.com/_77xe419MW1k/TILApMtwrDI/AAAAAAAAGjE/GjiB8tBefpw/HudsonView_thumb%5B11%5D.png?imgmax=800&quot; width=&quot;684&quot; height=&quot;772&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The link at the top of the page points to the Specifications HTML report:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/_77xe419MW1k/TILAqAUQazI/AAAAAAAAGjI/yoimyx7I-9c/s1600-h/SpecificationsReport%5B9%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;SpecificationsReport&quot; border=&quot;0&quot; alt=&quot;SpecificationsReport&quot; src=&quot;http://lh4.ggpht.com/_77xe419MW1k/TILArdzYsNI/AAAAAAAAGjM/ukF5N5laVGI/SpecificationsReport_thumb%5B7%5D.png?imgmax=800&quot; width=&quot;537&quot; height=&quot;484&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/_77xe419MW1k/TILAsQiDhLI/AAAAAAAAGjQ/U3c6zsdd2Nc/s1600-h/Specifications%5B4%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;Specifications&quot; border=&quot;0&quot; alt=&quot;Specifications&quot; src=&quot;http://lh3.ggpht.com/_77xe419MW1k/TILAuQgf2EI/AAAAAAAAGjY/UEvTZk_eY5I/Specifications_thumb%5B2%5D.png?imgmax=800&quot; width=&quot;551&quot; height=&quot;772&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;p&gt;That’s not all I wanted to say. But I’m a bit tired already. So much words :) Hope it would be useful for someone. And hope that yours Mr. Hudson and Chack Noris will always be happy:).&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/3475508610842821143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/3475508610842821143' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3475508610842821143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3475508610842821143'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2010/09/hot-to-integrate-mspec-into-hudson-ci.html' title='How to integrate MSpec into Hudson CI server'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_77xe419MW1k/TILAf-2leQI/AAAAAAAAGic/CHK-ishWoP8/s72-c/TestResult_thumb6.png?imgmax=800" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-5548135593897761388</id><published>2010-03-04T17:08:00.000+02:00</published><updated>2010-03-04T17:08:38.035+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fail"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows"/><title type='text'>XML file in Visual Studio - Request for permission failed.</title><content type='html'>Напишу для себе про помилку, яку показувала Visual Studio коли я відкривав xml файл. Бо не знатиму, що робити з цією помилкою, коли вона виникне наступного разу.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Отже ситуація така. Включив до проекту скачаний з інтернету XML файл. Відкрив його в Visual Studio 2008 і побачив таку помилку:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWE96qPKhjMpqcHsEOvRwaDDy6mkvaBiW30x510vWG0irBNc_BRITKCN_0WL4iQmJ88abf3lFxb4NoFEe_fCMz69GLA6EUVUslf8gkQ6YN-yE3aHAic5l3t579epHQ_EO04MHoX0IzXtLM/s1600-h/ErrorIndication.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;98&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWE96qPKhjMpqcHsEOvRwaDDy6mkvaBiW30x510vWG0irBNc_BRITKCN_0WL4iQmJ88abf3lFxb4NoFEe_fCMz69GLA6EUVUslf8gkQ6YN-yE3aHAic5l3t579epHQ_EO04MHoX0IzXtLM/s640/ErrorIndication.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHrgvfzKfznBpEEjg-JxyLAzeLmREIqXRHoDjDU1l8v-y1FpuQQWkbd2DoW4PRlixwBPpkaRukAqaZV6b8rAn_eGjx96Ss1aiWuYGopug2D9K5FL1xy_YxH76OyQ4h4C3dT1TtT0IgKUDd/s1600-h/Error.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;108&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHrgvfzKfznBpEEjg-JxyLAzeLmREIqXRHoDjDU1l8v-y1FpuQQWkbd2DoW4PRlixwBPpkaRukAqaZV6b8rAn_eGjx96Ss1aiWuYGopug2D9K5FL1xy_YxH76OyQ4h4C3dT1TtT0IgKUDd/s640/Error.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Повідомлення про помилку:&lt;/div&gt;&lt;pre&gt;Request for the permission of type &#39;System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#39; failed.&lt;/pre&gt;&lt;br /&gt;
Якщо в DOCTYPE зазначено url схеми в інтернеті, то відповідно виникає помилка:&lt;br /&gt;
&lt;pre&gt;Request for the permission of type &#39;System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#39; failed.
&lt;/pre&gt;&lt;br /&gt;
При цьому до проекту було вже підключено кілька XML файлів із таким жe DTD.&lt;br /&gt;
&lt;br /&gt;
Гугл мені не допоміг.&amp;nbsp;Здогадався подивитися у властивості файлу. Проблема виявилась простою - Windows заблокувала файл, тому що він був завантажений з інтернету.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_W7HeqgGQ3I3R55h62RFXSFsZ60IJxbJgPih2Ek_rcW1yxxD45tZBUuzwNAe9Z81spTbSVu0q1PgqkSdd8qA1ll-CyDBuukn3fwcaHeoCcYmjftEQMZDrB8P6oG_m6hdnbqvTKbPsyu6P/s1600-h/Unlock.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_W7HeqgGQ3I3R55h62RFXSFsZ60IJxbJgPih2Ek_rcW1yxxD45tZBUuzwNAe9Z81spTbSVu0q1PgqkSdd8qA1ll-CyDBuukn3fwcaHeoCcYmjftEQMZDrB8P6oG_m6hdnbqvTKbPsyu6P/s640/Unlock.png&quot; width=&quot;486&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Дуже дякую. Це ж мабуть я мав відразу здогадатися? Витратив кучу часу.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/5548135593897761388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/5548135593897761388' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/5548135593897761388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/5548135593897761388'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2010/03/xml-file-in-visual-studio-request-for.html' title='XML file in Visual Studio - Request for permission failed.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWE96qPKhjMpqcHsEOvRwaDDy6mkvaBiW30x510vWG0irBNc_BRITKCN_0WL4iQmJ88abf3lFxb4NoFEe_fCMz69GLA6EUVUslf8gkQ6YN-yE3aHAic5l3t579epHQ_EO04MHoX0IzXtLM/s72-c/ErrorIndication.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-3013307696413888344</id><published>2010-02-15T21:26:00.003+02:00</published><updated>2011-03-06T14:52:01.751+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Relax"/><title type='text'>Великий піст 2010. Що можна їсти?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;UPD&lt;/span&gt;: Оновлену схему посту для 2011 року можна подивитись &lt;a href=&quot;http://korneliuk.blogspot.com/2011/03/2011.html&quot;&gt;тут&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Сьогодні, 15 лютого, розпочався Великий піст. Для мене це привід змінити себе на краще, &lt;br /&gt;
поборотися зі шкідливими звичками. І хоча всі кажуть, що піст&amp;nbsp;–&amp;nbsp;це не дієта, все ж утримання від&amp;nbsp;їжі - це головний атрибут посту.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;Яку їжу можна вживати в піст&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Є різні правила. Біль та менш строгі. Я користуюсь тими, що описані на &lt;a href=&quot;http://www.sestry.ru/church/content/vpost&quot;&gt;сторінці&lt;/a&gt; сайту&amp;nbsp;&lt;a href=&quot;http://www.sestry.ru/&quot;&gt;http://www.sestry.ru&lt;/a&gt;.&amp;nbsp;Там я знайшов і цю зручну схему:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKOJm3h1swm8oqYmxsQlZyJlwRaTgT2_Ks2XyjGzy6eyEbudwoz8DO0bKMdopHypTATTdcdSYk9rpx7vFYpgOI9akboOsmzk_GzgpGLZb6yhhTACmDlfnxj7CsCaCOF9G2zc36lpp_zoE-/s1600-h/vpost_img.jpg&quot; imageanchor=&quot;1&quot; style=&quot;display: inline !important; margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKOJm3h1swm8oqYmxsQlZyJlwRaTgT2_Ks2XyjGzy6eyEbudwoz8DO0bKMdopHypTATTdcdSYk9rpx7vFYpgOI9akboOsmzk_GzgpGLZb6yhhTACmDlfnxj7CsCaCOF9G2zc36lpp_zoE-/s640/vpost_img.jpg&quot; width=&quot;384&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Отже оcновні правила такі:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Не можна їсти м&#39;ясо, рибу, яйця, молоко та інші продукти тавринного походження.&lt;/li&gt;
&lt;li&gt;У перші два дні посту (15 та 16 лютого) та в передостанній день (2 квітня) - строгий піст. Рекомендується повне утримання від їжі, або невелика кількість пісної їжі.&lt;/li&gt;
&lt;li&gt;В середу та п&#39;ятницю - «сухояденіє». Не можна вживати ні варену, ні приготовану на пару їжу. Не можна вживати олію. Дозволяються хліб, свіжі, сушені й квашені овочі та фрукти.&lt;/li&gt;
&lt;li&gt;В інші дні дозволена рослинна олія.&lt;/li&gt;
&lt;li&gt;В суботу, в неділю а також в свята&amp;nbsp;25 лютого, 9 березня та 22 березня&amp;nbsp;можна вживати морепродукти.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;В Вербну неділю (28 березня) можна їсти рибу. А в Лазареву суботу (напередодні Вербної неділі) можна їсти ікру.&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;І наостанок, слід пам&#39;ятати, що головне чого не можна їсти - це своїх ближніх.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/3013307696413888344/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/3013307696413888344' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3013307696413888344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3013307696413888344'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2010/02/2010.html' title='Великий піст 2010. Що можна їсти?'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKOJm3h1swm8oqYmxsQlZyJlwRaTgT2_Ks2XyjGzy6eyEbudwoz8DO0bKMdopHypTATTdcdSYk9rpx7vFYpgOI9akboOsmzk_GzgpGLZb6yhhTACmDlfnxj7CsCaCOF9G2zc36lpp_zoE-/s72-c/vpost_img.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-6485280299386189761</id><published>2010-01-24T01:52:00.006+02:00</published><updated>2012-08-27T14:19:00.641+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Dependency Injection"/><category scheme="http://www.blogger.com/atom/ns#" term="English"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Testing"/><title type='text'>Null arguments in a constructor. To check or not to check.</title><content type='html'>We&#39;ve had interesting discussion recently, on whether to check constructor arguments on nulls. I want to share my thought on this.&lt;br /&gt;
&lt;br /&gt;
Our coding convention has a rule stating that all public methods arguments should be checked for nulls. So our methods usually looks like this one:&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;public void SomeMethod(string arg)
{
    Precondition.Argument.NotNull(arg, &quot;arg&quot;);
    // Real code comes here...
}
&lt;/pre&gt;And I&#39;m quite happy with such&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Design_by_Contract&quot;&gt;DbC&lt;/a&gt; like coding style. But... with one exception.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;I don&#39;t like to write code checking for null dependencies in a service constructor.&lt;/i&gt; For two main reasons:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;It is easier to write tests for the service. &lt;/b&gt;In case when particular dependency is not used in test it is easier to pass null instead of&amp;nbsp;creating stub dependencies only to satisfy checks.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;It useless in case when all services are instantiated through &lt;a href=&quot;http://en.wikipedia.org/wiki/Dependency_injection&quot;&gt;DI container&lt;/a&gt;.&lt;/b&gt;&amp;nbsp;That is because, as far as I know, most DI containers will throw an exception&amp;nbsp;by self&amp;nbsp;when it can&#39;t find dependency for the service.&lt;/li&gt;
&lt;/ol&gt;I think code will show my point better. Suppose we need a service to login users. Service responsibility will be to retrieve user by the name provided, verify that provided password is correct and to set the user as a current user in the application. In case when&amp;nbsp;supplied&amp;nbsp;user name or password are incorrect, service should log appropriate message.&lt;br /&gt;
&lt;br /&gt;
So service will need some repository to retrieve users, some service to authenticate user and a logger to log messages in case when incorrect user credentials specified.&lt;br /&gt;
&lt;br /&gt;
I&#39;ll disregard TDD practice and will show the code before test (shame on me). So the LoginService code:&lt;br /&gt;
&lt;pre class=&quot;brush: csharp; gutter: false;&quot;&gt;public class LoginService : ILoginService
{
    readonly IUserRepository userRepository;
    readonly IAuthenticationService authenticationService;
    readonly ILog log;

    public LoginService(
        IUserRepository userRepository,
        IAuthenticationService authenticationService,
        ILog log)
    {
        // This is the subject of discussing.
        Precondition.Argument.NotNull(userRepository, &quot;userRepository&quot;);
        Precondition.Argument.NotNull(authenticationService, &quot;authenticationService&quot;);
        Precondition.Argument.NotNull(log, &quot;log&quot;);

        this.userRepository = userRepository;
        this.authenticationService = authenticationService;
        this.log = log;
    }

    public bool Login(UserCredentials userCredentials)
    {
        Precondtion.Argument.NotNull(userCredentials);
        
        var user = this.userRepository.FindByName(userCredentials.Name);
        if (user == null)
        {
            this.log.Info(&quot;Login attempt failed due to invalid user name&quot;);
            return false;
        }

        if (!this.authenticationService.PasswordMatches(user, userCredentials.Password))
        {
            this.log.Info(&quot;Login attempt failed due to invalid password&quot;);
            return false;
        }

        SetCurrentUser(user);
        return true;
    }
}
&lt;/pre&gt;Lets write a test for scenario when incorrect user name is provided. For this scenario we don&#39;t need IAuthenticationService.&lt;br /&gt;
&lt;pre class=&quot;brush: csharp; gutter: false;&quot;&gt;[Subject(typeof(LoginService))]
public class when_unknown_user_name_provided
{
    const string UnknownUserName = &quot;Unknown user&quot;;
    User user;
    UserCredentials credentials;
    LogSpy logSpy;
    LoginService loginService;
    bool loginResult;

    Establish context = () =&amp;gt;
    {
        credentials = new UserCredentials(UnknownUsername, &quot;stub password&quot;);
        var userRepository = MockRepository.GenerateStub&amp;lt;IUserRepository&amp;gt;();
        userRepository.Stub(x =&amp;gt; x.FindByName(UnknownUserName).Return(null);

        // We really do not need an authenticationService for this test. 
        // But should stub it only to satisfy null check constraints.
        // Isn&#39;t it easier and more readable to use such obviuos construction?
        // var authenticationServiceNotUsed = null;
        var authenticationServiceNotUsed = 
            MockRepository.GenerateStub&amp;lt;IAutenticationService&amp;gt;();

        logSpy = new LogSpy();
        
        loginService = new LoginService(
            userRepository, authenticationServiceNotUsed, LogSpy);        
    };

    Because of = () =&amp;gt; loginResult = loginService.Login(userCredentials);

    It should_indicate_that_user_login_failed = () =&amp;gt; loginResult.ShouldBeFalse();

    It should_not_set_current_user = () =&amp;gt; User.Current.ShouldBeNull();

    It should_log_invalid_login_attempt = () =&amp;gt;
        logSpy.InfoMessage.ShouldBeEqualTo(
            &quot;Login attempt failed due to invalid user name&quot;); 
}
&lt;/pre&gt;And wait, as far as I have serviceAuthentication instance I might want to ensure that it was not called within a test:&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;It should_not_use_authentication_service = () =&amp;gt; 
        authenticationService.AssertWasNotCalled(
            x =&amp;gt; x.PasswordMatches(Arg&amp;lt;User&amp;gt;.Is.Anyting, Arg&amp;lt;string&amp;gt;.Is.Anything));
&lt;/pre&gt;Seems like a waste of time. Intent is more clear when null authenticationService is used. That&#39;s all about testing challenge.&lt;br /&gt;
&lt;br /&gt;
Now lets me return back to my statement that such null checks in a constructor are useless. So what is the advantage they might give? Earlier problem discovering by throwing ArgumentNullException in a constructor, instead of NullReferenceException somewhere while executing method later. I believe that in production code such services should not be instantiated directly by hand, but resolved with DI container (in a &lt;a href=&quot;http://ayende.com/Blog/archive/2010/01/22/rejecting-dependency-injection-inversion.aspx&quot;&gt;recent Ayende&#39;s post&lt;/a&gt; you can see a very nice picture of dependencies graph). As I&#39;ve already said, most of DI containers will throw an exception itself if it can&#39;t find dependency. But with DI containers even better approach is to test container configuration. For given example test may look like: &lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;[Subject(typeof(ApplicationConfiguration))]
public class when_configuring
{
    Because of = () =&amp;gt; ApplicationConfiguration.Initialize();

    It should_initialize_service_locator = () =&amp;gt;
        ServiceLocator.Current.ShouldNotBeNull();

    It should_configure_login_service = () =&amp;gt;
        ServiceLocator.Current.GetInstance&amp;lt;ILoginService&amp;gt;().ShouldNotBeNull();
}
&lt;/pre&gt;With this approach we get even earlier problem discovering.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Summary&lt;/b&gt;: This post explains why using null arguments checks in services constructors is not a good idea. The better approach is letting them be null for testing purposes and testing you DI container configuration to ensure that services may be resolved in a run-time.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; Tests are using syntax of the awesome Machine.Specifications framework which you can find &lt;a href=&quot;http://github.com/machine/machine.specifications&quot;&gt;here&lt;/a&gt;. All the code examples were written without any code editor. So I expect it contains errors.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/6485280299386189761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/6485280299386189761' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6485280299386189761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6485280299386189761'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2010/01/null-arguments-in-constructor-to-check.html' title='Null arguments in a constructor. To check or not to check.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-8231809418151071073</id><published>2009-12-29T01:23:00.004+02:00</published><updated>2010-01-24T11:28:52.975+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="English"/><category scheme="http://www.blogger.com/atom/ns#" term="log4net"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Configuring Log4Net AdoNetAppender with a connection string from application configuration file</title><content type='html'>I read Ben Scheirman&#39;s &quot;&lt;a href=&quot;http://flux88.com/blog/changing-log4net-connection-string-at-runtime&quot;&gt;Changing log4net connection string at runtime&lt;/a&gt;&quot; post and wanted to leave a comment describing solution I use to solve log4net ConnectionString configuring problem. But as I wanted to show some code, it might be better to make a blog post.&lt;br /&gt;
&lt;br /&gt;
So the problem I faced with was:&lt;br /&gt;
&lt;blockquote&gt;How to configure &lt;a href=&quot;http://logging.apache.org/log4net/index.html&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;text-decoration: none;&quot;&gt;log4net&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; AdoNetAppender to use connection string specified in a&amp;nbsp;&amp;lt;connectionStrings&amp;gt; section of an application configuration file?&lt;/blockquote&gt;There is no obvious way to do this in a current release of log4net. But &lt;a href=&quot;https://issues.apache.org/jira/browse/LOG4NET-88&quot;&gt;such issue&lt;/a&gt; is already &lt;a href=&quot;http://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/AdoNetAppender.cs?r1=607475&amp;amp;r2=607748&amp;amp;diff_format=h&quot;&gt;fixed&lt;/a&gt; in a log4net trunk, thus it will be possible to do so in the next release.&lt;br /&gt;
&lt;br /&gt;
I don&#39;t really like to use the code which not yet&amp;nbsp;officially&amp;nbsp;released. So I use a simple workaround - a class inherited from AdoNetAppender with a new property ConnectionStringName. The code is pretty obvious:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;using System.Configuration;

using log4net.Appender;
using log4net.Core;

/// &amp;lt;summary&amp;gt;
/// Allows to use a connection string specified in the 
/// &amp;lt;see cref=&quot;ConfigurationManager.ConnectionStrings&quot;/&amp;gt; section of an application
/// configuration file.
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;remarks&amp;gt;
/// Such feature is already implemented in a log4net trunk (see
/// https://issues.apache.org/jira/browse/LOG4NET-88). But it is not yet released.
/// &amp;lt;para/&amp;gt;
/// TODO: Remove this class as soon as log4net 1.2.11 will be released.
/// &amp;lt;/remarks&amp;gt;
public class Log4NetConnectionStringNameAdoNetAppender : AdoNetAppender
{
    private string connectionStringName;

    /// &amp;lt;summary&amp;gt;
    /// Gets or sets the name of the connection string from the application
    /// configuration file.
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;value&amp;gt;The name of the connection string.&amp;lt;/value&amp;gt;
    public string ConnectionStringName
    {
        get
        {
            return this.connectionStringName;
        }
        
        set
        {
            this.connectionStringName = value;

            if (!string.IsNullOrEmpty(this.connectionStringName))
            {
                var settings =
                    ConfigurationManager.ConnectionStrings[this.connectionStringName];
                if (settings == null)
                {
                    string msg = string.Format(
                        &quot;Unable to find [{0}] ConfigurationManager.ConnectionStrings item&quot;,
                        this.connectionStringName);

                    throw new LogException(msg);
                }

                this.ConnectionString = settings.ConnectionString;
            }
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
And the log4net configuration looks like this:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;appender name=&quot;DBAppender&quot; type=&quot;NamespaceWhereClassLives.Log4NetConnectionStringNameAdoNetAppender,AssemblyContainingClass&quot;&amp;gt;
    &amp;lt;connectionStringName value=&quot;ConnectionStringNameFromConfigFile&quot;/&amp;gt;
    &amp;lt;!-- Other parameters --&amp;gt;
&amp;lt;/appender&amp;gt;
&lt;/pre&gt;This looks like a hack, but it works for me pretty well.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/8231809418151071073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/8231809418151071073' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/8231809418151071073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/8231809418151071073'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/12/configuring-log4net-adonetappender-with.html' title='Configuring Log4Net AdoNetAppender with a connection string from application configuration file'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-2266662034016117997</id><published>2009-10-14T23:53:00.000+03:00</published><updated>2009-10-14T23:53:38.107+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fun"/><category scheme="http://www.blogger.com/atom/ns#" term="Україна"/><title type='text'>На Украине? На Росії!</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj06AfS_Q2MWysY7UE7gNnLdidnlcwXgEK50PJxSK4koeZUDLsNOqCM7N9Ak_-DDCjZoGukeTm2Gl42pWkxszWS6ncub247WscBOnvLPlsgXzc1WTZOXAX-38EN9Mg8XTcTzgEbk8KKxbv9/s1600-h/Map_of_Kiev_Rus&#39;.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj06AfS_Q2MWysY7UE7gNnLdidnlcwXgEK50PJxSK4koeZUDLsNOqCM7N9Ak_-DDCjZoGukeTm2Gl42pWkxszWS6ncub247WscBOnvLPlsgXzc1WTZOXAX-38EN9Mg8XTcTzgEbk8KKxbv9/s200/Map_of_Kiev_Rus&#39;.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;Вчора дізнався, що фінською правильно вживати&amp;nbsp;&lt;i&gt;&quot;Я був &lt;/i&gt;&lt;b&gt;&lt;i&gt;на Росії&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&quot;&lt;/i&gt;&amp;nbsp;(Minä olin Venäjallä),&amp;nbsp;але &lt;i&gt;&quot;Я живу в Україні&quot; &lt;/i&gt;(Minä asun Ukrainassa).&lt;br /&gt;
&lt;br /&gt;
На відміну від інших країн, для Росії, в фінській мові використовуються &lt;a href=&quot;http://en.wikipedia.org/wiki/Finnish_language_noun_cases#External_Locatives&quot;&gt;зовнішні місцеві відмінки&lt;/a&gt;. Приклади&amp;nbsp;&lt;a href=&quot;http://en.wiktionary.org/wiki/Ven%C3%A4j%C3%A4#Usage_notes&quot;&gt;тут&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
PS. Взагалі то я не дуже переймаюсь тим як саме кажуть росіяни - &lt;i&gt;&quot;на Украине&quot;&lt;/i&gt; чи &lt;i&gt;&quot;в Украине&quot;&lt;/i&gt;. Мені це навіть імпонує&amp;nbsp;трохи. Все таки підкреслюється унікальність нашої країни. Писав же Некрасов &lt;a href=&quot;http://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D0%BC%D1%83_%D0%BD%D0%B0_%D0%A0%D1%83%D1%81%D0%B8_%D0%B6%D0%B8%D1%82%D1%8C_%D1%85%D0%BE%D1%80%D0%BE%D1%88%D0%BE&quot;&gt;&quot;Кому на Руси жить хорошо&quot;&lt;/a&gt;. Так от я подумав, може це &lt;i&gt;&quot;на&quot;&lt;/i&gt; нам у спадок від Київської Русі дісталась?&lt;br /&gt;
&lt;br /&gt;
Та не про те хотів сказати. Я не знаю як правильно вживати &quot;в Україні&quot; російською мовою. Але я &lt;a href=&quot;http://mova.kreschatic.kiev.ua/41.htm#1&quot;&gt;знаю&lt;/a&gt;, що українською правильно казати: &quot;Я живу &lt;b&gt;в Україні&lt;/b&gt;&quot;.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/2266662034016117997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/2266662034016117997' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2266662034016117997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2266662034016117997'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/10/blog-post_14.html' title='На Украине? На Росії!'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj06AfS_Q2MWysY7UE7gNnLdidnlcwXgEK50PJxSK4koeZUDLsNOqCM7N9Ak_-DDCjZoGukeTm2Gl42pWkxszWS6ncub247WscBOnvLPlsgXzc1WTZOXAX-38EN9Mg8XTcTzgEbk8KKxbv9/s72-c/Map_of_Kiev_Rus&#39;.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-3987253274828876927</id><published>2009-10-14T21:45:00.002+03:00</published><updated>2009-10-14T23:56:43.368+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fun"/><category scheme="http://www.blogger.com/atom/ns#" term="Україна"/><title type='text'>За кого голосувати на виборах?</title><content type='html'>Послухайте &lt;a href=&quot;http://sashko.com.ua/?p=10&quot;&gt;чудову пісню&lt;/a&gt; Сашка Положинського. Мене дуже порадувала.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/3987253274828876927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/3987253274828876927' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3987253274828876927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3987253274828876927'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/10/blog-post.html' title='За кого голосувати на виборах?'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-2770993747544829203</id><published>2009-09-30T09:34:00.004+03:00</published><updated>2009-10-13T23:23:18.112+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Books"/><title type='text'>Майкл К. Физерс. Эффективная работа с унаследованным кодом</title><content type='html'>&lt;a href=&quot;http://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;span id=&quot;goog_1254291409403&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1254291409404&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy0_uLqDjYuI8ZHmmvqPJtuYyCFphKRXbm0R41mKDRRjmsm_gPKx6pkBOyItzUo8R0-YdMmkTx45RDxzHaagUITr8WzInZ1j2eFWsohHHPqxnaZQtiaBNb4I5_9Rxk2FQVYJRjZ3K9SYc7/s1600-h/FWELC.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy0_uLqDjYuI8ZHmmvqPJtuYyCFphKRXbm0R41mKDRRjmsm_gPKx6pkBOyItzUo8R0-YdMmkTx45RDxzHaagUITr8WzInZ1j2eFWsohHHPqxnaZQtiaBNb4I5_9Rxk2FQVYJRjZ3K9SYc7/s320/FWELC.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;Останнім часом я зустрічав багато посилань на книгу &lt;a href=&quot;http://www.williamspublishing.com/Books/978-5-8459-1530-6.html&quot;&gt;&quot;Эффективная работа с унаследованным кодом&quot;&lt;/a&gt;&amp;nbsp;із дуже позитивним відгуками. Тому сподівався, що книга мені сподобається. Але прочитавши її, мої очікування не виправдались. Навпаки, книга здалась мені дуже нудною. Не знаю чия це вина, автора, перекладачів, чи мого сприйняття. Багато сторінок, я просто переглядав по діагоналі. Часто ловив себе на тому, що прочитавши якийсь розділ нічого не зрозумів, бо думки гуляли&amp;nbsp;деінде, &amp;nbsp;а перечитувати ніякого бажання немає. І взагалі не розумію, як можна стільки уваги приділити питанню - як розірвати залежність між кодом, і жодним словом не обмовитись про &lt;a href=&quot;http://en.wikipedia.org/wiki/Dependency_injection&quot;&gt;Dependecy Injection Containers (IOC)&lt;/a&gt;. А, точно, це ж успадкований код. До того ж судячи з книги, більшість успадкованого коду - це код на C та C++. Але мене це мало цікавить.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/2770993747544829203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/2770993747544829203' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2770993747544829203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2770993747544829203'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/09/blog-post.html' title='Майкл К. Физерс. Эффективная работа с унаследованным кодом'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy0_uLqDjYuI8ZHmmvqPJtuYyCFphKRXbm0R41mKDRRjmsm_gPKx6pkBOyItzUo8R0-YdMmkTx45RDxzHaagUITr8WzInZ1j2eFWsohHHPqxnaZQtiaBNb4I5_9Rxk2FQVYJRjZ3K9SYc7/s72-c/FWELC.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-9152232477045987316</id><published>2009-09-27T16:12:00.008+03:00</published><updated>2010-01-23T16:19:13.137+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="English"/><category scheme="http://www.blogger.com/atom/ns#" term="NHibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Sql"/><title type='text'>High/Low generator with SQL</title><content type='html'>In current project, we use High/Low generator strategy to generate identifiers for entities. (Fabio Maulo wrote a good explanation &lt;a href=&quot;http://fabiomaulo.blogspot.com/2008/12/identity-never-ending-story.html&quot;&gt;why using identity is a bad thing&lt;/a&gt;). The question I sometimes see in NHibernate forums is what to do if some other applications also use the same database. Usual answer is - implement some service which would generate id, and use it in that applications.&lt;br /&gt;
Yesterday I met similar issue. What I needed to do is to insert some fake data using SQL only. For that purpose I wrote such stored procedure:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot;&gt;IF OBJECT_ID(&#39;dbo.GenerateHiLoIdRange&#39;) IS NOT NULL
  DROP PROCEDURE dbo.GenerateHiLoIdRange
GO
CREATE PROCEDURE dbo.GenerateHiLoIdRange (
    @IdsCount INT
)
AS
/* =============================================================== */
/* == Generates a range of identifiers using High/Low strategy. == */
/* =============================================================== */
BEGIN
    SET NOCOUNT ON;
    
    IF @IdsCount &amp;lt;= 0
    BEGIN
        RAISERROR(&#39;@IdsCount should be positive. But was %d&#39;, 16, -1, @IdsCount)
        RETURN(-100);
    END

    DECLARE @NextHi INT
    DECLARE @MaxLo  INT
    SET @MaxLo = 100  -- Hardcoded value used over all tables in a database.
 
    BEGIN TRANSACTION UpdateHiLoTable
        
        SET @NextHi = (
            SELECT next_hi 
            FROM hibernate_unique_key WITH (UPDLOCK, ROWLOCK)
        )
        
        UPDATE hibernate_unique_key 
        SET next_hi = @NextHi + 1 + (@IdsCount - 1) / @MaxLo
        WHERE next_hi = @NextHi
        
    COMMIT TRANSACTION UpdateHiLoTable
    
    SELECT @NextHi * @MaxLo + IntValue
    FROM   dbo.Integers(@IdsCount - 1)
END
GO
&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Main points of procedure:&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;It uses hard coded MaxLo value&amp;nbsp;(100)&amp;nbsp;, which is used over all entities in our application.&lt;/li&gt;
&lt;li&gt;Calculates new NextHi value based on requested identifiers count and updates&amp;nbsp;&lt;span style=&quot;font-family: monospace; white-space: pre;&quot;&gt;hibernate_unique_key&lt;/span&gt;&amp;nbsp;table in transaction.&lt;/li&gt;
&lt;li&gt;To return a result set containing generated identifiers procedure needs some sort of &quot;Integers&quot; table.&amp;nbsp;In my case i simulate such table with a table-valued function.&lt;/li&gt;
&lt;/ul&gt;&lt;pre class=&quot;brush: sql&quot;&gt;IF OBJECT_ID(&#39;dbo.Integers&#39;) IS NOT NULL
  DROP FUNCTION dbo.Integers
GO
CREATE FUNCTION dbo.Integers (
    @MaxValue INT
)
RETURNS @Integers TABLE (IntValue INT NOT NULL)
AS
/* =============================================================== */
/* ==   Returns the [0,  @MaxValue] range of integer values.    == */
/* =============================================================== */
BEGIN
    IF @MaxValue &amp;gt; 9999
    BEGIN
      RETURN;
    END;
    
    DECLARE @Digits TABLE
    (
        Digit INT NOT NULL PRIMARY KEY
    )

    INSERT INTO @Digits (Digit) VALUES (0)
    INSERT INTO @Digits (Digit) VALUES (1)
    INSERT INTO @Digits (Digit) VALUES (2)
    INSERT INTO @Digits (Digit) VALUES (3)
    INSERT INTO @Digits (Digit) VALUES (4)
    INSERT INTO @Digits (Digit) VALUES (5)
    INSERT INTO @Digits (Digit) VALUES (6)
    INSERT INTO @Digits (Digit) VALUES (7)
    INSERT INTO @Digits (Digit) VALUES (8)
    INSERT INTO @Digits (Digit) VALUES (9)
    
    INSERT INTO @Integers
    SELECT Number
    FROM  
        (SELECT 
            Thousands.Digit * 1000 + 
            Hundreds.Digit * 100 + 
            Tens.Digit * 10 + 
            Ones.Digit AS Number
         FROM   
            @Digits Thousands
            CROSS JOIN @Digits Hundreds
            CROSS JOIN @Digits Tens
            CROSS JOIN @Digits Ones
        ) Integers
    WHERE Number &amp;lt;= @MaxValue
    ORDER BY Number
        
    RETURN;
END
GO
&lt;/pre&gt;Note that number of integers in a function is limited to 10000. But that is what I need.&lt;br /&gt;
&lt;br /&gt;
Now I can generate identifiers in t-sql batches:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot;&gt;CREATE TABLE #TempId (Id INT NOT NULL)

SELECT * FROM hibernate_unique_key

INSERT INTO #TempId
  EXEC dbo.GenerateHiLoIdRange 250

SELECT&amp;nbsp;Id AS Id, 
    &#39;PersonName&#39; +  CAST(ROW_NUMBER() OVER(ORDER BY Id) - 1 AS VARCHAR(255)) AS PersonName
FROM #TempId

DROP TABLE #TempId
&lt;/pre&gt;&lt;br /&gt;
In my sandbox database I see such results:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnr73WnHAsjuYZMfrcFN1ENWXkQARjFkZeZdZVsC6AFS4Nz2BvsFtLWjbkAb0q9d3oJ9Xt1rhHu4AVUOiWlnxx9JeQDhd7d0aryKCbHwcu32jRxJjV1E0x9Q7u18nSQrJ8VY8DEDGgicgP/s1600-h/HiLoGeneratorResults.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnr73WnHAsjuYZMfrcFN1ENWXkQARjFkZeZdZVsC6AFS4Nz2BvsFtLWjbkAb0q9d3oJ9Xt1rhHu4AVUOiWlnxx9JeQDhd7d0aryKCbHwcu32jRxJjV1E0x9Q7u18nSQrJ8VY8DEDGgicgP/s400/HiLoGeneratorResults.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/9152232477045987316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/9152232477045987316' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/9152232477045987316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/9152232477045987316'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/09/highlow-generator-with-sql.html' title='High/Low generator with SQL'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnr73WnHAsjuYZMfrcFN1ENWXkQARjFkZeZdZVsC6AFS4Nz2BvsFtLWjbkAb0q9d3oJ9Xt1rhHu4AVUOiWlnxx9JeQDhd7d0aryKCbHwcu32jRxJjV1E0x9Q7u18nSQrJ8VY8DEDGgicgP/s72-c/HiLoGeneratorResults.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-8277015124053538340</id><published>2009-06-29T20:41:00.007+03:00</published><updated>2009-06-29T21:03:45.681+03:00</updated><title type='text'>Firefox - пожирач пам&#39;яті</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimOM2wtIHrQ_XhuS5mldEAfDuwSmOFdE2jXE3mvGqefIIGhSEalGanAzXHXG1fPpHHw4xidrIr8K20yBQXYZmbIUn2t1K6MjRKF8iE2ILdNkhjrhHb7yr-5Jqo9gn7sOSTxUqU7ZGnZwRr/s1600-h/firefox.png&quot;&gt;&lt;img style=&quot;cursor: pointer; width: 400px; height: 257px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimOM2wtIHrQ_XhuS5mldEAfDuwSmOFdE2jXE3mvGqefIIGhSEalGanAzXHXG1fPpHHw4xidrIr8K20yBQXYZmbIUn2t1K6MjRKF8iE2ILdNkhjrhHb7yr-5Jqo9gn7sOSTxUqU7ZGnZwRr/s400/firefox.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5352811162481116274&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Це через кілька хвилин після того як, здавалося б, закрив  firefox. Куди стільки пам&#39;яті можна жерти?</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/8277015124053538340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/8277015124053538340' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/8277015124053538340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/8277015124053538340'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/06/firefox.html' title='Firefox - пожирач пам&#39;яті'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimOM2wtIHrQ_XhuS5mldEAfDuwSmOFdE2jXE3mvGqefIIGhSEalGanAzXHXG1fPpHHw4xidrIr8K20yBQXYZmbIUn2t1K6MjRKF8iE2ILdNkhjrhHb7yr-5Jqo9gn7sOSTxUqU7ZGnZwRr/s72-c/firefox.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-6114733026307027082</id><published>2009-06-28T15:13:00.005+03:00</published><updated>2009-06-28T15:50:21.634+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Linq в .Net Framework 2.0</title><content type='html'>&lt;span style=&quot;font-weight: bold;&quot;&gt;Проблема:&lt;/span&gt; Клієнти живуть на Windows 2000, на яку можна поставити лише .Net Framework 2.0. Але в проекті хочеться використовувати Linq. Чи це можливо?&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;Рішення&lt;/span&gt;: Можна! &lt;a href=&quot;http://code.google.com/p/linqbridge/downloads/list&quot;&gt;Завантажуємо&lt;/a&gt; чудову бібліотеку &lt;a href=&quot;http://www.albahari.com/nutshell/linqbridge.aspx&quot;&gt;LinqBridge&lt;/a&gt; і з радістю використовуємо Linq.&lt;br /&gt;&lt;br /&gt;Що саме містить ця бібліотека:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Власну реалізацію всіх Linq операторів для Enumerable класу  із Framework 3.5, що саме і дозволяє використовувати Linq to Objects в .Net Framework 2.0.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Реалізує generic делегати &lt;span style=&quot;font-weight: bold;&quot;&gt;Func&lt;/span&gt; та &lt;span style=&quot;font-weight: bold;&quot;&gt;Action&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Реалізує &lt;span style=&quot;font-weight: bold;&quot;&gt;ExtensionAttribute&lt;/span&gt;, який дозволяє використовувати extension methotds в .Net Framework 2.0.&lt;/li&gt;&lt;/ul&gt;Однак це не стосується &lt;span style=&quot;font-weight: bold;&quot;&gt;Linq to Sql &lt;/span&gt;та &lt;span style=&quot;font-weight: bold;&quot;&gt;Linq to Xml&lt;/span&gt;, які ця бібліотека не реалізує.&lt;br /&gt;&lt;br /&gt;Детально про LinqBridge, і про те чому це можливо &lt;a href=&quot;http://www.albahari.com/nutshell/linqbridge.aspx&quot;&gt;читайте в статті автор&lt;/a&gt;а, якому я дуже вдячний за чудову роботу.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/6114733026307027082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/6114733026307027082' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6114733026307027082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6114733026307027082'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/06/linq-net-framework-20.html' title='Linq в .Net Framework 2.0'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-176732399986776480</id><published>2009-02-15T23:35:00.003+02:00</published><updated>2009-10-13T23:23:18.112+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Books"/><title type='text'>Харпер Лі. Убить пересмешника.</title><content type='html'>В романі &lt;a href=&quot;http://ru.wikipedia.org/wiki/%D0%9B%D0%B8,_%D0%A5%D0%B0%D1%80%D0%BF%D0%B5%D1%80&quot;&gt;Харпер Лі&lt;/a&gt;, очима маленької дівчинки, показано життя Америки на початку минулого століття.&lt;br /&gt;&lt;br /&gt;Читається дуже легко, чимось нагадало &quot;Пригоди Тома Сойєра&quot; Марка Твена.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/176732399986776480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/176732399986776480' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/176732399986776480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/176732399986776480'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/02/blog-post_7610.html' title='Харпер Лі. Убить пересмешника.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-3571837635056757413</id><published>2009-02-15T09:34:00.004+02:00</published><updated>2009-10-13T23:23:18.112+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Books"/><title type='text'>Вернор Виндж. Пламя над бездной.</title><content type='html'>В романі автор пропонує дуже цікавий погляд на будову всесвіту. Він поділяється на зони - від центра до краю. В центрі - безодня, в якій розум неможливий. Чим ближче до краю, тим технологічнішими можуть бути цивілізації. В Краї, швидкість світла не є обмеженням. За краєм цивілізації стають Силами (я так і не зрозумів що це таке).&lt;br /&gt;&lt;br /&gt;Розпочинається книга, тим, що представники людської цивілізації, десь в Краї, знайшли та розворушили якийсь архаїчний архів, і цим розбудили Зло, яке собі спокійно дрімало мільйони років. Корабель, в якому, як виявилось була протидія, встиг втекти і потрапив на планету в повільній зоні.&lt;br /&gt;&lt;br /&gt;Надалі, однією з основних сюжетних ліній є опис цивілізації собакоподібних зграй, які населяють ту планету, де приземлився космічний корабель з утікачами. Ці собаки можуть бути розумними лише коли об&#39;єднані в зграю. І вся зграя - це одна особистість. &lt;br /&gt;&lt;br /&gt;Щоб активувати протидію Злу, споряджена експедиція. Пригоди та стосунки членів екіпажу: жінки, чоловіка, який певним чином пов&#39;язаний із Силою, та двох розумних рослин на візках складають іншу сюжетну лінію.&lt;br /&gt;&lt;br /&gt;І все це переплітається повідомленнями із груп новин пародійної всесвітньої мережі &quot;мільйонів неправд&quot;.&lt;br /&gt;&lt;br /&gt;Мені роман сподобався своєю незвичністю. Тепер собак шкода, як же їм, бідним &quot;синглетам&quot; живеться.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/3571837635056757413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/3571837635056757413' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3571837635056757413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3571837635056757413'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/02/blog-post_15.html' title='Вернор Виндж. Пламя над бездной.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-4611967212947931194</id><published>2009-02-02T23:10:00.003+02:00</published><updated>2009-10-13T23:24:26.844+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Books"/><title type='text'>Герберт Уэллс. Машина времени.</title><content type='html'>&lt;a href=&quot;http://lib.aldebaran.ru/author/uyells_gerbert/uyells_gerbert_mashina_vremeni/&quot;&gt;Ця книга&lt;/a&gt; давно була в мене в readlist&#39;і. Нарешті дійшли руки її прочитати. Перед тим як її завантажити, прочитав кілька дуже схвальних відгуків. І мабуть тому від книги очікував більше. Але прочитав із задоволенням, швидко. Перед сном і з ранку в метро.&lt;br /&gt;Головною темою книги є питання соціальної нерівності, яке автор показав в незвичному ракурсі.&lt;br /&gt;&lt;br /&gt;PS. Я думаю, що людству до 8000 року не дотягнути.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/4611967212947931194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/4611967212947931194' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/4611967212947931194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/4611967212947931194'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/02/blog-post_02.html' title='Герберт Уэллс. Машина времени.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-6912215716038341295</id><published>2009-02-01T07:35:00.005+02:00</published><updated>2009-10-13T23:24:26.845+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Books"/><title type='text'>Стивен Хокинг и Леонард Млодинов. Кратчайшая история времени.</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://amphora.ru/book.php?id=832&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 214px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWFVqqusYVgtUVPqcm33mkxGwkSUOmnmb-WEUlLkiK5nBg5F58LV9iUCeOEzgoE61rZBUS1Ngitvym502CUy8qlWR9w_B8lu8JpTT_GMx-LRvzHd4UV-2rGADVn44pihzc9jMP-1H6pa5F/s320/A+Briefer+History+of+Time.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5297699481748537986&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; Прочитав &lt;a href=&quot;http://amphora.ru/book.php?id=832&quot;&gt;чергову книгу&lt;/a&gt; найвідомішого (принаймні для мене) фізика сучасності.&lt;br /&gt;&lt;br /&gt;В цій книзі автор намагається, іще доступніше ніж в своїх попередніх книгах, пояснити будову всесвіту, з точки зору сучасної фізики.&lt;br /&gt;&lt;br /&gt;І дійсно складні речі в книзі пояснені дуже доступно і з цікавими прикладами. Прочитав із великим задоволенням.&lt;br /&gt;&lt;br /&gt;P.S. Але така хитрість автора зі мною не спрацювала. Все рівно нічого не розумію.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/6912215716038341295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/6912215716038341295' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6912215716038341295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6912215716038341295'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2009/02/blog-post.html' title='Стивен Хокинг и Леонард Млодинов. Кратчайшая история времени.'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWFVqqusYVgtUVPqcm33mkxGwkSUOmnmb-WEUlLkiK5nBg5F58LV9iUCeOEzgoE61rZBUS1Ngitvym502CUy8qlWR9w_B8lu8JpTT_GMx-LRvzHd4UV-2rGADVn44pihzc9jMP-1H6pa5F/s72-c/A+Briefer+History+of+Time.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-2859159140534659674</id><published>2008-10-30T07:17:00.007+02:00</published><updated>2009-02-15T09:33:53.956+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NUnit"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Testing"/><title type='text'>Unit testing #2. NUnit constraint-based Asserts</title><content type='html'>Починаючи з версії 2.4 в NUnit реалізовано новий стиль assert&#39;ів. Ця модель використовує один метод Assert.That(args) для всіх тверджень. Логіка виконання кожного твердження перенесена в другий параметр. Ось декілька прикладів:&lt;br /&gt;&lt;pre class=&quot;csharp&quot;&gt;Assert.That(10.0/3.0, Is.EqualTo(3.33).Within(0.01f));&lt;br /&gt;Assert.That(2*2, Is.Not.EqualTo(5));&lt;br /&gt;Assert.That(new object(), Is.Not.Null);&lt;br /&gt;Assert.That(string.Empty, Is.Empty);&lt;br /&gt;Assert.That(&quot;abc&quot;, Has.Length(3));&lt;br /&gt;Assert.That(new string[] {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;}, Is.All.Not.Null);&lt;br /&gt;&lt;/pre&gt;Також можна комбінувати constraints.&lt;br /&gt;&lt;pre class=&quot;csharp&quot;&gt;Assert.That(3, Is.LessThan( 5 ) | Is.GreaterThan( 10 ));&lt;br /&gt;Assert.That(&quot;s&quot;, !Is.Null));&lt;/pre&gt;Для того щоб працювати з новим стилем потрібно використати:&lt;br /&gt;&lt;pre class=&quot;csharp&quot;&gt;using NUnit.Framework.SyntaxHelpers;&lt;br /&gt;&lt;/pre&gt;Цей стиль мені подобається більше ніж &lt;a href=&quot;http://www.nunit.org/index.php?p=classicModel&amp;amp;r=2.4.8&quot;&gt;класичний&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Детальніше - на сторінці &lt;a href=&quot;http://www.nunit.org/index.php?p=constraintModel&amp;amp;r=2.4.8&quot;&gt;Constraint-Based Assert Model &lt;/a&gt;документації NUnit .</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/2859159140534659674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/2859159140534659674' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2859159140534659674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2859159140534659674'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2008/10/unit-testing-2-nunit-constraint-based.html' title='Unit testing #2. NUnit constraint-based Asserts'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-2902417838402813074</id><published>2008-10-29T08:07:00.010+02:00</published><updated>2008-10-29T09:23:06.409+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NUnit"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Testing"/><title type='text'>Unit testing #1</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM5b4eCPAepeQGRe9Ryxmj-_3Linvmh4EFWC2JrEeaiAFh3SWFWpChyphenhyphentnQQmbkncUQTHjJcc2nS1PbUfTZRe3k2ctvv60Ou_yIUH_hyphenhyphen8pdYs7TZQKzRa1POlkkffAKy5ytFAmz1PD5fQIn/s1600-h/utc2.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 190px; height: 228px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM5b4eCPAepeQGRe9Ryxmj-_3Linvmh4EFWC2JrEeaiAFh3SWFWpChyphenhyphentnQQmbkncUQTHjJcc2nS1PbUfTZRe3k2ctvv60Ou_yIUH_hyphenhyphen8pdYs7TZQKzRa1POlkkffAKy5ytFAmz1PD5fQIn/s320/utc2.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5262458498435631602&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Я знову вирішив щось написати. Справа в тому, що я почав читати книгу &lt;a href=&quot;http://www.pragprog.com/titles/utc2/pragmatic-unit-testing-in-c-with-nunit&quot;&gt;&quot;Pragmatic Unit Testing in C# with NUnit&quot;&lt;/a&gt; by Andy Hunt and Dave Thomas with Matt Hargett. І ось, вночі, коли я прочитав перші сторінки, я подумав - &quot;Круто, прочитав лише кілька сторінок, а вже виніс для себе чотири нових речі про які не знав раніше. А наступного дня, коли на роботі розказував, що книжка цікава, що я дізнався чотири нових штучки, ніяк не міг згадати, а про яку ж все-таки четверту річ я дізнався. От три пам&#39;ятаю а четверту ні. Отже треба ці знання записувати. Тут їм і буде місце.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Тіп #1. &quot;Ommit the &lt;/span&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt; string for reporting unless you really need to&quot;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ось класичний синтаксис Assert в NUnit:&lt;br /&gt;&lt;pre&gt;Assert.AreEqual(expected, actual [, string message])&lt;/pre&gt;Автори рекомендують не включати текстовий рядок для пояснення тесту, крім випадків коли це дійсно необхідно. Краще коли ім&#39;я тесту самостійно пояснює призначення самого тесту, коли використовуються доречні методи Assert&#39;а, або тест розбивається на декілька методів, щоб залишатися сконцентрованими на конкретних тестових випадках.&lt;br /&gt;&lt;br /&gt;Що ж в цій практиці революційного і чому вона нова для мене? Не знаю. Просто я чомусь часто писав ці текстові пояснення в NUnit Assert&#39;ах. Мабуть це був вплив StyleCop, який змушує завжди писати пояснення для методу System.Diagnostics.Deиug.Assert. А тепер не буду, звісно крім випадків, коли це дійсно необхідно :).</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/2902417838402813074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/2902417838402813074' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2902417838402813074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2902417838402813074'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2008/10/unit-testing-1.html' title='Unit testing #1'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM5b4eCPAepeQGRe9Ryxmj-_3Linvmh4EFWC2JrEeaiAFh3SWFWpChyphenhyphentnQQmbkncUQTHjJcc2nS1PbUfTZRe3k2ctvv60Ou_yIUH_hyphenhyphen8pdYs7TZQKzRa1POlkkffAKy5ytFAmz1PD5fQIn/s72-c/utc2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-7441615525813611</id><published>2008-07-02T23:00:00.003+03:00</published><updated>2009-10-13T23:26:39.123+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Relax"/><title type='text'>Двоколісний друг</title><content type='html'>Нарешті купив мотик. Yamaha YBR 125. Або просто &quot;йобр&quot;, чи &quot;юбка&quot;. Уже встиг впасти :). Фотки потім.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/7441615525813611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/7441615525813611' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/7441615525813611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/7441615525813611'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2008/07/blog-post.html' title='Двоколісний друг'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-3594526220378822145</id><published>2008-06-02T22:41:00.003+03:00</published><updated>2009-10-13T23:28:58.322+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Finance"/><title type='text'>Інвестиційний портфель</title><content type='html'>Натрапив на сайт &lt;a href=&quot;http://www.investportfel.com&quot;&gt;Мой инвестиционный портфель&lt;/a&gt;, який дозволяє контролювати та аналізувати свої інвестиційні вклади. Я для таких цілей використовував spreadsheets в Google docs. Мушу визнати що користуватися новим ресурсом значно простіше.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/3594526220378822145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/3594526220378822145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3594526220378822145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/3594526220378822145'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2008/06/blog-post.html' title='Інвестиційний портфель'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-6055103743651245288</id><published>2008-04-11T00:05:00.003+03:00</published><updated>2009-10-13T23:26:55.944+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tip"/><title type='text'>Як перезавантажити IPod</title><content type='html'>Що робити коли завис IPod? Перезавантажити. Як це зробити описано &lt;a href=&quot;http://docs.info.apple.com/article.html?artnum=61705-ru&quot;&gt;тут&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/6055103743651245288/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/6055103743651245288' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6055103743651245288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/6055103743651245288'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2008/04/ipod.html' title='Як перезавантажити IPod'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8619358898227991199.post-2596795136124078187</id><published>2008-03-31T22:53:00.002+03:00</published><updated>2009-10-13T23:23:18.113+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Books"/><title type='text'>Николай Гаврилович Чернышевский: Что делать?</title><content type='html'>&lt;blockquote&gt;Кто не изучил человека в самом себе, никогда не достигнет глубокого знания людей.&lt;/blockquote&gt;Сильний твір! Розумний і непростий. Чомусь не можу дібрати слів, щоб описати про що саме ця книга. Мабуть про стосунки людей, про місце особи в суспільстві, про особистість... Не знаю, якось складно передати враження від роману в двох словах. Та мабуть цього й не варто робити...&lt;br /&gt;Комусь твір може здатись неактуальним для нашого часу. Так я з кимось не погоджусь. Одним словом, раджу читати &amp;mdash; книга точно не залишить Вас байдужим.</content><link rel='replies' type='application/atom+xml' href='http://korneliuk.blogspot.com/feeds/2596795136124078187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8619358898227991199/2596795136124078187' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2596795136124078187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8619358898227991199/posts/default/2596795136124078187'/><link rel='alternate' type='text/html' href='http://korneliuk.blogspot.com/2008/03/blog-post_31.html' title='Николай Гаврилович Чернышевский: Что делать?'/><author><name>Ivan Korneliuk</name><uri>http://www.blogger.com/profile/12117983842614711809</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>