Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Thursday, July 26, 2012

Auditing ExtendedProperties

So yesterday I was coding a User Story about reporting audit information for the project I am working on.  This project basically extends the ERP application called Macola (don’t get me started). What we are building is an extended properties application and we are auditing each change to an extended property for SOX compliance.

So we are using a class called (funny enough) ExtendedProperty. We have a collection of these objects to fill our grid using a List(of ExtendedProperty).  We were auditing each save in the Save method of each individual ExtendProperty.  This created a ton of audit entries in the database. We decided to combine these into a batch audit at the collection level to mitigate the number of entries and use the xml data type in SQL Server.

So our Audit objects began to take shape and now look like this:

image

An AuditEntry has a one to many relationship to an AuditChange. And an AuditChange has a many to many relationship to AuditColumn as well as AuditKey. Each of the objects overrides the .ToString function to return xml to be stored in the database.

The metadata in AuditEntry is in separate columns in the database and AuditChange, AuditColumn and AuditKey are all stored in a single xml column.  This gives us great flexibility in what we can audit and how much space it takes up.

How this relates to an Extended Property is that each property is responsible for its own audit unless it is in a collection of changes.  So we had to change how we accessed the List(of ExtendedProperty) in the containing class. We could not have a List anymore because it became difficult to act on that list as a whole. This caused us to create an ExtendedProperties collection class that inherits from List(of ExtendedProperty). This class gives us the ability to act on the collection as a whole but still allows us the functionality of a List(of T).

The results of this audit can be returned flattened using xquery in SQL Server.  It can be a little complicated when trying to compare values (sql:parameter(“parametername”) is your friend in xquery). But it makes life easier when batching audit entries.

Cool Visual Studio 2010 feature

As an aside, while I was coding the audit classes above I discovered a GREAT feature in VS2010. First I created a file for the class, then I started coding the public properties of the class. I did not create the constructor of the class yet.  I went to a calling class and instantiated this new class and put the arguments in the call.  There appeared a blue squiggly line below the code with the little red block in the bottom right.

image

When I click on the little red block it tells me it can create the constructor in the class.

image

So I tell it to go ahead and do that by clicking on the link. Now keep in mind I had already created the public properties for this class that will expose the arguments in the constructor.  So what did Visual Studio do?  It knew which arguments to assign to the private class variables automatically and wrote the constructor for me and assigned the arguments to the variables.

Sub New(ByVal userName As String, ByVal propertyName As String, ByVal operation As String, ByVal originalValue As String, ByVal newValue As String, ByVal timeStamp As Date)

' TODO: Complete member initialization
_userName = userName
_propertyName = propertyName
_operation = operation
_originalValue = originalValue
_newValue = newValue
_timeStamp = timeStamp

End Sub



Cool!


till next time…


Technorati Tags: ,,

Friday, October 28, 2011

ASP.Net – Code Behind and the Times

In 2001 Microsoft gave us ASP.Net.  The successor to what we now call “Classic ASP”. This brought the full power of the Visual Studio IDE to web development. Allowing us to write “Code Behind” in our favorite language, either Visual Basic or C#, for WebForms development inside Visual Studio.

This was a significant improvement to Classic ASP and to the developers ability to quickly produce web applications based on Microsoft Technology.  Up till then we had to use Visual Interdev. And was that a mess or what?

While I was an engineer at FM Global back in 2001, I was on the team that adopted .Net while it was still in beta.  (I know, pretty progressive for an insurance company, huh.) We had Microsoft consultants on site what seemed to be 24/7. We were learning a completely new way to code in a completely new IDE. Visual Studio .Net was simply amazing to all of us.  We were all Visual Basic developers then and being able to code using VB in this new environment was fantastic.

A couple of years later we were building an extranet application for our clients to be able to access their insurance information on the web.  We had been programming in .Net for a while but we were still VB programmers.  We were writing procedural code in an Object Oriented world.  There were some Code Behind methods that were several hundred lines of code long and full of spaghetti.

This is when we started learning about how VB can be a fully object oriented language and about utilizing Agile development techniques to help with the quality of our code.  It all started to come together. Our designs improved because we started to design our code to be testable. Our time to build and release methods were being revamped so we could be more efficient.  We were using code generation tools. It was a time of great learning.  We made our share of mistakes but all-in-all it was good.

Why do I reflect on such times?  I was reminded about these times because I am currently working with a group that is in a very similar situation.  Folks who are mostly COBOL programmers learning ASP.Net for the first time or are early in their object oriented programming learning and none of them have any Agile exposure at all.  I am sharing my experiences with them to help them grasp some of these concepts.

While doing a code review, one finds an asp button with an OnClick event that has 300+ lines of code in it, one is reminded of these times.  I am coaching my team in the craftsmanship of Agile Software Development, Object Oriented Programming and ASP.Net. So it behooves me to try to remember where I was and remind myself that there was a time when I wrote 300+ lines of code in a single method.  Well, maybe not that much but still…

Till next time…

Wednesday, September 14, 2011

What is ‘Metro’?

Yesterday Microsoft introduced us to Windows 8.  If you want to download the new bits, you can here. The  screen shots have been shared millions of times across the net so I wont show them to you here.  But what I want to talk about is the new Design Language that Microsoft is focused on.  It is called Metro.

This Design Language is not new to you if you have been programming for the Windows Phone. But if you have been focused on the desktop and client server apps, which are still very prevalent, then this is new to you or you are just learning about it.

Ziff Davis has a small article on Metro.  The interesting thing to me about this write-up is the graphic:

(image courtesy of @longzheng) via ZD

If you are like me, you have been focusing on the right side of this picture, what Microsoft now is referring to as Desktop Apps.  This is the traditional .Net, HTML, Win32 based apps  that we all know and love.  This includes today’s Internet apps and client server apps.

The left side of the graphic is new to most of us. Though we have been utilizing the languages and the technology in the upper portion (presentation), the lower part of the green section is new.  It looks to be all encompassing. It controls the basic services all apps will be utilizing.

I am not offering anything new here.  I just thought some of you may want to start gathering up as much information as you can about this “new” way of doing things so when Windows 8 hits the bricks you will be ready.  I know that I am going to do just that.

till next time…

Technorati Tags: ,,

Monday, April 28, 2008

New Challenge


So this Monday morning has given me a new challenge that I am looking forward to solving. I began working on moving to CruiseControl.Net and MSBuild for our CI. This is in the very early stages. I decided to use the least resistance path to setting up CruiseControl.


I setup CruiseControl (done this many times at my previous job) without incident. I edited the ccnet.config file to use perforce. I am still getting an error there but went around it by getting latest to my workspace. I'll deal with that later. Created a sample project and solution. Got CC to build it. Hurray, I'm in the clear!

Nope.

I grabbed an existing solution with about ten C++ projects, no external dependencies, and a quick build time inside visual studio. I pointed CC to it and BANG, big fat error:

C:\Projects\CCTestProj\CCTestProj.sln (,): error MSB4018: The "ResolveVCProjectOutput" task failed unexpectedly. System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path) at System.IO.Path.IsPathRooted(String path) at Microsoft.Build.Tasks.ResolveVCProjectOutput.ResolveUsingVCEngineObjectModel(ITaskItem projectRef, String configName, String& resolvedAssemblyPath, String& resolvedImportLibraryPath) at Microsoft.Build.Tasks.ResolveVCProjectOutput.Execute() at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)

Names have been changed to protect the innocent.

I thought, Illegal characters in the path? What is this? Visual Studio builds it fine. Why is MSBuild having a problem. So I dug around some. Thought it was related to references or something like that. No path problems could be found. Nothing in the CC log or the MSBuild log was helpful

So I decided to create a new solution and slowly bring in one project at a time to see where the problem lays. I created the solution added an existing project which was the first project in the build order of the original solution. CC built it fine. I grabbed the next project. No problems. I grabbed the third project in the original solution's build order and CC built it without a problem. I was getting nowhere fast.

But then I noticed CC and MSBuild was not building the projects in order. I thought, David you forgot to set the project dependencies in Visual Studio for the solution to build in the right order. There are no direct references but I wanted it to build in the same order as the original solution just in case. So this is where we were at:

Projects build order in original solution:
P1
P2
P3
Project build order in new solution:
P1
P3
P2

So I set in visual studio that P2 depended on P1 and built in VS. Worked. I then forced a build in CC and Viola! Same error as above.

I posted this in the MS forums and waiting for a reply. I am also doing some more experimenting to further define the problem.

Monday, November 27, 2006

To SCRUM or not to SCRUM

I am faced with a dilemma.  It is not a life or death problem, nor is it even important in the grand scheme of life.  However, it is a dilemma I face with my team.

Let me try to explain my dilemma.  We currently are using TFS as our source control application.  we are slowly beginning to utilize the Tasks for development and will continue to move toward integrating QA etc..  We are using the Agile Team Project template that ships with TFS with some minor modifications.  We now have about 17 Team Projects with more to come.

The problem is that our development process is more like SCRUM.  So, low and behold, I found what I thought was fantastic. www.scrumforteamsystem.com developed by Conchango.  This is great! I thought.  I downloaded and put it in our sandbox.  I played with it and found it almost perfect.  Now,the crux of the problem.  Without major surgery,  I can not convert my current Team Projects to use the Scrum templates. 

My dilemma is: Do I bite the bullet and create new Team Projects with the Scrum templates?  Do I spend time upgrading my surgical skills and TRY to convert my existing Team Projects?  Or do I do nothing with the current Team Projects (mine included) and only use the Scrum template for new Team Projects?

I have sent an email to Conchango asking if they provide a utility to convert the Team Projects.  No reply from them.  I must admit, what I know of TFS templates, it is not a trivial task to convert Team Projects to a different template.

If anyone out there has any ideas, I am open to suggestions.

Sunday, October 29, 2006

TFS Checkin Policy for CI

I just read Buck Hodges blog about a great idea! One that I wish I had thought of. Clark Sell created this custom policy for TFS that checks the CI process via a web service to interrogate the status of the most recent build attempt.  If it is red then you can not check in your code. I've got to have this!

My team is still trying to come to grips with moving our CI process to retrieve code from TFS instead of VSS.  Steve St. Jean, one of my former team members, talks a lot about some of the obstacles of moving from VSS to TFS that our team has hit, among other things, here.  One thing we have struggled with is knowing when CI is Red.  CCNet is great but it is so small in tray and sometimes (often times) gets over looked.  We've talked about creating a web page that would interrogate TFS and turn the whole background of the page what ever color indicates the status of the build.  We would put this on a huge monitor in the middle of the team room for all to see.

But would something like that stop a dev team from continuing their work and checking in their code?  More than likely not.  Enter said checkin policy. It seems to me the devs would get so ticked off about not being able to check in code that they would make sure everyone on the team would know they couldn't.  This might lead to faster build fixes.  On the other hand, how could you check in code that would fix the build??? hmm.. just override the polcy right..  OK, maybe my theory about the devs getting upset is not really that realistic. But you get the idea of how good this checkin policy could be.

I sure do!