I recently started working on a project with an SQL 2012 server database project. To target SQL 2012 I had to install SQL Server Data Tools or SSDT. If you haven't already had a chance to look into SSDT then you may not know that with SSDT .dbproj files (Visual Studio Database Projects) have been replaced by .sqlproj files (SQL Database Projects). The new project file type allows you to target all SQL server versions including 2012. Sqlzapper did a nice post on the key differences between the two and helped me understand better how builds and deployments work with in SSDT.
With Visual Studio Database Projects you could use VSDBCMD.EXE to deploy your database project using the Post-build event command line in your project properties.
So, I needed to figure out how to do this with SQL Projects as my build was failing miserably doing the way you would with Database Projects. The docs on MSDN tell you how to publish a database project using the 'Publish Database' dialog (like one-click publish). Although this method works its not ideal in situations were you want to automate your publish on build to satisfy some dependencies, or if your lazy and don't want to right-click and deploy each time ;) Unfortunately, I couldn't find how to automate the publishing of the database. After reading sqlzapper's post I realized that I needed to use SQLPACKAGE.EXE to publish my database in the Post-build event command line instead of VSDBCMD.EXE.
I just showed you how to deploy your database using the Post-build command line. Looking at the images there is a lot to be explained, such as the new tabs in the project properties and .dbschema file extension from the database project vs. the .dacpac file extension from the SQL database project (in the Post-build event scripts). Check out sqlzapper's post and the other links I provided above to learn more about them.
I'm a huge supporter of clean coding (writing good code using principals, patterns and practices). Below is a list of some must have extensions for visual studio to help you code better and write cleaner code.
Resharper is a developer productivity tool that enhances VS with a bunch of features to make you more productive. Not only that, Resharper helps you adhere to basic coding standards thru powerful code editing helpers and code generators, and helps eliminate errors and code smells, which ultimately lead to cleaner code. Some of my favorite features include:
If your practicing clean coding and are programming to interfaces (like you should be) instead of concrete implementations, then I highly recommend Agent Mulder. Although Agent Mulder is not actually a VS extension (its actually a plug-in for Resharper), it integrates nicely with VS and Resharper to see your dependency injection container's registrations and help you navigate them.
Agent Ralph is another Resharper plug-in. This plug-in will help you keep your code DRY (Don't Repeat Yourself) by scanning your code and detecting functional duplicates, and offering the appropriate method to replace the offending code.
[caption id="attachment_392" align="alignnone" width="550"] Agent Ralph detecting duplicate functional code[/caption]
GhostDoc is an awesome extension that automatically generates XML documentation comments for methods and properties. If your practicing clean coding techniques then you know your documentation is your code (prose). This is not always acceptable, especially in the enterprise, so if your going to be documenting in code, then automate it so its consistent. The added benefit of this extension is that it will make you name your methods and parameters better since it uses those names in the documentation.
[caption id="attachment_393" align="alignnone" width="585"] GhostDoc XML Documentation[/caption]
Like Resharper, this one is packed with features. Some features overlap with Resharper so you may want to take a look at the settings after installing to turn them off. Some of my favorite features:
Custom Document Well that allows you to change the behavior of document tabs, including the ability to sort tabs alphabetically or by project
Format Document on Save
Email Code Snippet and HTML Code Copy
Align Assignment statements
[caption id="attachment_396" align="alignnone" width="672"] Productivity Power Tools 2012 options[/caption]
The Team Foundation Server Power Tools extension is a very powerful and handy tool if you use TFS. Basically, its a set of tools and utilities that enhances TFS by exposing some of its features to VS and windows. For example, the tool provides an Alert explorer that provides a GUI to subscribe to alerts based on different scenarios and exposes a TFS context menu that can be used in Windows Explorer. In addition, the tool improves your teams use of TFS thru Custom Check-in Policies and a Best Practices Analyzer.
[caption id="attachment_397" align="alignnone" width="775"] TFS Power Tools context menu[/caption]
[caption id="attachment_398" align="alignnone" width="851"] TFS Power Tools Best Practices Analyzer[/caption]
Well thats it. I didn't mention it earlier, but Resharper will set you back about a $100 bucks; professionally, its a great investment. All the other extensions are free!
Any recommendations? Something I might have missed? Let me know.
Sometime last month, Microsoft released its Visual Studio Tools for Git. The tool is an extension for Visual Studio that allows source control integration with Git. It enables you to integrate Visual Studio with local Git repositories and provides tools to work with remote repositories as well.
I've recently become a big fan of Git and have begun using it to see how I can enhance my personal development workflow and see what else I can get out of it. So after hearing about the Git extension I was eager to try it out.
I had an existing project of some code samples with a git repo on my local machine. This project was also on my clients on-premises TFS 2010 server. After installing the extension, the project was immediately recognized as a Git team project and it appeared that all was well. I quickly switched to another task with the intent of orienting my self to the extension later. When I went to show the code samples from the project, I noticed that all the files were marked as read-only and VS kept prompting me to save the files with another name after making changes. Thinking the source code was still being managed by TFS, I checked the Source Control -> Environment -> Checked-in items -> Editing settings, to ensure it was set to 'Check out automatically'. To my surprise, the Environment and Visual Studio TFS settings were missing!? I realized then, there was more to it and continued with my demo by un-checking the read-only property for each file, to save the changes before running the examples.
When I had some time to look into what had happened, I noticed that the project had been un-bound from TFS source control. After looking thru the Q&A on the extension download site I found out that you can't create a project on an on-premises TFS server that is a git repository. Apparently, a project can only be a traditional Team Foundation Version Control (TFSVC) team project, or a Git team project -- you can't have both. Which makes sense, since distributed version control is so different then centralized version control. Right now, Git team projects can only be created on Visual Studio's cloud service, tfs.visualstudio.com. The next major release of on-premises TFS will include support for Git team projects, but they are not available in TFS 2005-2012.
This is somewhat of a disappointment as I was hoping to maintain a local git repo that I could manage locally and/or remotely, while having it managed as a traditional team project simultaneously; didn't necessarily want a Git team project.
To fix it, I disabled the extension and then changed the source control using the Change Source Control command 'Bind' function. This allows a user to reestablish a source control link between a solution/project and the version store. Previous attempts with the extension enabled resulted in an error.
Start by disabling the extension and then restarting Visual Studio.
Open the project that has the git repo. You will be asked if you want to permanently remove the source control bindings from the project. Selecting either 'Yes' or 'No' does not seem to matter.
After the solution opens, you should notice that the solution is no longer under source control in Solution Explorer and Team Explorer should indicate that TFS is not the current source control provider. Also note that the Source Control menu under the File is missing. To enable the Change Source Control command you will first need to set TFS as the source control provider by either clicking on 'Change Plug-in' in Team Explorer or going to Tools -> Options -> Source Control settings.
Select Visual Studio TFS as the source control provider.
You should now see the Source Control option under the File menu. Click 'Change Source Control'
The project should be unbound. Select each Solution/Project and click Bind. Your project should now be connected.
You may be prompted by Visual Studio to check out your project from TFS.
Your files should now show that they are under source control in Solution Explorer.
For now, I'll continue using Git for Windows to manage my local repos and push/pull from GitHub. And if the project is a traditional team project on TFS, then I'll commit my changes (on TFS) and be done with it.
As software developers, how do we get professional development? Who's responsibility is it to ensure we receive professional development?
There are many ways to get professional development. For example, you can subscribe to a video training provider like Pluralsight or get free content from Microsoft thru Channel9 or many of the training videos they offer thru their technology focused sites, like ASP.NET. There's a lot of free stuff out on the web you can search for as well. Product documentation, such as information on MSDN, books and blogs are all great sources for professional development. User group meetings, meetups, lunch-n-learns, round-tables, group discussions and mentorships are also valuable ways of getting professional development. So there's tons of ways to get professional development you just got to go out there and get it.
Whoa! Whoa! Whoa! Hold up..."just got to go out there and get it". Seriously?!
That's wrong! Well not completely. As an individual, you should express some degree of personal responsibility and ensure you are getting some sort of professional development. But the buck does not stop there. If you work for someone else or are part of a team where you have leaders above you, such as senior devs, lead developers, team managers, etc, then they have a responsibility as well, to ensure you are getting some professional development. If they're not, then they are wrong too! Bottom line here is you and your leaders share responsibility in making sure you are getting professional development.
Individual responsibilities:
Set your professional development goals for the year. Don't just focus on technology oriented development either. Career, productivity, work-life balance are good ones too.
Build a repository of training content; either on your computer, an external drive or thru a training provider and schedule some time throughout the month to watch them
Join a user group or find a meetup
Find several blogs (personal and product specific) and read them daily, if not weekly
Attend at least one conference throughout the year
Maintain some kind of frequency. The more you do these activities the more likely you are continue doing them
Leader responsibilities:
Make time for your subordinates to get professional development on company time. Put it on a schedule
Allow them to experiment and explore on thier own during work hours
Have your subordinates show case their work on a regular basis
Get them access to books and training material
Host lunch-n-learns
Have your juniors lead discussions or give talks
Bring someone in from the outside if you don't have the knowledge and skills in house
Start a mentorship program
I'm sure there are other things that can be done for professional development. These are the most obvious ones to me. How do you all do it? Is there a process you can share? Let me know, I'd love to here about it.
Over the past couple of months, my co-workers and I have been watching a video series on Software Craftsmanship, called Clean Coders, by "Uncle" Bob Martin.
The last video we watched was on System Architecture. In this video Bob Martin talked about how presentation patterns like MVC and MVP are part of "delivery mechanisms" of a system architecture and the that business logic should reside in "Interactors" -- a higher level controller like class. The group I watched the video with related these interactors to services in a service layer. At a recent usergroup meeting I attended, about UI Presentation Patterns (MVC, MVP, MVVM) the speaker said you should favor light controllers (or presenters) and heavier models (models as in -- Db Layer, Repos, Service Layers etc.) -- pretty much same thing as Bob said.
That said, I wanted to know how this applied to a project I'm working on which uses a UI Presentation Pattern Framework called WebformsMVP (blogged about this previously here). Inparticular, I wanted to know:
What is the consensus for system architecture with MVP?
Light Presenters with mainly just calls to service layer?
Heavier Services with business logic and calls to Repositories?
Light Repositories with calls to the database?
So I reached out to the WebFormsMVP GoogleGroup and asked these questions there. Below is a response I got back from one of the users, Alan McBee.
Uncle Bob is right. Light Presenters are best. Following SOLID, I say that the primary (or Single Responsibility) for Presenters are to provide the interaction between the state of the domain model in whatever form that happens to be (whether you use Repository, or some other business layer, or even just LINQ2SQL, just use your best judgment), and the state of the user interface which provides the Views.