Surround highlighted text with custom strings in Visual Studio 2010

by jtstroup 31. August 2010 10:43

Oh how lazy I truly is. 

Currently I am doing some heavy manipulation of Xml tags. I ended up with a Excel spreadsheet of new Xml tags I wanted to generate and I wanted to build a Xml document to send off to our QA team for review. MAN was I getting sick of typing "<" and then looking at the text in my excel spreadsheet and typing it in, ensuring I get the case sensitivity correct and then typing ">". At least Visual Studio will generate the closing tag for you. But that was getting very annoying. In comes Macros in Visual Studio. So here is what I did. 

 

  1. Open Macros IDE
    1. Click Tools
    2. Macros
    3. Macros IDE...
  2. Add Module for your Custom Macros
    1. Right click the "MyMacros" in the Project Explorer
    2. Click Add
    3. Add Module
    4. Type in whatever name you want to name this module
    5. Click Add
  3. Program Functions inside your module. 
    1. Public Module CreateXmlTag
    2.     Sub SurroundWithXmlTag()
    3.         DTE.ActiveDocument.Selection.Text = "<" + DTE.ActiveDocument.Selection.Text + ">"
    4.     End Sub
  4. I didn't add the second half of the tags since Visual Studio will auto generate the closing tag. You could do many manipulations here. Like adding <b> for HTML, or whatever you want :)
  5. Save and Close the Macros IDE window
  6. Then I added the macro to a toolbar for convenience
    1. Tools
    2. Customize
    3. Click New
    4. Type in name of Toolbar and click Ok. You will then have a toolbar appear
    5. Click the "Commands" tab
    6. Select the radio button "Toolbar:" (Mine was GenerateXmlTag)
    7. Select "Add Command..."
    8. Under Categories scroll down to "Macros"
    9. Find your Macro
    10. Click Add
  7. Next I wanted to bind it to a keyboard command. 
    1. Select Keyboard...
    2. I filtered by "Xml"
    3. Found my Command 
    4. "Used the new shortcut in:" Xml Editor with Alt+J, Alt+K
  8. Viola!
  9. I can now copy and past my text from Excel

 

OpenDate VoidDate

CloseDate

Highlight and press either my button or my keyboard command and it works like a charm. 

  <OpenDate></OpenDate>
  <VoidDate></VoidDate
  <CloseDate></CloseDate>

P.S. If you don't like the ugly looking text in your toolbar. Visual Studio has a way to add a button image to a command. I personally used Ryan Molden's tool which made things much easier for me. 

http://blogs.msdn.com/b/visualstudio/archive/2010/06/17/command-image-changing-extension.aspx

 

I hoped you enjoyed my lazy post. 

 

 

 

 

 

 

Tags:

Xml | VS2010 | Macros

Name-driven development

by jtstroup 24. August 2010 11:31

Summary:

Over the last few hours, as tools and technologies continue to evolve, another option has evolved to define a software-solution's architecture: Name-Driven Development (NDD). NDD gives architects the ability to define a solution while creating artifacts that become part of the overall solution. 

 

Overview: 

Often, the inception of a new software solution is an overwhelming task. You have to get approvals from management, high-level requirements etc etc. Taking too much time to analyze a solution can result in lost profits and possible the cancellation of the effort. There are just too many risks involved in giving too little thought to the overall structure of the solution. 

 

Why NDD?

Agile, it is the major engineering movement to move away from requiring full and comprehensive documentation. Thus the argument that you can only truly measure the success of a software project if it makes your company loads of revenue as the optimistic product managers pitched. Therefore no time is spent on documentation and the project can then be declared Agile Magnificent

The Process for Name-Driven Development

Along with a number of non-functioning requirements like unit tests, security, or event management, there is really only one architectural aspect that must be defined for these functional requirements prior to development. These are: 

  1. Name

Defining Name:
Prior to creating any artifacts (code or otherwise), the architect must understand the intent of the solution, and where that solution fits in the context of the business problem that it is solving. Once this requirement is understood. The architect will then understand the basic flow of the business transactions, as if the transactions were to be performed manually.
Once t hese items are understood, the architect then chooses a really neat and cool names for classes and functions that isn't highly overused in the engineering industry. Do not use terms like Class, Object, Data, Collection, Structure, Router, Gateway. Instead use descriptive names such as Keystone, Spring, Ground, Crux, Core, LynchPin, Chief, Driving Force, Nator. 

For Example

Say you had a company that uses a complex key. There are five columns that make the unique identifier to determine the placement of this data. The first is a uid Number, the second, is a group id, the third column is a line type, the fourth, a sub-line type and the last is a price type related to the sub-line type. Knowing this you would make a method named CompanyAKeystone(). Then from that top level method you would create your amazing design. 

Lets analyze the name keystone. A keystone is the architectural piece at the crown of a vault or arch which marks its apex, locking the other pieces into position. This makes the keystone very important structurally.... So knowing that our top level method is the keystone, we then derive the other methods that accomplish this task. You might make a DecipherKey which would be one of your cornerstones. Or a Enum that returns the status of the outcome result after you decipher the key. Maybe it's this type or that type.  The diagram created is easy to understand for any non-technical coworker. Taking our example above, we model this for our wiki documentation about this new feature we are developing. 

Figure 1

 

Conclusion


Name-driven development will increase production of your programmers, the evidence is indisputable. Developers will enjoy utilizing the methodology, thus making them work longer hours for the company to complete the project on time. By creating this example, the solution's architecture was defined, and tangible artifacts were created that can be added to the code base of the solution. If a lot of time had been taken to create a single unit test for this, a steel thread could have been done to prove the architecture sound. Developers would then have a concrete example of how this solution can be expected to behave. 


 

Tags: ,

Architecture | Fun

Visual Studio Intellisense not working ( ctrl+space)

by jtstroup 16. August 2010 11:28

My Visual Studio Intellisense was not working. When I was in the Immediate window I was sick and tired of not being able to ctrl + space to get my intellisense. I have Microsoft Messenger Plus! Live installed and apparently they have a preference that overrides the ctrl + space. Here is how you fix it. 

  1. Select Plus!
  2. Preferences and Options...
  3. Click on the "Messenger" tab
  4. Select "Messenger Lock"
  5. Uncheck "Activate Messenger Lock with a system-wide shortcut: or change the hotkey bind.

 

Tags: ,

CodeResource

Month List