mBerube.net
A journey to .Net

Using NDepend to analyse Protobuf

Monday, 14 November 2016 17:40 by mBerube
(Also available in: français)

As an academic assignement, we were asked to analyse the architecture of the Google Protobuf open source project. Protobuf is the communication protocol used by Google to communicate between processes (see the official site). The project also comes with compilers to generate access classes for many languages live Java, Ruby, C#, etc. Being a .Net developer for years, it was natural for me and my teammate to focus on the C# library of Protobuf. To analyse the architecture of the C# module, we used a really nice tool, NDepend. NDepend is a sophisticated analytic tool for .Net projects that give a lot of informations about code architecture and code quality.

What have we found

Using the different graphs provided by NDepend, we were able to find some really interesting facts :

  1. The abstraction level of the code is pretty good (see graph 1)
  2. The authors have been able to manage dependencies pretty well, having only 2 cross-referencing between namespaces (there's only one assembly in the core project) (see graph 2).

This is really interesting informations and there's many more available in the tool but what NDepend was the most usefull for us is to quickly analyse the architecture and be able to see that it's, in fact pretty simple (see graph 3)

 

My experience with the tool was good and I plan to continue using it during the remaining classes of my master degree. I'll most certainely pass the information to my employer because there's a lot in that product to improve the quality of our softwares.

 

Give it a try and thanks NDepend for such a quality product.

 

Graph1

 

 

Graph 2

 

 

Graph 3

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .Net | NDepend
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRss comment feed

Installing MongoDB as a Windows Service

Wednesday, 27 April 2016 21:20 by mBerube
(Also available in: français)

For a new project, I decided to give MongoDB a try. It works great but I always have to look for the documentation to install MongoDB as a Windows Service so as a reminder for me (and also for you dear readers), here's the steps :

  • Download MongoDB from https://www.mongodb.org/downloads
  • Run the installer
  • Create a data folder. It can be anywhere on the disk but for dev purpose, the same folder as the mongo installation is good. In it, create 2 subfolders, db and logs
  • Create a configuration file (for this exemple c:\devtools\mongodb\mongod.cfg) to configure paths for database and log folders. Ex:
systemLog:
    destination: file
    path: C:\DevTools\MongoDB\data\log\mongod.log
storage:
    dbPath: C:\DevTools\MongoDB\data\db

  • In a command prompt (as administrator), use the following command : .\bin\mongod.exe --config c:\devtools\mongodb\mongod.cfg --install
  • Make sure the service is running and is set to automatic start by opening the service window (services.msc)
  • To test that your installation of mongoDB is working, you can use the fantastic Robomongo tool, a UI interface to MongoDB

That's it. Please give it a try and for further informations, you can see the mongoDB official windows installation documentation page. To learn more about how to use MongoDB in .Net, you can see the great Wes Higbee Pluralsight course Using MongoDB with ASP.Net MVC

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRss comment feed

Integrating Git into Visual Studio 2010

Saturday, 24 July 2010 00:10 by mBerube
(Also available in: français)

In the previous post, I talked about Git, a distributed version control system. The classic way to use Git is to use the bash command line. But if you use Visual Studio, you have some extensions you can use to integrate all the goodness of Git into your favourite IDE. Although I still need the command line tool to do some tasks like doing rebase and dcommit on the subversion server, most of the things you need during development are available in your IDE.

Git source control provider

This extension (downloadable from the visual studio extension gallery) set Git as your source control provider. This tool is pretty limited but have 3 interesting features :

  • It displays the name of the current working branch at the top of the solution explorer
  • It shows the status of the files in the solution explorer (added, modified or unchanged)
  • It give a shortcut to open the Git bash windows in a specific solution folder

git source control provider

This extension by itself give really basic functionalities but with the addition of the git extensions for visual studio, it becomes more interesting.

Git Extensions

This extension can be downloaded from Google code and add many Git commands into Visual Studio and Windows Explorer. You can see in the picture above that Git source control provider include a shortcut for Git Extensions but you can use it by itself.

In Visual Studio, Git extensions add a new tool bar and a new menu into the IDE. By these menus and toolbars, you can do much of the day to day work with Git (you can see the new tool bar in the red circle).

git extensions menus

To be honest, I don’t know yet what all these options do but here’s a quick explanation for some of them :

  • Checkout branch : switch from the current branch to another branch. More details on this in a following post.
  • Commit : commit the change in the current branch to the local repository. See below the picture of the commit window.
  • Edit .gitignore. Allow you to set the .gitignore file for your local repository. You can do it manually but if you’re a .Net developer, I suggest you take the default template for .Net that exclude all the temp files. So far, I don’t find any missing files or files that should be exclude.
  • For all the remote features (Manage remotes, pull, push, rebase, etc.), I didn’t try them yet because I never used a remote Git repository for now.

Some more explanations about the commit process. When you want to commit something, you open the commit window :

git commit window

In the top left part, you select the files you want to commit and you click "Stage selected file” to include them in the commit. You must enter a comment in the right bottom section and click “Commit” to confirm. If the file has a change status “Untracked”, it means it’s a new file and the code part (top right) will show the source code. If the status of the file is “Modified”, the code part will show a diff between the 2 versions. Really useful. If you want to rollback a change to the previous version, select the file(s) to want to be rolled back and click “Reset changed”.

I think that’s enough for now. Next post, I’ll talk about branching and merging with Git, with both Git Bash and Git Extension.

Thanks, happy programming.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Git | Programmer life
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRss comment feed

From SVN to GIT

Wednesday, 21 July 2010 15:07 by mBerube
(Also available in: français)

As you already know if you read that blog as religiously as you should, I’ve setup a dev server for my experiments at home. I’m using Visual SVN server as my source control tool but I work more and more on my laptop now and from many places where I don’t necessarily have a WiFi access.  It means that I can spend many days with uncommitted changes of my programs and I don’t like it because it’s really a pain to undo some work. I heard many times about Git which is a distributed version control system and allow you to have a complete repository locally on your computer. You can do many commit, branches and merges on your local repository and when you can connect to your remote repository, you can then push the changes so the others developers can use your updated version of the code. You can also pull the code for the remote repository to update your local copy of the code.

What is best for a Subversion user like my, is that you can still use Subversion as your remote repository and use Git as your local repository. That’s what I’ve tried and here’s the steps I took to go from svn to Git on my Windows 7 machine and to integrate all this in Visual Studio.

First, you must download the installer for Git and install the package. Make sure to check the Git Bash and Git GUI windows explorer integration, it’s really useful. Git Bash is really useful for all administrative tasks in Git. Git GUI is supposed to help with commit and branching but I preferred the Git extensions for Visual Studio for these tasks. More on this in my following posts.

Now that you have that, you can clone your Subversion repository locally. Using Git Bash, navigate to the folder where you want to create your repository and use the following command :

git svn clone –s https://mysuberversionserver/svn/myrepository/trunk

Of course, your replace the URL by your subversion project URL. At this stage, it’s recommended to set your .gitignore file. This file contains all the files and directories that you’ll want to exclude from git version tracking. There’s a lot of pages on the web about how to setup your .gitignore file so I wont give any specific details here (also, mostly because git extensions for Visual Studio contains a default template for .Net developer that already exclude all the temp file that doesn’t belong in the source control).

You have created your local git, now bring back the source from your svn :

git svn fetch

Your only need this the first time to create your first copy. After that, you’ll only do updates of the files. It’ll be a lot faster. You can start to do some changes locally and as you work, git will track all the files that are modified. When you’re done, you can use the commit command to post your changes on the local repository :

git commit

There’s many switches to the commit command. I’ll not mention all of them here but there’s a good one to check what will be committed without doing it:

git commit –v –dry-run

When you’re ready to push your changes to the remote svn repository, you can use the following command:

git svn dcommit

Here again, there’s a really useful command to check what changes will be push on the remote svn repository before doing it. It will show the name and the status of all the local files that are different from the remote repository:

git diff ..remotes/git-svn --name-status

You can finally get the changes from the other contributors on the remote repository by using :

git svn rebase

Ok, that’s it for the git svn quick tutorial. In the next post, I’ll talk about the Visual Studio extensions you can use to simplify the common tasks with git. I’ll also talk about branching with git and about some customizations you can do to speed up your workflow.

Thanks, happy developing

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Git | Programmer life
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRss comment feed

From IIS 6 to IIS 7.5 : not as easy as it looks

Sunday, 27 June 2010 15:23 by mBerube
(Also available in: français)

I wanted to do some changes to my blog engine yesterday. I took my production code which run perfectly at my hoster on IIS 6 and I put it on my dev server on IIS 7.5. Nothing worked ! Error 401 (authentication) on every pages, even with Accept Anonymous request enabled. After many tries and searches, here's what I did to make it work, hopping it could be usefull for some of you :

  • 1st, I've created the application and put it in the Classic .Net AppPool
  • I verified that the default document was default.aspx. It wasn't so I put it on the top of the list.
  • Then, I checked if the user of the appPool had the required rights on the files. It's a little bit harder to check with IIS 7 because every appPool has a custom user. The only thing to check is that the IIS_IUSRS group has the required rights on the folder and it was ok.
  • It still doesn't work. I then saw on a blog post that even if you gave Anonymous user access to the site, you still need to setup which user to use as ananymous. My error was there and as soon as I put the anonymous user credential to "Application Pool Identity", boom, everything worked perfectly.

There's one last problem with an easy workaround but I still not understand. When i use the url http://myservername/blog (with a lower case b), it doesn't work BUT with the url http://myserbername/Blog (with an upper case B), it works? The application name is "Blog" but I didn't think that IIS treat URL as case sensitive. I will continue to look for that and I will keep you in touch.

Thanks, happy developping.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   BlogEngine.NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRss comment feed