Monthly Archives: January 2012

Windows Fonts Megapack [Free Download]

Update 1/31/2012: As MegaUpload was taken down, I moved the font zip to mintywhite servers (and got by the 20 MB file limit.) Please only download if you want a ton of fonts. The file is quite large (79.3 MB) but hopefully it’s quite convenient (plus, all the applicable licenses and credit is included for [...]

Windows Fonts Megapack [Free Download]

Update 1/31/2012: As MegaUpload was taken down, I moved the font zip to mintywhite servers (and got by the 20 MB file limit.) Please only download if you want a ton of fonts. The file is quite large (79.3 MB) but hopefully it’s quite convenient (plus, all the applicable licenses and credit is included for [...]

Microsoft Exchange PST Capture v.14.03.0016.004

Microsoft Exchange PST Capture v.14.03.0016.004 is available to download.

Overview
Microsoft Exchange PST Capture is used to discover and import .pst files into Exchange Server or Exchange Online.

Overview
PST Capture is used to discover and import Outlook Personal Folder (.pst) File Format files into Exchange Server and Exchange Online. PST Capture helps an organization that wishes to gain more control over their email data repositories by placing them into Exchange. By optionally installing PST Capture Agents on target machines, administrators can determine where .pst files are located and who their file owner is via the PST Capture Console. Administrators can import .pst files via Import Lists to Exchange Server or Exchange Online. Data can be directly imported into the primary mailbox or associated archive mailbox.

Related Links:

Windows 7 : Que faire pour optimiser le système ?

Pat842Hello tout le monde,

Vous avez achet√© voici un an ou deux l’ordinateur dernier cri de vos r√™ves, dot√© du meilleur processeur avec de la m√©moire plus qu’il n’en faut Clignement d'Ňďil 
Seulement voil√†, c√īt√© vitesse, ce n’est plus du tout ce que c’√©tait dans le pass√© !

" Que puis-je faire pour changer tout ça " vous martelez-vous ?

Il existe plusieurs moyens d’am√©liorer les performances de Windows, en mettant ou pas le mat√©riel √† niveau. Voyons cela…

Pointer vers le haut D√©sinstaller les programmes non utilis√©s. Que ce soient des versions limit√©es et plus utilisables, fournies par le constructeur de votre machine ou bien des programmes que vous avez install√© sans plus les300x250_Techdays_2012 utiliser, retirez-les de votre disque dur.
Garder ces logiciels sur votre ordinateur peut le ralentir en utilisant un espace mémoire, un espace disque et une puissance de traitement précieux.

Certains utilitaires d‚Äôoptimisation sont param√©tr√©s pour s‚Äôex√©cuter au d√©marrage √† un moment o√Ļ vous en aviez besoin pour r√©gler un probl√®me‚Ķ Ces utilitaires ont-ils toujours leur place sur votre machine ? Doivent-ils toujours s‚Äôex√©cuter en arri√®re-plan au risque d‚Äôencombrer l‚Äôespace m√©moire ?

Pointer vers le haut Limitez le nombre de programmes s’ex√©cutant au d√©marrage
Beaucoup de programmes sont conçus pour se charger automatiquement au imagedémarrage de Windows.

Les √©diteurs de logiciels r√®glent souvent leurs programmes pour qu’ils op√®rent en arri√®re-plan. Est-ce bien n√©cessaire ?
D√©cidez vous-m√™me des programmes que vous voulez voir s’ex√©cuter au d√©marrage.

Si vous n’√™tes pas s√Ľr de vouloir qu’un programme s’ex√©cute automatiquement au d√©marrage (voir l‚Äôutilisation de msconfig.exe), vous pouvez le d√©sactiver, red√©marrer votre ordinateur, puis utiliser ce programme. Si cela cause le moindreimage probl√®me, vous pouvez r√©activer son ex√©cution automatique.

Pointer vers le haut D√©fragmenter votre disque dur
Pour ouvrir le Défragmenteur de disque, cliquez sur le bouton Démarrer, sur Tous les programmes, sur Accessoires, sur Outils système, puis sur Défragmenteur de disque. Si vous êtes invité à fournir un mot de passe administrateur ou une confirmation, fournissez le mot de passe ou la confirmation (Exclure les disques SSD de la défragmentation).

La défragmentation du disque dur est automatique. Pensez à modifier l’heure à laquelle elle s’exécute (Configurer la Planification).

Pointer vers le haut Nettoyer votre disque dur
Votre disque se rempli quotidiennement de fichiers inutiles, obsolètes dont vous n’avez aucune utilité. Tous ces fichiers ralentissent votre ordinateur et prennent une place inutile quelquefois conséquente après plusieurs mises à jour du système.

Pour cela, utilisez l’outil Nettoyage de disque :
Pour ouvrir le Nettoyage de disque, cliquez sur le bouton Démarrer, sur Tous les programmes, sur Accessoires, sur Outils système, puis sur Nettoyage de disque.

Pointer vers le haut D√©sactivez les effets visuels
Si vous pr√©f√©rez que Windows soit plus rapide que beau, ceimage param√©trage est fait pour vous. Vous pouvez agir ainsi sur pr√®s de 20 effets visuels pour gagner en performance. 
Cette configuration est à privilégier si les performances matérielles de votre machine sont un peu à la traine.

Pour cela, cliquez sur Panneau de configuration, Système et sécurité, Lien Paramètres Système avancés. Dans la zone Performance, cliquez sur le bouton Paramètres.

Pointer vers le haut Red√©marrer de temps en temps votre machine
Si vous laissez souvent votre machine se mettre en veille ou en veille prolongée, pensez à la redémarrer de temps à autre.
Quelquefois, des problèmes de performance sont simplement liés à des services toujours en mémoire sans avoir été arrêtés par le logiciel qui les a utilisés.
De plus, un redémarrage permet de nettoyer la mémoire.

Pointer vers le haut Ajouter de la mémoire
Windows Vista / Windows 7 ont besoin de 2 Go pour fonctionner normalement; quoique Vista soit un peu plus gourmand. Si vous êtes fan du traitement d’images et de vidéos et du travail avec plusieurs logiciels ouverts en même temps, n’hésitez pas, si vous le pouvez à pousser à 4 Go la quantité de RAM installée.
A savoir, sur une machine 32 bits (x86) seuls les les premiers 3.2 Go sont réellement utilisés par le système; les 800 Mo restants sont utilisés par le système qui place les pilotes en mémoire.

Pensez √©galement  √† l‚Äôutilisation de ReadyBoost‚Ķ

Pointer vers le haut Lancez-vous à la pêche aux virus
Votre ordinateur s’exécute lentement ? Les virus ralentissent souvent de façon anormale les performances de l’ordinateur. Autres signes possibles : des messages intempestifs inattendus, des programmes qui démarrent automatiquement ou votre disque dur en travail constant.

Pas d’anti-virus ? Ohhh, quand même pas ! Voir ici ce que vous pouvez entreprendre…

Et puis, dernière chose qui est en fait la primordiale : Gardez votre système à jour. Faites-en sorte que les mises à jour s’exécutent automatiquement. Pour cela :

  • Cliquez sur Panneau de configuration, Syst√®me et s√©curit√© puis sur, Windows Update
  • Cliquez sur le lien Modifier les param√®tres,
  • S√©lectionnez Installer les mises √† jour automatiquement,
  • S√©lectionnez Installer les nouvelles mises √† jour Tous les jours,
  • S√©lectionnez une heure √† laquelle votre machine est le plus souvent en fonctionnement.

image

Bonne soirée.
Patrice.

3326_image_7DAAB7DA

Hide Account Usernames in Windows for Extra Security [How To]

If you use online banking, you may have noticed when you get your password wrong that the error in response is pretty generic i.e. “Wrong user name or password.” These error messages are pretty unhelpful; however, this is by design. If someone tries to compromise your account, do you really want them knowing they got [...]

Hide Account Usernames in Windows for Extra Security [How To]

If you use online banking, you may have noticed when you get your password wrong that the error in response is pretty generic i.e. “Wrong user name or password.” These error messages are pretty unhelpful; however, this is by design. If someone tries to compromise your account, do you really want them knowing they got [...]

Have you tried switching it on and off again? Go on be aggressive!

We have been building ‚Äėstandard‚Äô environments for our TFS Lab Management system. Environments that can be used for most of the projects we are involved in without too much extra setup e.g. a small domain controller VM and a Server VM with SQL and SharePoint. These environments have a series of snapshots so it can be used in a number of ways e.g if we just want SQL and IIS we just go back to a snapshot prior to SharePoint being installed.

When trying to deploy one of these environments we saw a couple issues.

Capacity

First we got the error that there was not a suitable host with enough capacity to host the environment (remember all the VMs in a network isolated environment need to be on the same Hyper-V host). This can be a bit of a red herring as with dynamic memory and other new Hyper-V features there is often the capacity there (see Tiago’s post on this for more details). The fix here was to set TFS to allow aggressive deployment using the command

C:Program FilesMicrosoft Team Foundation Server 2010Tools>tfsconfig lab /hostgroup /collectionName:myTpc  ‚Äč/labenvironmentplacementpolicy:aggressive /edit /Name:"My hosts group"

Initial Startup

The next problem I saw was that when the new environment was deployed it did not started cleanly. The first time an environment is started it seems to take longer than subsequent starts (assume there is some initial configuration done). Basically in this case network isolation did not start correctly, hence build and testing capabilities also failed.

The fix was simple, shut down the environment and start it again. The tried and trusted IT answer to all problems. This time it started fine, and was faster to start.

Now I have not see this issue every time I deploy. When I deployed the same environment again and it worked perfectly first time. I suspect it was really a capacity issue on the underlying Hyper-V server causing some delay, but I am running in aggressive mode so I should expect this.

Have you tried switching it on and off again? Go on be aggressive!

We have been building ‚Äėstandard‚Äô environments for our TFS Lab Management system. Environments that can be used for most of the projects we are involved in without too much extra setup e.g. a small domain controller VM and a Server VM with SQL and SharePoint. These environments have a series of snapshots so it can be used in a number of ways e.g if we just want SQL and IIS we just go back to a snapshot prior to SharePoint being installed.

When trying to deploy one of these environments we saw a couple issues.

Capacity

First we got the error that there was not a suitable host with enough capacity to host the environment (remember all the VMs in a network isolated environment need to be on the same Hyper-V host). This can be a bit of a red herring as with dynamic memory and other new Hyper-V features there is often the capacity there (see Tiago’s post on this for more details). The fix here was to set TFS to allow aggressive deployment using the command

C:Program FilesMicrosoft Team Foundation Server 2010Tools>tfsconfig lab /hostgroup /collectionName:myTpc  ‚Äč/labenvironmentplacementpolicy:aggressive /edit /Name:"My hosts group"

Initial Startup

The next problem I saw was that when the new environment was deployed it did not started cleanly. The first time an environment is started it seems to take longer than subsequent starts (assume there is some initial configuration done). Basically in this case network isolation did not start correctly, hence build and testing capabilities also failed.

The fix was simple, shut down the environment and start it again. The tried and trusted IT answer to all problems. This time it started fine, and was faster to start.

Now I have not see this issue every time I deploy. When I deployed the same environment again and it worked perfectly first time. I suspect it was really a capacity issue on the underlying Hyper-V server causing some delay, but I am running in aggressive mode so I should expect this.

Windows Phone 7.5 et FREE Mobile : Histoire de pictogrammes

Bonjour tous,




Nous utilisons notre nouveau forfait Free Mobile. De nouveaux pictogrammes apparaissent comme l’itinérance, pas habitué à voir cela…
Je vous ai donc “collé” ces informations en provenance du site Windows Phone afin de “tout” savoir sur ce qu’il apparait au niveau de votre interface favorite ;-)


Appuyez en haut de l’écran de votre téléphone pour accéder instantanément à des informations sur la connectivité réseau, la puissance des signaux, la charge de la batterie, l’heure, et bien plus.


La barre d’état s’affiche également pendant quelques instants quand des éléments changent sur votre téléphone. Vous disposez ainsi d’informations spécifiques sur l’appareil en temps opportun. Par exemple, si votre batterie est faible, la barre d’état affiche une icône le signalant.


Ordre d'affichage des icônes dans la barre d'état



L’illustration suivante montre l’ordre dans lequel les icônes apparaissent dans la barre d’état avec les descriptions correspondant à chacun d’elles.


1. Puissance du signal de réseau mobile


Icône de signal très puissant

Puissance de signal très élevée

Icône de signal puissant

Puissance de signal élevée

Icône de signal moyennement puissant

Puissance de signal moyenne

Icône de signal faible

Puissance de signal faible

Icône de signal très faible

Puissance de signal très faible

Icône de non-détection de signal

Puissance de signal extrêmement faible

Icône d'absence de signal

Il n’y a pas de signal parce que votre téléphone n’est connecté à aucun raison cellulaire.

Icône du mode avion

Votre téléphone est en mode avion. Lorsque activez le mode avion, les connexions cellulaire, Wi-Fi, Bluetooth et radio FM sont toutes désactivées simultanément (vous pouvez cependant toujours activer les connexions Wi-Fi, Bluetooth et radio FM séparément). Pour plus d’informations, consultez la rubrique Qu’est-ce que le mode avion ?.

Icône d'absence de carte SIM

La carte SIM est manquante.

Icône de carte SIM verrouillée

La carte SIM est verrouillée. Pour plus d’informations, consultez la rubrique Utilisation d’un code PIN pour verrouiller la carte SIM.


2. Connexion de données


Icône GPRS

GPRS

Icône EDGE

EDGE

Icône 3G

3G

Icône HSDA/HSUPA

HSDPA/HSUPA

Icône RTT

RTT

Icône EVDO

EVDO

Icône EVDV

EVDV


Remarque


Les icônes de connexion de données peuvent avoir un autre aspect sur votre téléphone et varier en fonction de l’opérateur mobile.



Plus d’informations
Paramètres cellulaires : http://www.microsoft.com/windowsphone/fr-fr/howto/wp7/start/cellular-settings.aspx
Rappel : pour configurer un nouvel APN ne pas suivre les conseils du lien précédent. Saisir uniquement le nom de l’APN, Free en l’occurence. Voir ici




Bonne journée.
Patrice.

Dynamics CRM‚ÄďWhat is Supported‚ÄďDifferent Rollups of Client and Server?

In a recent conversation with the Dynamics CRM products team the topic of supportability recently came up between different User Rollups(UR). Sustained Engineering does some testing against both scenarios,  i.e. higher UR version on servers vs. clients and higher UR version on clients vs. servers, for both CRM 4.0 and CRM 2011.  However, the test matrix, especially for CRM 4.0, is huge, so spot checking is done; the entire matrix is not tested by any means.  Test focus is probably on v-minus 1.

Standard rules of thumb are:

¬∑ Generally the servers are upgraded first and the clients after as quickly as feasible.  Until the clients are updated, they‚Äôll be missing any Outlook Client-specific binary fixes

· Sometimes due to lack of test resources re: server upgrades + known, impactful Outlook client issues available in the Client rollups, customers will roll out higher UR versions on their clients

· When there is a client/server mismatch,

  • Try to keep the situation temporary, getting the versions in sync ASAP
  • Try to minimize the ‚Äúmismatch delta‚ÄĚ; obviously, running (for example) RTM (UR0) clients against UR6 servers is more risky (and less likely to be tested) than running UR5 clients against UR6 servers.

Hope this is helpful,

Jeff Loucks
Chief Strategy Officer | Winrox | 425-577-7377

‚ÄúMicrosoft Dynamics NAV 2009: Professional Reporting‚ÄĚ book give away

Thanks to the kind people of Packt Publishing, I’m able to give away 3 e-copies of the book “Microsoft Dynamics NAV 2009: Professional Reporting” written by Steven Renders. What you need to do for that? Send me e-mail to kamil.sacek at gmail dot com with these info:


Subject: Book giveaway


Body:


        Your Name:


        What you like and hate most on the NAV 2009 from technical point of view:


        What you are looking for most on NAV “7”:


 


I will randomly select 3 winners which will receive the e-books (deadline for the emails is 23:59:59 5.2.2012 CET). This give away is running on all my blogs together, it means only 3 e-books for all 3 blogs sites I am using…


 

NetMF ‚Äď Serial Port – Echo response App

Some people ask me to have any soft start guide using microframework serial port. Well, as you know in desktop apps is the typical “Hello World”, the translation into serial port apps are “Echo for response”.


This code shows how to open the serial port to read incoming bytes and resend it as an echo. Is the first brick to check that the UART is all right! After this lab, you are ready to build your own DCE/DTE protocol and play serial commands between both sides.


Imports System.IO.Ports
Imports System.Text
 
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
 
Module EchoResponse
 
    Private WithEvents SerialComm As SerialPort =
        New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)
 
    Private DataReceived As String = ""
    Private PortActivity As New OutputPort(CType(55, Cpu.Pin), False)
 
    Sub Main()
        SerialComm.Open()
        ' include your functions here
        Thread.Sleep(Timeout.Infinite)
    End Sub
 
    Private Sub SerialIn() Handles SerialComm.DataReceived
        PortActivity.Write(True)
        Dim Length As Integer = SerialComm.BytesToRead
        Dim Frame(Length) As Byte
        SerialComm.Read(Frame, 0, Length)
        SerialComm.Write(Frame, 0, Length)
        DataReceived = ""
        PortActivity.Write(False)
    End Sub
End Module

Enjoy!! PepLluis,

Microsoft Exchange PST Capture Tool

It’s time to harvest those PST files

PST files are the plague of most managed networks and the bane of most email administrators.  It also clearly demonstrates that if you don’t have an email policy (and email management strategy to back it up), users will follow the path of least resistance.



In the not-so-long-ago days, email storage was expensive and growing exponentially.  The common reaction to this was to enforce mailbox quotas to keep mailboxes from growing so large.  When you put a barrier in place it’s human nature to try going around it, so when users run up against their mailbox quota they looked for alternate ways to store their emails.



Enter Outlook PST (personal storage) files.  PSTs allow users to archive emails out of their Exchange mailbox into a discreet file.  There are several problems with this:



  • PSTs are not governed by company email retention policies or legal discovery
  • PSTs cannot be accessed from Outlook Web App (OWA) or mobile devices
  • PSTs are usually stored on local computer drives that are rarely, if ever, backed up
  • If users store their PSTs on a network drive you haven’t really solved the storage issue, have you?
  • PSTs are normally not password protected.  Anyone who can access the PST can read the emails.
  • PSTs are typically difficult for end-users to manage

Now that storage is cheaper and more abundant, companies are looking to harvest those PST files back into Exchange so they can be managed by corporate retention and discovery policies.  Older emails can also be archived using native Exchange Online Archiving or other third-party solutions.



Today, Microsoft delivered the Microsoft Exchange PST Capture Tool.  This new tool allows you to import the contents of PST files into a user’s mailbox, into an Office 365 online mailbox, or directly into an Exchange Online Archive.  By optionally installing PST Capture Agents on target machines, administrators can determine where .PST files are located and who their file owner is via the PST Capture Console.



Read the Exchange Team blog, .PST, Time to Walk the Plank, to read a bit more and watch a video about the tool with Ann Vu and Ankar Kothari.  BTW, Ann was the one who came up with the “That’s right. My theme is Super Sparkle Happy” Exchange t-shirts at least year’s TechEd.  :)


When DBCC INPUTBUFFER disappoints

Today we have an alert from one of the client server about blocking, I have immediately start looking at it using below statement

 
SELECT * FROM 
MASTER..SYSPROCESSES
WHERE BLOCKED != 0 
Yes, I’ve found the culprit SPID that is occupying more resources, using DBCC INPUTBUFFER(SPID). so, instead of seeing what exactly this SPID is doing I have received SP_EXECUTESQL, surprised!!! No, it’s bound to happen when SPID is running dynamic TSQL (using SP_EXECUTESQL) and/or cursor. But, yes, at the same time I would like to know what it is running behind the scene. There are two options that came to my mind
  • Using Profiler
  • using function ‚Äď ::fn_get_sql(@SQLHandle)

 
-- Variable that will store the SQLHandle
DECLARE @SQLHandle BINARY(20)

-- Variable that will pass on the culprit SPID
DECLARE @SPID INT

-- value for culprit SPID
SET @SPID = 52

-- this will give you the SQLHandle for the culprit SPID
SELECT @SQLHandle = SQL_HANDLE 
FROM MASTER..SYSPROCESSES 
WHERE SPID = @SPID  

-- this statement will give you the SQL Statement for culprit SPID
SELECT [TEXT] FROM ::FN_GET_SQL(@SQLHandle)
I preferred to use 2nd option as this is one time effort (at least as of now), and, it would be very quick. So, here is what I have used
You must be thinking why I have used this function instead sys.dm_exec_sql_text? Any guess??
Yes, you are right, customer is still using SQL server 2000 Winking smile
BTW, if you happened to come across something relating but on SQL Server 2005 or SQL Server 2008 and greater I have a reference script for you
Erland Sommarskog, SQL Server MVP has written aba_lockinfo and a script a.k.a. Custom Blocker Report from Aaron_Bertrand.
–Hemantgiri S. Goswami (http://www.sql-server-citation.com )

Using Web Services to validate data in VS Lightswitch

This is a useful post by Beth Massi on calling web services to validate data.


I found it useful because Lightswitch does not easily present this facility for data validation


http://blogs.msdn.com/b/bethmassi/archive/2012/01/30/calling-web-services-to-validate-data-in-visual-studio-lightswitch.aspx

List of performance counters for SharePoint web parts/application

My blog has been moved to http://sundarnarasiman.net.


It has been migrated to wordpress platform
You can find this post http://sundarnarasiman.net/?p=72


 

PowerShell Command Builder para SharePoint 2010 y Office 365

Encontr√© por ah√≠ una aplicaci√≥n para generar comandos de PowerShell llamada PowerShell Command Builder la cual encuentro muy √ļtil. La direcci√≥n para acceder es http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html y requieres contar con el plugin Silverlight en tu navegador.

image

Aqui mas informacion: http://www.microsoft.com/download/en/details.aspx?id=27588

Microsoft Dynamics CRM 2011 New Features Ebook

A couple of my fellow CRM MVPs have created a book for CRM 2011. First I want to congratulate Darren Liu and Jim Wang on their efforts.

What I found useful about the book is the approach. They featured a solution and walk readers through the architectural steps of a real world project. Then they match those structures to the features and technologies within CRM. I found it to be a light read which helps to introduce some of the new features of Dynamics CRM 2011.

For those of you looking for a project oriented approach, this book is very illustrative of how to walk through a CRM engagement. Complete with coding samples for client and server side code this is a great reference for developers.

Good Job Jim and Darren!

http://www.packtpub.com/microsoft-dynamics-crm-2011-real-world-tutorial/book

Jeff Loucks
Chief Strategy Officer | Winrox | 425-577-7377

What Code Comments are Not For.

I deal a lot with other people’s and legacy code.  One of the things I see very often is what I call "misuse of code comments".  Let me provide an exhaustive list of what code comments are for:

  • Describing why code isn’t doing something obvious

There, done.

What code comments are not for (not complete):

The Obvious


// set the value of i
i = value;

It’s obvious that the code is doing that; the comment adds no value here.  The compiler provides no validation that the "i" in the comment really applies to any variable in the line the comment applies to.  Nor does it even know what line the comment applies to!  Comments like this actually introduce some technical debt because I can refactor this code to move it around independently of the comment and thus the comment would appear to annotate some other line of code. Refactoring tools help somewhat with this; but they only really do name matching in comments when you rename a variable.  Do you think renaming "i" to "count" really means replacing all "i"’s in all comments with "count"?  Probably not; don‚Äôt use refactoring tools as a crutch.

Helping the Reader Learn the Language


You can’t possibly know what the reader of your code does and does not know.  This is especially true of what they do and don’t know of language syntax.  The language syntax is your common language; you can only assume they know it. You can‚Äôt possibly know if a comment about language syntax is going to help the reader or not.  If they don’t know it, they should look it up.  Comments that describe syntax are a no-win proposition, you can‚Äôt possibly have a comment that helps every reader of the code.

An example:
        /// <summary>
        /// Constructor for class.
        /// </summary>
        public MyClass()

If your reader doesn’t know this is a constructor, they probably don‚Äôt even know what a c’tor is‚ÄĒthis comment isn’t going to help them much. 

Slightly different example:

/// <summary>
/// Initializes a new instance of the MyClass class
/// </summary>
public MyClass()

If the reader doesn‚Äôt know what a c‚Äôtor does, does all your code include comments that will help this reader?  These comments are a waste of time and add no value. Same technical debt as Obvious, it‚Äôs not a syntax error to separate the comment from the declaration; there is a risk they will become disconnected or out of synch.  If the comment has no value having to manage it also has no value and therefore adds work to the project.

Another example verging on Obvious:
public MyClass()
{
  // Empty
}

As this stands, it seems benign. But one, it should be Obvious.  Two, if it’s not, the reader should be brushing up on language syntax.  Three, it’s not verified.  I can edit this c’tor to make it do something else this is perfectly syntactically correct:

public MyClass()
{
  x = 42;
  // Empty
}

Now, the comment is meaningless and potentially confusing.  Reading this for the first time makes you wonder did the class just have // Empty in it in the past and x = 42 was added, or does "empty" mean something different to the author, or did the author suffer from a stroke and possibly need medical attention?

You can assume the reader of your code doesn‚Äôt know anything about the code.  If the language can‚Äôt express the concepts in the code properly (if it can, you should be writing it that way; if you choose not to, comment why.) then comment why the language isn‚Äôt describing the concepts.

WHY not HOW


Writing comments to aid the reader in the understanding of the language is sometimes describing HOW the language is working.  That’s not describing the code but describing the language.  Comments should describe WHY the code was written that way if it‚Äôs not obvious.  Again, the language is the common denominator between the reader and the author.  There’s many references the reader can refer to to learn the language–let them do that; you may not be the best person to help someone learn the language; at the very least you don‚Äôt know the degree to which they don‚Äôt know the language.  Let the code clearly describe HOW.

Use of comments is often a form of religion; people are very opinionated about them in one way or another.   Robert Martin pulls no punches in Clean Code by saying:

‚ÄúThe proper use of comments is to compensate for our failure to express yourself in code. Note that I used the word failure. I meant it. Comments are always failures.‚ÄĚ

Martin has previous described comments as ‚Äúapologies‚ÄĚ for ‚Äúmaking the code unmaintainable‚Ä̂Ķ

If you want to use concepts like XMLDOC or tools like JavaDoc to document members and classes, that’s fine; just make sure your comments are meaningful and can stand alone.

For what it’s worth, these are comments that I have encountered; more than once and on more than one project.

Do you have some code comment pet peeves?  We‚Äôd love to hear them!

(function() { var po = document.createElement(‘script’); po.type = ‘text/javascript'; po.async = true; po.src = ‘https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s); })();

Writing ASP.NET MVC bootstrapper with Autobox

This will post will show how you can use AutoBox to easily write a bootstrapper for ASP.NET MVC. I have used the latest version of AutoBox (available from nuget, this version also includes Castle.Windsor internally for managing dependencies rather using its own resolver and does not require interface to type naming convention [IAccountRepository ‚Äď> AccountRepository]) . To understand what is AutoBox , how you can use it for caching using memcached and let it automatically handle dependencies for controllers and repositories, i would recommend to take a look at this post:

http://weblogs.asp.net/mehfuzh/archive/2011/11/06/introducing-autobox-on-the-fly-dependency-injection-and-caching-container.aspx

Moving forward , let’s consider a simple bootstrapper interface:

  1. public interface IBootStrapperTask
  2. {
  3.     void Execute();
  4. }

The Execute()  method will be invoked during initialization for registering routes, controllers, mappings (AutoMapper), etc. We will have one static factory (Ex. BootStrapper)  that will initiate it through CommonServiceLocator.

  1. public static class BootStrapper
  2. {
  3.     /// <summary>
  4.     /// Executes registered tasks.
  5.     /// </summary>
  6.     public static void Execute()
  7.     {
  8.         ServiceLocator.Current.GetAllInstances<IBootStrapperTask>().ToList().ForEach(task =>task.Execute());
  9.     }
  10. }

A typical example of a bootstrapping task could be RegisterRoutes:

  1. public class RegisterRoutes : IBootStrapperTask
  2. {
  3.     private readonly RouteCollection routes;
  4.  
  5.     /// <summary>
  6.     /// Intializes the new instance of <see cref="RegisterRoutes"/> class.
  7.     /// </summary>
  8.     public RegisterRoutes()
  9.         : this(RouteTable.Routes)
  10.     {
  11.         // intentionally left blank.
  12.     }
  13.  
  14.     /// <summary>
  15.     /// Intializes the new instance of <see cref="RegisterRoutes"/> class.
  16.     /// </summary>
  17.     internal RegisterRoutes(RouteCollection routes)
  18.     {
  19.         this.routes = routes;
  20.     }
  21.  
  22.     public void Execute()
  23.     {
  24.         routes.Clear();
  25.  
  26.         routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  27.         routes.IgnoreRoute("{*favicon}", new {favicon = @"(.*/)?favicon.ico(/.*)?"});
  28.  
  29.         Routes.Register(routes);
  30.     }
  31.  
  32. }

Here on line 29, i have added Routes.Register which is similar to the BootStrapper.Execute() that further narrows down to specific routing classes. For example. AccountRoutes.

  1. public static void Register(RouteCollection routes)
  2. {
  3.     ServiceLocator.Current.GetAllInstances<IRoutesRegistration>().ToList()
  4.        .ForEach(task => task.Register(routes));
  5. }

The code inside Routes class again pretty straight forward and exactly identical to BootStrapper except the IRoutesRegistration interface. We can also have RegisterControllers but since the dependencies are automatically wired by AutoBox, we only need to specify (if required) what repository methods to be data cached and for what duration.

  1. public class RegisterControllers : IBootStrapperTask
  2. {
  3.     void IBootStrapperTask.Execute()
  4.     {
  5.         Container.Setup<ProductRepository>(x => x.GetProductDetails(0)).Caches(TimeSpan.FromMinutes(1)).VaryByArgs();
  6.         ControllerBuilder.Current.SetControllerFactory(new MyControllerFactory());
  7.     }
  8. }

More on caching and how MyControllerFactory should look like; please check my previous post as well as the product documentation. Finally, it’s about gluing the whole thing together and we just need to have these lines in global.asax.cs

  1. protected void Application_Start()
  2. {
  3.     // Initalizes autobox self.
  4.     Container.Init();
  5.     BootStrapper.Execute();
  6. }

When you will run the project; if you followed the flow then it should work as you have expected it. The project page for AutoBox can be reached here: http://mehfuzh.github.com/AutoBox/ .

 

Hope that helps

Recent Comments

Archives

ÔĽŅ