CRM developers tools of the trade – ReSharper

Do not wait; the time will never be ‘just right.’ Start where you stand, and work with whatever tools you may have at your command, and better tools will be found as you go along.

George Herbert

CRM Tools

Tools play an important part of the CRM developers life, they can save you hours of time and speed up development.  One of the best examples of a tool saving you time and effort is CRM MVP’s Scott Durow’s Ribbon workbench.  The manual process of editing the Ribbon in CRM is incredible tedious, the Ribbon workbench offers a GUI way to do it and it’s free.

Tools allow you to code on the shoulders of great CRM developers

You should checkout Tanguy’s XrmToolBox

I have reviewed a number of tools on this blogpost – Hosk’s CRM 2013 Tools List

Tools

CRM tools are very useful but there are some generic tools which are useful to CRM developers and one I would highly recommend is ReSharper by JetBrains.

ReSharper is a Visual Studio extension for .Net developers.  I have heard a few developers talk about ReSharper, so I thought I would have a look myself.  What you usually find is anyone who has used ReSharper will tell you how good it is.

The downside is this tool isn’t free but it doesn’t cost that much, find the price for personal use here

It is free for various people/groups which you might be part of

Additional options
* For startups (50 percent off)
* For students and teachers
* For education and training
* For Open Source projects
* For .NET user groups
* For Microsoft MVPs

For a personal license it’s 99 pounds.   Which if you use this a few times a week isn’t that much and the benefits to your coding and time spent finding bugs, formatting and other tasks could easily be worth it.  They also have a pay monthly option

ReSharper has a try before you buy scheme
The good news is you can try ReSharper free for the 30 days, so download it and give it a go.
I have tried it and I love it, to get the full benefits you will need to be writing CRM plugins and/or .NET code.
These blog posts highlight the benefits of ReSharper

Lots of features

ReSharper has lots of functionality, one of the difficulties I had was to learn what features were available, what they did and when I should use them.

These blogs were useful in learning about the ReSharper functionality

Warnings not nagging

I appreciate the way ReSharper works because it uses warnings.  These are often best practices but not serious.

It pops a warning mark on the right of the code and if you click on it you will get to a light-bulb.

Often I take these as suggestions, sometimes I do, sometimes I don’t. The way ReSharper warns you I have found not to be annoying or nagging.

Keeps me thinking

One of the positives of Resharper is keeps offering me code assistance and constantly keeps me thinking about the quality of code I’m writing.

  • It has offered to change a query expression to a linq query
  • swap If Else statements to a switch
  • Catching the nulls
  • One great features of Resharper is it warns you if a variable may contain null and offers to add an if statement to catch it.

Correct Naming standards

ReSharper is good for nudging you in the direction of better coding and will warn you to rename fields and functions

  • Lightbulbs – quick fixes
  • closing brackets and quotes automatically
  • Code Generation
  • Alt – INS

RED Errors whilst you type

“Big deal,” you may say. “Visual Studio already has squiggles like that.” True. But Visual Studio only shows the squiggles after you compile. ReSharper points out compiler errors in real-time, as you type. It does its magic completely in the background.

Grey is dead code

If you see grey code, it means you don’t need this code because it’s not being used.  Sometimes this is annoying because you are about to use it.  It’s good for getting rid namespaces you don’t need (ReSharper will get rid of them for you)

One feature I really like is when ReSharper puts up an error, there is an option to click which says

Why is ReSharper suggesting this and it will explain the coding practice to you

Auto Closing Delimiter

ReSharper automatically closes brackets

Not used warning

ReSharper has great features and one of them is to warn when variables are not used

I had an example where I was assigning a value and then overwriting it.  Resharper warned me that variable value wasn’t being used in any code branch

warnings I found annoying

VAR

One warning which annoyed me was Resharper trying to change all varibables to var to improve readability.  Personally I like developers to use the correct variable type and using var is a bit lazy.

it kept trying to persuade me to remove this but FXcop kept advising me to put this in.  Only one way to resolve this

FIGHHHTTT

The good news is it’s easy to turn off the warnings.  You can turn off the warnings in a method or class or project.

Or you can turn the inspect severity and then search for the error you want to remove.

Learn to use your tools effectively

Tools can make speed up development process and make development processes easier. Choosing the right tools is one part of the solution.  The rationale behind this is you probably use your development tools on a daily basis, if you can find functionality which speeds up, automatics tasks you do every day, lots of times a day you will make a considerable time saving.

This sums up my thoughts on resharper, it eases and speeds up my development

information for learning ReSharper

There is a series of screencasts on the Dime Casts website which are quite good as an introduction.There is also the 31 days of Resharper and the official demos give you an idea of what’s possible so you know to dive into the menu.
This article show you how ReSharper’s code creation

Absence makes the heart grow fonder

The time I really notice the work ReSharper does is when I am helping with someone and they don’t have ReSharper.

ReSharper helps refactoring, this article describes why – Why use ReSharper manage refactor code

Overall

ReSharper makes working easier and smoother with lots of great enhancements.

Warning me about unusual variables, methods and usings is useful.

Warnings about code which could be done better is useful

It’s difficult to describe what exactly ReSharper does but it does things better than Visual Studios’s out the box functionality and will make your life easier.  If you use Visual Studio on a daily basis all the small benefits will add up to large benefits.

If you try ReSharper you will see why it’s great and will be tempted to buy it

Questions on Microsoft Dynamics CRM solutions and environments

The art and science of asking questions is the source of all knowledge.

Thomas Berger

I was asked some questions about solutions in Microsoft Dynamics CRM, I decided to answer using a blog post so other CRM developers could benefit.  If one person is asking the question there are probably many more people thinking it.

Posting the answer to a question on my blog means other people who are having the same problem can find the answer.

Solutions

Understanding solutions is a something a CRM developer must master,  getting it wrong can cause problems deploying and managing your customizations.

The blogs below will give you a good understanding of Solutions, how they work and many of the common problems you experience with solutions (usually managed solutions)

Here are the questions

Q.  All changes made to any (unmanaged) solution are applied to the default solution.

A.  All changes to an unmanaged solution are applied to the default solutio,  you can’t undo the changes except by importing an older unmanaged solution, which is like rolling back those customizations.

Importing an unmanaged solution will overwrite any of the customizations included in the unmanaged solution (assuming the system only includes unmanaged solutions)

Q.  Multiple developers are able to work in parallel on the same entities as all changes are applied to the default solution. Everyone has sight of all changes at all times.

A.  If you are working on the same CRM environment, changes  will be visible instantly to all developers but only published changes will be visible to customers.

  • Fields, views, new entities will be visible instantly
  • Form changes will be visible when the developer publishes the solution

Code changes are different due to the way CRM developers work e.g. CRM developers tend to download a copy of the code (Javascript or plugin) work on the code and then upload when ready.

Developers usually get the latest code from TFS or the source control used in the project rather than getting the latest code Javascript from the CRM form.  This process can result in developers overwriting changes if they are both working on the same Javascript or plugin at the same time because they work offline whilst coding.  You can work around this by setting up processes and source control is your friend.

This blog post discuses multiple developers working on web resources

How do multiple developers work on a web resource within the CRM environment

Q.  Removing the unmanaged solution does not remove the changes in the default solution – these have to be removed manually (or the default solution can be restored (snapshot tools like Cobalt look good and free? Can they be used to perform a rollback in Dynamics online?)

A unmanaged solution is a wrapper to move your customization’s between CRM environments.  When imported it imports those changes into the default solution, overwriting any existing changes.  Deleting the unmanaged solution will delete the solution but not delete the customizations.

Managed solutions can be thought of as read only to the customer.  You cannot modify any of the managed components (unless they are the default CRM fields).  Deleting a managed solution will delete the customizations and the data.

To remove unmanaged customizations you must delete them manually.  Solutions are additive which means they don’t remove customizations.  You can use unmanaged solutions to change the customizations back to previous state.

I haven’t used Dynamics CRM Snapshot from Cobalt but looking at the page it seems to snapshot the data not the solution and customizations

You can create snapshots of your customizations by keeping the solution files so you can import them to roll them back.  Remember to use version numbers otherwise it’s difficult to manage and keep track of the CRM solutions, particularly if you have to move the solutions through multiple CRM environments.

Version numbers are mentioned in the blog post CRM 2015 – Best practices for CRM Deployments

Q.  Managed solutions are essentially a container for any changes you want to move to a new environment. Care must be taken to ensure that all of the relevant changes to entities are pulled into a release. It will become clear when the solution enters UAT if dependencies have been missed.

I have written about Managed solutions CRM 2013 – Managed solution problems with out of sync solutions.   Only a solution from the same publisher can update the customizations in a managed solution

Why use managed solutions

Choosing your solution strategy is an important because it can be difficult to swap back from a managed solution to an unmanaged solution.  There is anxiety before you make the decision and push the button and import a managed solution.

There are many choices you have to make in CRM which are very hard to undo like

CRM Entity ownership – How do you decide?

I have talked to CRM developers who hate managed solutions and only deploy unmanaged solutions. I have been asked numerous times why anyone would use a managed solution, so lets investigate the reasons.

The logic behind a managed solution is two fold

  1. Managed solutions are read only to protect the customization creator from users and CRM developers taking and changing the customizations
  2. Stopping users from changing the customizations which could result in the customizations not working or working incorrectly.

Managed solutions are great for CRM resellers who created a solution for CRM which acts like a products.  E.g. an Autonumber solution.  They can sell the Autonumber solution, it’s gets deployed and the users can’t change any of the code to stop it working and other CRM developers can look at the code to steal the code/ideas.

This scenario is ideal for managed solutions because if the users change their mind and don’t want to use the solution they can uninstall it and it removes all traces of the solution and its data.

Q.  If managed solutions are removed from an environment any data would be removed as well – so we should NEVER remove a managed solution but instead apply a new managed solution on top.

When you remove a managed solution it removes everything

  • Customizations
  • Data

Once the data is gone you can’t get that back, which is why you need to think carefully if using managed solutions are the right choice.

I know many CRM developers who refuse to use managed solutions due to

  • Build problems
  • unable to edit production/live system without importing a new solution
  • Solution dependencies

Unmanaged solutions will give you an easier life but it will potentially let end user modify live customizations which could break the solution and with no easy way to know what had been changed.

CRM 2016 has added patched solutions

Solution patching allows you to release smaller solutions, creating smaller solutions and reducing conflicts and problems when deploying the patch solution.

I haven’t used patch solutions so I don’t know if the theory works in practice.

Q.  Environments setup question

Dev – unmanaged default solution with project related solutions.
UAT – Test environment that managed solutions are deployed into.
Live – managed solutions transition to prod when successfully passed UAT.

There is no right answer for the number of environments, it depends on the development and testing schedules you are doing, how you work with the customer.

The number of environments can reflect the different phases of a project,  you can often have testing and development phases running at the same time.

Ask yourself what is the purpose of each environment.

I would add a preproduction environment, an environment which is hosted on the customers site or a sandbox instance if using Microsoft Dynamics CRM online.  This environment has exactly the same customizations and similar data to the production environment.  It allows the customer to test near production environment and is useful for investigating live issues.

For on premise development it’s common to have a development environment and internal QA/UAT environment for non developers to test fixes.  Developers are terrible at testing their own fixes

The usually test as CRM Admin role – The System Administrator role is a benefit and a curse to CRM developers

They often only test the happy path –Don’t just test the happy path

Development environments have development data – How to create realistic Test Data for your CRM Project and why you should

Here is some final reading on CRM environments for you – The pain of setting up CRM Dev environments

Never leave a CRM developer stranded

 

What lies behind us and what lies ahead of us are tiny matters compared to what lives within us.

Henry David Thoreau

 

Developers are a community which spans projects, developers jump in and out of different projects for varying times.  Any code or customizations are developer creates might be maintained by himself or another developer, it‘s important to do a good job to make it easy for yourself and others.

When developers in a company work well as a group, they push each other to keep high standards.  Keep high standards takes pride and enthusiasm because it‘s harder to write simple code than complex code.  When one developer drops their standards, this can infect a whole project, Bad code is like a virus, don’t get infected.

Microsoft Dynamics CRM developers need to work as a group because CRM has lots of pockets of specialisation and impossible for one developer to know the functionality and limitations of all aspects of CRM.  The knowledge of the group of developers can give guidance to developers without knowledge of parts of CRM.

Today I say act like a soldier, in an earlier blog I told you to write code like a boy scout, what will future blogs bring

A Team of individuals

One day a call came into the support desk with an urgent bug on a Microsoft Dynamics CRM project I had not worked on, I had to investigate the bug.

The developers who worked on the project, either left the company or was unavailable.  I read the project documentation, it was outdated and didn’t help.  I looked at the development environment and started my investigation with the code and CRM.

The code wasbig ball of mud, rolled in a plate of spaghetti with technical debt on the side.  This was legacy code with no one to help me, it would be a long day, my fellow CRM developers had left me stranded.

I poked and prodded the code, toyed with the CRM, asked questions, documented my investigation and was 90 percent sure I had found the bug but it‘s scary changing legacy code with no unit tests.

Legacy code evolves to incorporate lots of fixes to particular problems or processes, when viewing the code for the first time often the code doesn’t seem logical unless you understand the business logic.  

Don’t let you fellow CRM developers down struggling with poor code I had written.  When you take shortcuts, don’t document code and write.

Code echoes

Creating code is like creating a baby, the creation is fast and fun but you have to look after the code for years.  

Once the code is written it will be read, maintained, extended, debugged for years.  Complex code will make take up more time, sometimes a small bug fix or code change can take days to do.  Coding faster will slow you down later, particuarly first draft code which has not been refactored.

The code you create today is likely to be used and maintained for years.  Make sure quality is high so the pain of maintaining it is low.   Working with legacy code, finding bugs can take hours/days and thought process of.  My usual approach to legacy code is

If the legacy code ain’t broke, don’t touch it and slowly back away.

Poor quality code will leave developers maintaining that code stranded and struggling with the code and time taken to get it right.

Starship developer

The best things in life are beyond money; their price is agony and sweat and devotion ― Robert A. HeinleinStarship Troopers

Reading Robert A. Heinlein Starship Troopers , in the story it follows one recruits journey in the mobile infrantry.  The mobile infrantry are volunteers, their actions are motivated only by their willingness to be in the mobile infranty and they can leave at any point.

Self motivation is the strongest form of persuasion and motivation.  This theme was discussed In the book  Leading by Sir Alex Ferguson (Author), Sir Michael Moritz (Author) gives insights into management style of Alex Ferguson and motivated to write Leadership

I like to bring the thoughts and opinions from different areas to CRM development to see if there are similarities and differences.  CRM developers are a community who share and help each other and sometimes contribute to the frustrations of a CRM developers The Frustrations of a CRM Developer

  • CRM developers are volunteers, they have chosen to be a CRM developer
  • CRM developers should be proud to be a CRM developer
  • CRM developers can change jobs at any time if they don’t like it
  • CRM developers are part of a team
  • CRM developers are part of the Microsoft Dynamics community

I have nothing to offer but code, customizations, sweat, solutions, tears, documentation and unit tests and blood to offer – Hosk

CRM developers are soldiers, battling bugs, deploying troops, creating customizations to take down customer requirements and keeping our heads down when the flack is flying.

Never leave a man down

The chances of CRM developers dying for the cause are remote, there have been a few close calls but I got away with a few broken bones and nightmares (which mainly consist of having to support CRM 4 projects and SSRS report formatting)

The soldiers creed – I will never leave a fallen comrade.

I saw this in the film Black Hawk down, where a helicopter crashes and is surrounded.  Some troops drive in to rescue them and get stuck themselves.  They fight their way back to base.  They realize not everyone made it back and most of them go back and rescue their comrades.

Why is it important because if you were the man left behind you would hope your buddies would come back to rescue you, it gives that Soldier hope.

The American soldiers have the Soldier’s Creed (US version)

I am an American Soldier.
I am a Warrior and a member of a team.
I serve the people of the United States, and live the Army Values.
I will always place the mission first.
I will never accept defeat.
I will never quit.
I will never leave a fallen comrade.
I am disciplined, physically and mentally tough, trained and proficient in my warrior tasks and drills.
I always maintain my arms, my equipment and myself.
I am an expert and I am a professional.
I stand ready to deploy, engage, and destroy the enemies of the United States of America, in close combat.
I am a guardian of freedom and the American way of life.
I am an American Soldier.

I adapted it, similar to updating the quote from full metal Jacket Why CRM Developers should always start with the CRM SDK 

CRM Developers creed (Hosk Version)

I am a CRM Developer.
I am a coder and a member of a team.
I serve the people of the Dynamics CRM Community.
I will always place the project first.
I will never accept defeat.
I will never quit.
I will never leave a fallen comrade.
I am disciplined, physically and mentally tough, trained and proficient in my code tasks and skills.
I always maintain my code, my computer and myself.
I am an expert and I am a professional.
I stand ready to deploy solutions, engage customers, and destroy the bugs in the code.
I am a guardian of freedom and the Leisurely way of life.
I am a CRM Developer.

Here is an interesting article on the subject Leave no soldier behind – no exceptions

Don’t leave a CRM developer stranded

Leave no man down.  You are part of a team, you might not see or talk to your team mates everyday but you are a group and you must work together

Ways to leave your fellow CRM developer stranded

  • hard to read code
  • poor quality
  • lazy bugs
  • no comments
  • poorly labeled code
  • first draft code/no refactoring
  • no documentation

CRM developers are a team, your code/customizations will be used by your fellow developers, don’t let them down with first draft code

  • Have pride in your work
  • Skilled expert
  • Enjoy working with your team mates
  • If everyone keeps a high standard it works
  • Soldiers are highly trained and have pride in their abilities.
  • Soldiers have faith in fellow soldiers

When someone is out of the office and they call you for help, help them I will never leave a fallen comrade.  Stop what you are doing and bust a gut to find the answer because if you were out on site you would help the team would help you.

Final thoughts

Individual commitment to a group effort – that is what makes a team work, a company work, a society work, a civilization work. Vince Lombardi

To deliver projects successfully it takes a team effort, with many individuals working together.  Strength of a team of CRM developers comes from each individual working together.

CRM developers might not always work in the same team on the same project by CRM developers team is beyond projects.  The code and customizations you create will be used and maintained beyond the life of delivering the project.  Code and customizations expand beyond their project and unite CRM developers together.  Create code and customizations you are proud of and will be easy for your follow CRM developers to maintain and extend.

Don’t leave a CRM developer stranded.

“Alone we can do so little, together we can do so much.” Helen Keller

 

This post is my personal opinions and not the views or opinions of my employer 🙂