1. NuGet without committing packages to source control

    Several days ago switched to new approaching of working with NuGet by enabling NuGet Package Restore featrure. From now packages aren’t being stored into source control. Instead NuGet download missing packages during build. So far so good. …


  2. Entity Framework (EF), UnitOfWork & Repository patterns

    There are some debates on the network about if we need to add abstraction layer on the top of Entity Framework. Or it’s redundant. Sure, I have my own opinion as well Smile Entity Framework (EF) object context provides us ability to make whatever we want with any table in database. So if our business logic uses EF directly our data access code will be spread through it.  Me personally like Persistence Ignorance pattern so business logic shouldn’t be aware of the data layer details. Furthermore I like then each repository contains some related methods. Usually it’s something like UserRepository, ChangeRepository, PostRepository, etc. It helps to structure code since in this case we don’t have huge repositories. EF implements UnitOfWork pattern and that’s amazing. So that we did in our last project is used EF object context as UnitOfWork and passed it to our Repositories. (it was wrapped into IUnitOfWork, probably I’ll post some technical details later) We used Code First approach and all our POCOs were located in the Model. So business logic worked with Model not with data. That’s worked like a charm. We got clean data layer and business logic. It’s very easy to unit test and maintain. …


  3. Distributed version control (DVCS)

    For a long while I was interested to try out some DVCS. The problems caused me to not do that was really simple – which one to choose Mercurial or git? I read some technical articles and came to a conclusion that Mercurial has better merge capabilities. Unfortunately I don’t have links to these articles (I read them several months ago) But what I like about git is that it has a huge community and that’s why there are many neat tools for it. For example there is a two-way bridge between TFS and Git. Today I came over Mercurial, Subversion, and Wesley Snipes article and Eric Sink says there:

    But if I were choosing a DVCS as a regular user, I would choose Mercurial. I've used it some, and found it to be incredibly pleasant.  It seems like the DVCS that got everything just about right.
    But in my particular case of .NET development using VS 2010… Mercurial isn’t seem that simple to use. Here’s some information on Real-world use of Mercurial with a Team Foundation Server. On the other hand there is a plug-in that integrates git with Visual Studio and a two-way bridge between TFS and Git. So it seems git wins a competition for me… at least for now. …


  4. primaryGroupToken via C# from Active Directory (AD)

    I needed to change Primary Group of the Active Directory user programmatically (via C#). I found a good example in PowerShell. But it wasn’t obvious for me on how to convert the following code fragment into C#:

    $NewGroup = [ADSI]"LDAP://CN=Domain Guests,CN=Users,$DomainNC"
    $NewGroup.GetInfoEx(@("primaryGroupToken"), 0)
    $NewGroupToken = $NewGroup.Get("primaryGroupToken")
    
    So here is it, just in case it isn’t obvious for you as well ;)
    group.Invoke("GetInfoEx", new object[] { new object[] { "primaryGroupToken" }, 0 });
    object primaryGroupToken = group.Invoke("Get", new object[] { "primaryGroupToken" });
    


  5. Command Query Responsibility Segregation (CQRS) pattern

    I’ve just read excellent introduction to the Command Query Responsibility Segregation (CQRS) pattern. And you know, it seems really worthy to have in a toolbox.
    Actually just to be ready to use it I’ll need to research many related patterns such as Reporting Database, Event Sourcing, etc..
    So check it yourself - read this great CQRS introduction to see how many useful patterns and practices those are related to CQRS you don’t know yet ;) …


  6. MSpec and TFS Build Service (MSMSpec)

    If you are going to use MSpec in your next .NET project you could face the following issues:

    1. Visual Studio won’t be able to execute MSpec specifications. (MSpec has it’s own test engine)
    2. TFS Build Service is able to run only MSTest.
    I found several articles on that problem in search engine. The best solution I found was MSMSpec. I’m very appreciate the work HeartattacK had done since it really helped me! MSMSpec is a T4 template which creates MSTests based on your MSpec classes. So it provides us ability to run MSpec specs in Visual Studio and in TFS Build Service, calculate Code Coverage and Test Impact using MS tools. Here’s my approach to get it working:
    1. I added MSMSpec.tt to the solution items. And added its as a link to each MSpec project.
    2. I made TestExecutionHelper class internal. It was public initially, so if one MSpec project is referencing another, public TestExecutionHelper will result in a conflict. (since both assemblies are declaring the same class). MSMSpec author suggests another workaround but it doesn’t fit my need since I use shared MSMSpec.tt.
    3. I added 108 to the suppress warnings list in all MSpec projects. (to suppress “_Setup hides inherited member. Use the new keyword if hiding was intended” warning)
    4. Finally I fixed Cleanups execution order (Parent class Cleanup should be called after Child class Cleanup):
    1. //var cleanupInfos = FilterByType<Cleanup>(fieldInfos);
    2. var cleanupInfos = FilterByType<Cleanup>(fieldInfos).Reverse();
    Thant’s it. Hope this helps someone! …


  7. Team City: Windows Authentication

    There is detailed article on how to configure different authentication modes in Team City. But it lacks some information… Let consider the following example:

    1. You setup Team City
    2. Configured Project in it
    3. All went fine and now you need to configure user access
    4. So you switched Team City to Windows Authentication
    5. Now you can login with you Domain credentials, but you can’t give administrator rights to any user since you don’t have administrator yet
    So I found the following workaround:
    1. Login using Default Authentication Mode as Administrator in the Browser #1
    2. Switch Authentication Mode to Windows Authentication
    3. Login in as a Windows Domain User in the Browser #2
    4. In the Browser #1 open Users and Groups
    5. You will see newly created user account for Windows Domain User logged in using Browser #2
    6. You can select this account and give it administrative rights


  8. Automated Build Usage Example

    A problem

    Do you have a manager on a project? Does (s)he use Visual Studio to review new versions? For me the answer was Yes for the both above questions on the last project I was involved on. It’s a real pain to start Visual Studio just to build an run application, isn’t it? I think so, since to be honest it will take a while…
    • Wait Visual Studio to be started
    • Get latest source code
    • Wait until Visual Studio will load a project
    • And finally we need to build a project.


  9. Peopleware: Productive Projects and Teams

    Peopleware is a really amazing book. IMHO it isn’t just for managers or management people, but to the all people engaged in collaboration. So please consider to read it since I’m sure it will provide a lot of joy for you! Some great quotation.

    • The manager's function is not to make people work, but to make it possible for people to work.
    • There are a million ways to lose a work day, but not even a single way to get one back.
    • Quality—If Time Permits
    Among other things book states that productivity heavily depends on the working environment. The main negative factor is Interruptions and Noise. So companies should stop saving money on the office space. Since in that case they will pay hidden cost on the productivity drop. So it’s much better to provide nice (required?) working environment to the employees to make them happy and receive productivity boost. As about Signal & Noise issue. The authors stated that Phone (I’m sure it’s related to the Skype calls as well) usage should be avoided in the most cases. If you really need an immediate answer to continue your work, then phone should be your choice. In other case they recommend to use e-mail. All we need to be able to rely on e-mail is just to come to the agreement that e-mail will be checked with reasonable frequency.
    People must  learn  that it's  okay sometimes not to answer their phones, and they just learn that their time—not just the quantity but its quality—is important.


  10. Erlang and web development

    First off all what is Erlang? Here’s description from the http://www.erlang.org/

    Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance
    First time I heard about Erlang was way back into 2007. At that time I thought about it as a great choice for development of the server applications such as game servers, instant messaging, etc. Recently I was wondering if are there any Erlang frameworks for web development exists. And as you probably expected there are Many frameworks. I made some research of the Chicago Boss. And you know it’s just awesome! One of the greatest features is Zero downtime code upgrades in production. I’m sure Chicago Boss doesn’t so mature as for example ASP.NET. But you know ASP.NET is a general solution. You can build any kind of web application using it. It could be regular HTML pages or highly interactive single-page application or just web service. I suppose Erlang (and Chicago Boss) are more specialized. For example if I plan to build web site with regular HTML pages I probably will rely on ASP.NET (or PHP). But for single-page applications with requirements on high availability I will consider Erlang (Chicago Boss) + HTML5 (jQuery, Knockout) …