Sometimes you just have to wonder what people are thinking. What level of software engineering degree does it take to completely misunderstand a concept and write this very special code?
SqlConnection conn = _db.GetConnection();
SqlTransaction tx = conn.BeginTransaction();
SqlCommand cmd = this.GetCmdRemoveField(conn);
cmd.Transaction = tx;
cmd.Parameters.Add("@ID", id);
cmd.Parameters.Add("@FieldName", field);
cmd.ExecuteNonQuery();
tx.Commit();
conn.Close();
try { tx.Rollback(); }
catch { }
conn.Close();
My eyes bleed and my heart sunk as I found this code from an external development group that was developing part of the previous application I worked on.
Thursday, May 24, 2007
On the virtues of crap code
Posted by Unknown 0 comments
SQL Deadlock Troubleshooting
SQL deadlocks can happen in the funniest places and when you least expect them. Take for example one website that had no problems with 1-2 users, but when 'scaling' to even 4 users SQL deadlocks would start. The blog entry below is well worth the read to help debug those pesky deadlocks.
Bart Duncan's SQL Weblog : Deadlock Troubleshooting, Part 1
Posted by Unknown 1 comments
Thursday, May 17, 2007
Can Agile Methodology be adapted for stand-up comedy?
The age old question. Once you feel the power of the Agile methodology you may too find yourself looking for other parts of your life to apply it.
http://angryaussie.wordpress.com/2006/12/04/can-agile-methodology-be-adapted-for-stand-up-comedy/
Posted by Unknown 1 comments
Labels: Agile Methodology
Continuous Integration with Subversion and AssemblyInfo
Building a continuous integration environment is becoming easier every day. How nice is it to have all of your source code automatically versioned with each build from continuous integration?
Here are some steps that might help when using Subversion:
A task to retrieve the latest subversion change number from the repository
<echo message="Retrieving Subversion revision number"/>
<property name="svn.revision" value="not_available"/>
<exec
program="c:\program files\subversion\bin\svn.exe"
commandline="log ${code.trunk} -r HEAD --xml"
output="_revision.xml"
failonerror="false"/>
<xmlpeek
file="_revision.xml"
xpath="/log/logentry/@revision"
property="svn.revision"
failonerror="false"/>
<echo message="Using Subversion revision number: ${svn.revision}"/>
Now add a task that will update all of the CommonAssemblyInfo.cs and AssemblyInfo.cs files that have the AssemblyVersion attribute defined.
<target name="SetVersions" description="Stamp the version info onto assemblyinfo.cs files">
<foreach item="File" property="filename">
<in>
<items basedir=".">
<include name="**\AssemblyInfo.cs"></include>
<include name="**\CommonAssemblyInfo.cs"></include>
</items>
</in>
<do>
<script language="C#">
<code><![CDATA[
public static void ScriptMain(Project project)
{
StreamReader reader = new StreamReader(project.Properties["filename"]);
string contents = reader.ReadToEnd();
reader.Close();
string pattern = @"\[assembly: AssemblyVersion\("".*""\)\]";
if (Regex.IsMatch(contents, pattern))
{
string replacement = string.Format(
"[assembly: AssemblyVersion(\"{0}.{1}.{2}.{3}\")]",
project.Properties["build.version.major"],
project.Properties["build.version.minor"],
project.Properties["build.version.build"],
project.Properties["build.version.revision"]
);
string newText = Regex.Replace(contents, pattern, replacement);
StreamWriter writer = new StreamWriter(project.Properties["filename"], false);
writer.Write(newText);
writer.Close();
}
}
]]>
</code>
</script>
</do>
</foreach>
</target>
And now tie it all together with this little task before executing your build, and you should have an accurately versioned build every time!
<property name="build.version.major" value="1" />
<property name="build.version.minor" value="0" />
<property name="build.version.build" value="0" />
<property name="build.version.revision" value="*" />
<target name="UpdateVersions">
<call target="RetrieveSVNChangeNumber" />
<property name="build.version.build" value="${svn.revision}" />
<call target="SetVersions" />
</target>
Of course the next step could be to check in all of those updated assembly info files...
Posted by Unknown 0 comments
Labels: Continuous Integration, Subversion