Good Practices for Pull Requests

A good PR guide

   Steps
  • Pull request for each feature is a minimum when completing a story for the same.
  • Assign a reviewer and setup some time with him , and give adequate time to review .
  • Allocate adequate time for reviewee as well to address the points raised by PR and fix them in the sprint stories.
  • Finally meet once again with reviewer to ‘resolve’ all the feedback given and get approval of the PR.
  • Ensure that the code works and is tested before the merge.
  • Once the PR is approved , validate the build and static code are successful, before merging and delete your branch to maintain repo hygiene.
  Best Practises
  • Keep PR’s small, so that the review is quick and feedback will not take much time.Else most of the time if you have a long living branch with lots of files,its very tedious to go throught various features and requirements to understand what was the expected behaviour.
  • Give a proper description for each PR, with changes implemented nicely listed.
  • Respect the time of both reviewer/reviewee, so that a proper time to fix a time with your reviewer. 
  • As a reviewer, it’s your responsibility not to hold on to the PR for too long , lest you end up blocking deployment and release.
  • Give constructive feedback for each review and not generic statements or mocking .Being rude is not an objective here, even if the code is frustrating to review.
  • The reviewer can ask the reviewee questions to understand more on the functionality or context.
  • Commented code or temp code should be avoided and maintain coding practices including testing and static analysis.
  • Always watch out for sensitive data not being checked into git.Eg config files with password.
  • We should always protect the main release branch from being merged directly without a PR process.

TIP: You now have the ability to review/start a PR within Intellij itself.

https://google.github.io/eng-practices/review/developer/small-cls.html

Git repository and branching standards

Guide for a new Repository

  1. Tag your Git repos along with application name or common theme which is relevant for that repo.Eg you might have several repos related to a proj called MyCart, tagging all the repos with MyCart will help discover them faster .
  2. Add readme with endpoints and support doc whenever possible.At the minimum each repo should atleast mention the core responsibilities of the repo.
  3. Enable Branch protection to avert inadvertent pushes.
  4. Readme updates in case of special needs like building the proj.
  5. Adding last Build run statuses using urls to you pipeline.

There is no limit on how far we would want to refine our git standards, but i have only concentrated on the min here which are the first 5 points above.

Code Check-in Guidelines

  • Before starting any work, take the updated code from git
  • Cut a branch name prefixed with feature Eg “feature-” from dev
    • this can be tagged to create a build name prefixed with “b” in drone (Example: b54-123e1222)
    • test your changes locally 
  • Once testing is done, create a Pull Request from your feature-* branch to dev
    • On merge, this should create a build name prefixed with “dev” in drone(Example: dev64-ff4e1233)
    • deploy these “dev*” builds in dev environment
    • test your changes in dev environment.
  • The last merge happens from dev to master via another Pull Request
    • this can create a build name prefixed with “p” in drone(Example: p34-22e6e882)
    • deploy these “p*” builds in prod environment
    • test your changes in prod env
  • Once the changes are deployed to prod, delete the “feature-*” branch

** In some scenarios if you keep a stage branch you will want to merge your changes from dev→ stage before you move to master. This will facilitate a prod like environment for UAT .

https://help.github.com/en/github/administering-a-repository/about-protected-branches

https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-status-checks

Visual Studio Productivity Power Tools for VS 2012

Well for starters let me assume you are a poor dev like me and don’t have access to Resharper! Well in case you do they have a lot of these features that are now available free of cost in Productivity Tools in VisualStudioGallery.msdn.microsoft.com.

Let me quickly show you some of the features that stand out pretty instantaneously .

1.PresentOn/Off – type this into the quick launch and lo you get the power of zoomit 🙂

PresentOn

2.You can now edit a project file by right clicking on the project.

Edit Project

3.Browse to definition by pressing on control and left mouse click.

Definition

4.Email code snippets by using the same option in context menu.

Email

5.Now you can find duplicate code snippets by selecting the option “Find Matching clones in solution” in context menu.

Clones

Also there are other features like Auto Brace Completion,Open Command Prompt and HTML copy.
So go ahead and give it a download!!

Setup Load Testing in Visual Studio

Well most often MS doesn’t setup stuff .So you have to do it for yourself.Like for Load testing in VS test cases,
you have to configure the database “LoadTest2010” and the corresponding tables like LoadTestRun,LoadTestCase,…
Well this is how you can do it in case you stuck at it.

Browse to this folder and execute in command line else you can always run the script in Management Studio.

cd “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE”

SQLCMD /S localhost\sqlserver -i loadtestresultsrepository.sql

Copying Directory or File in VSTS test cases

Well this one was pretty nasty I must admit.I didn’t know that I would lose some time on this one.And since I did I might as well blog about it.So here goes the problem statement.Have you faced the scenario wherein you had to copy some files under some folder in Unit tests in Visual Studio? This is because the test cases run under a folder called test results and each time you run it creates a new folder for that particular test case. Mind you before I start I must say that I have encountered this on the VS-2010 and not on the nascent versions of Visual Studio viz 2012.So here goes as to what you need to do to achieve the same.

1)First go the TestSettings file in VS 2010 which is directly under solution.
2)Go to Deployment section and check Enable deployment and add the directory that you want to add.

testsettings

3)Now is the trick part you have to edit the Test Settings file in Xml editor and go the tag under Deployment which has the required DeploymentItem and the attribute outputDirectory as follows.

deployment

4)Finally the worst part was now when you run the unit tests you will still now find it added.So to get it in working in VS 2010 you have to select the test list editor under the Test–>Windows menu in Visual Studio IDE.And then select your tests and hit run.Eureka… ooo still not there yet.The directory or file is still not out there!

5)Close your Visual Studio IDE and open it once again.(Age old trick works in the realm of WINDOWS).

So happy testing once again 🙂

Tip for the day!

I was recently working with xmls and xsd’s and came across this wonderful utility called XSD.exe.Using this you can create classes or xmls from schema’s and viceversa as well.Wonderful aint it?
Example
Generate classes from a given xsd

C:\classfiles>xsd “C:\SampleServices\Item\Lookup.xsd” /classes
For more info go to the path where xsd is(mine is C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools or C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64.This location is for VS2010 as you would have already presumed) in the command prompt is and hit

$:\xsd /h

And did you know you can even generate schema for a type from a dll or exe.. Cool eh?!

Custom Configuration Designer!

There has many a time that i have posted on tools, that makes life so much simpler,in order that we can can have the extra time to fall in love with C#!So many of us hate to see Xml. Lets admit it ,not many are in awe of the beauty called xml and have burnt their fingers and are not comfortable with it.But next time when you hear that you have to create a custom configuration,don’t fear as we have tools in place to handle that.Thanks to the wonderful tool called Configuration Section Designer.I wouldn’t have ventured into it had not i made a silly mistake which took my entire day and i began to question the logic of creating all these with mere hands and why not get it automated?

You can install the Configuration Section Designer from here.Once you download the plug-in and install it ,it fits perfectly well with VS-2008. and VS-2010 folks ,your version is yet to be out.But once you have installed the Custom Configuration Designer you can see that you will get a project like the snapshot available for you to play around!

 

 

Once you have created the Custom Configuration ,you will get a default custom Section designer diagram which will be empty .Go to the properties and enter the values in Namespace and XmlSchemaNamespace as follows.

 

 

Once you are done naming your namespace as well as the xml schema namespace, you can go ahead and drag and drop the Config Section, Config Section Group, Configuration Collection  as well as Configuration Element.Here is sample that I have created.Its really simple isn’t it?

 

 

And you can add custom classes to the existing predefined system types for your elements as well as the attributes as well as mention if it required and to make a certain attribute Key for a Config Collection.And then all you need to do is build it .

 

Start a Windows Service Automatically after Install

Recently i came across a situation wherein i had to host a WCF service as a Windows Service.Only after i installed the service using InstallUtil –i  “assembly name”,did i realize my folly that i had a misconception regarding the term “Automatic”.What i am referring to the ServiceInstaller.StartType property.The main intent of this property is to start the Service automatically on start of Windows.

Code Snippet
  1. this.serviceInstaller1.StartType =
  2.      System.ServiceProcess.ServiceStartMode.Automatic;

 

So what do i do in run the service while installation?All you need to do add the event AfterInstall for the ServiceInstaller and then call the ServiceController from the eventhandler to start the service.

Code Snippet
  1. [RunInstaller(true)]
  2.     public partial class ServiceInstaller : Installer
  3.     {
  4.         public ServiceInstaller()
  5.         {
  6.             InitializeComponent();
  7.             ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
  8.             ServiceInstaller serviceInstaller = new ServiceInstaller();
  9.             //Specifies the type of account that should be used for the service.
  10.             processInstaller.Account = ServiceAccount.LocalSystem;
  11.             //Specifies the name of the service that is installed.
  12.             serviceInstaller.DisplayName = "Josh Service";
  13.             //Gives the description of the Installed service.
  14.             serviceInstaller.Description = "this is a Win Service";
  15.             //It tells which is the service that should be installed.
  16.             serviceInstaller.ServiceName = "MyService";
  17.             //It specifies the Start type of the service.
  18.             serviceInstaller.StartType = ServiceStartMode.Automatic;
  19.             this.AfterInstall += new InstallEventHandler(ServiceInstaller_AfterInstall);
  20.             Installers.Add(processInstaller);
  21.             Installers.Add(serviceInstaller);
  22.         }
  23.  
  24.         void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
  25.         {
  26.             ServiceController sc = new ServiceController("MyService");
  27.             sc.Start();
  28.         }
  29.     }

 

Trivia:

The  service on local computer started and then stopped. Some Services stop automatically if they are not in use by another services or programs.”

You are all used to debugging and would have most likely than not used the “attach to process ” to debug your service implementation.But what do you do when you get Errors or have to debug the Windows Service installer itself?Bingo, we can always write “System.Diagnostics.Debugger.Launch();” in the OnStart() method and start debugging.Also you can write the errors to the EventLog or dump the Exception to a Log after putting in place a simple try catch!

Some links on the New Release Visual Studio 2010

Download the trial now!

visual studio 2010

visual studio 2010

 Customers can evaluate Visual Studio 2010 editions free for 90 days. After 30 days, customers must register the product to obtain a free key which extends the trial an additional 60 days. 

http://www.microsoft.com/visualstudio/en-us/download 

Download the training kit for DotNet Framework 4

http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&displaylang=en

Learning videos for VS 2010

http://www.microsoft.com/learning/en/us/training/format-learning-snacks.aspx#vs10

Visual Studio 2010 Featured Content

http://msdn.microsoft.com/hi-in/vstudio/ff625297(en-us).aspx

Life runs on code!

http://www.microsoft.com/visualstudio/en-us/watch-it-live

Test drive for Visual Studio 2010

http://www.microsoft.com/visualstudio/en-my/download

Visual Studio 2010 Feature Comparison

Visual Studio 2010 Feature Comparison Visual Studio 2010  Visual Studio 2010  Test Professional
Ultimate Premium Professional
Development Platform Support        
Windows, Web and Cloud Development  
Office and SharePoint Development  
Architecture and Modeling        
Architecture Explorer, Layer Diagram and Dependency Validation      
Read-only diagrams (UML, Layer, DGML Graphs)    
Database Development        
Deployment, Change Management, Test Data Generation, Unit Testing    
Debugging, Diagnostics and Testing        
IntelliTrace™ (Historical Debugging), Web Performance Testing, Load Testing1      
Static Code Analysis, Code Metrics, Profiling, Code Coverage, Test Impact Analysis, Coded UI Test    
Unit Testing  
Test and Lab Management        
Microsoft® Test Manager, Test Case Management, Manual Test Execution, Fast Forward for Manual Testing    
Virtual environment setup & tear down, Provision environment from template, Checkpoint environment    
Team Foundation Server        
Version Control, Work Item Tracking, Build Automation, Team Portal, Reporting & Business Intelligence, Agile Planning Workbook,  Team Explorer
MSDN Subscription benefits        
Priority support in MSDN Forums, MSDN Magazine, Flash newsletter, Online Concierge
Technical support incidents 4 4 2 2
Microsoft® e-learning collections (typically 10 courses or 20 hours) 2 2 1 1
Windows® Azure™ Platform ●† ●† ●†  
MSDN Subscription – Software for Production Use        
Microsoft® Visual Studio® Team Foundation Server 2010 plus one CAL
Microsoft® Office Professional Plus 2010, Project Professional 2010, Visio® Premium 2010, Expression Studio 3    
MSDN Subscription – Software for Development and Test Use2        
Windows (client and server operating systems), Microsoft® SQL Server®, Toolkits, Software Development Kits, Driver Development Kits
Microsoft® Office, Dynamics®, All other Servers, Windows Embedded    
† Azure benefits vary by subscription level; see the MSDN Subscription site for details: http://msdn.microsoft.com/subscriptions/ Subject to change and subject to availability.1. May require one or more Microsoft® Visual Studio® Load Test Virtual User Pack 2010.2. Per-user license allows unlimited installations and use for designing, developing, testing, and demonstrating applications.UML is a registered trademark of Object Management Group, Inc.

This material is provided for informational purposes only. Microsoft makes no warranties, express or implied.