Tallan Blog

Tallan’s Experts Share Their Knowledge on Technology, Trends and Solutions to Business Challenges

Category Archive for "Custom Software Development"

Hibernate: Merge vs SaveOrUpdate

In my previous and current project, I have run into cases where I needed to save an object to database using hibernate, and from time to time, I run into some sort of Hibernate Session Exception.
I did a bit of google search, and it turns out that when saving an object, I needed to make sure the object was attached to Hibernate session.
This can be very tedious issue, since that means if you need to save an object that is not attached to a session, you need to do these.

Retrieve the object using the Id value found within the object passed to you.
Update the property values one by one
Save the object back within the same Hibernate Session

Here’s a quick summary that I found out about MERGE and SaveOrUpdate.
void saveOrUpdate(object)->object must be attached to a hibernate session (including all sub objects…

Using XSLT in .Net

So you’ve finished writing your new XSLT file using your favorite XML/XSLT editing tool. Great. Now for the next problem, you’ve been given the task to transform thousands of XML documents using your new XSLT file. Great… There’s no way we can transform all of these documents by hand. At this point we should be thinking about automating this process in the fastest and most efficient way possible. This scenario may sound familiar to some of us. Luckily, .Net provides us with such options.
For this example we’ll be serializing an XML file and transforming it using .Net’s XSLT processor. The process is very simple, and requires very little code.

Load the XML File into memory using the XmlReader class.
var reader = XmlReader.Create(xmlFileLocation);

Create a StreamWriter object which will be used to write the transformation to a file.
var textWriter = new StreamWriter(outputFileLocation);

Create an…

Process vs Thread

Yesterday, Google launched their first web browser application, named Chrome.
And here’s an interesting cartoon that describes Google’s take on web browser.
What’s interesting is the idea of Process vs Thread.
Google’s Chrome uses Process for individual window, tab, and even plug-in.
In contrast, Firefox, the popular open source web browser, utilizes multiple threads for managing its windows, tabs and even plug-ins.
I think some of you remember that Internet Explorer has always been using Process for windows management. Any new windows are launched via new processes, and people did not like this idea, I guess. Firefox, instead, created one process application.
Of course, Internet Explorer 7 uses threads, but only on the tabs.
So, google’s take on web browser application is to use all process and no thread. I find this quite interesting, because as we all know, process takes more memory space than thread does….

Hartford Code Camp – Spring.NET Presentation Material

This Saturday was the first Hartford Code Camp. I presented on SpringFramework.NET specifically regarding Inversion of Control (IOC).
The presentation is in PowerPoint and discusses some of the basic concepts that need to be understood prior to understanding Spring.NET.
The source code is what was demonstrated during the presentation. It contains two solution folders.

TightlyCoupledClasses – Example of normal C# development where classes are tightly coupled together with manual instantiation.
LooselyCoupledClasses – Similar code loosely coupled using Spring.NET IOC. Includes various NUnit tests utilizing mock objects showing the ability to isolate tests with manual injection of mock objects.

PowerPoint Slides
Source Code
If you have any question feel free to post questions or comments here or email me directly at lrodgers@tallan.com.

The Cost of Reflection

Uploading file: the .NET MVC way

In ASP.NET, the traditional way of uploading files is as follows.
<form id=”form1″ runat=”server”>
<asp:FileUpload ID=”FileUpload1″ runat=”server” />
<asp:Button ID=”Button1″ runat=”server” Text=”Upload”
OnClick=”Button1_Click” /></p>
<asp:Label ID=”Label1″ runat=”server”></asp:Label></p>
And you have access to the uploaded file like this.
protected void Button1_Click(object sender, EventArgs e)
In .NET MVC, you can achieve the same with the following code.
<form action=”/controller/action/” accept-charset=”UNKNOWN” enctype=”multipart/form-data” method=”post”>
<label for=”file1″>file1</label>
<input id=”file1″ name=”file1″ size=”20″ type=”file” />
The controller side
foreach (string fileName in Request.Files)
HttpPostedFile file = Request.Files[fileName ];
It is important to understand the fundamental difference between the traditional web-form based .NET programming methods and the .NET MVC methods. You can still use the server controls, but you can only use them for read-only data rendering purpose, since ViewState is no longer an option in .NET MVC.

Compression Using the GZipStream and DeflateStream in .NET

What is GZipStream and DeflateStream?
There are two basic compression methods that are exposed in the .NET I/O Framework i.e. System.IO namespace : GZIP and DEFLATE. They (Compression methods) are exposed via streams and support both compression and decompression (which ofcourse makes sense!).
Compression Streams in .NET


Important Facts
The compression streams in .NET support compression of streams with a maximum size of 4GB. You will have to break your file down if it is larger than 4GB. A drawback of the .NET compression methods is that you cannot compress multiple files into a single archive file, like you may be used to with WinZip or other similar tool. Atleast this is not avaialable out of the box.
Which one to use – GZip or Deflate?
Both these methods use the same compression algorithm (RFC 1952). But if you are going to be interfacing with other…

Working with Isolated Storage in .NET

What is Isolated Storage and Why use It?
Putting it simply, an isolated storage is a “place” where an application can store its state information- things such as user settings, some assembly and application configuration information, and other application/assembly state information. So what is so different about that right?
Well a few things and some of these pertain to or relate to application and computer security. Let me explain, usually when an application tries to persist application state, it has to deal with user access rights, trust levels and so on. One way to resolve this is to give the application whatever rights it needs and potentially open up your computer to malware and spyware. Another way is to save information in the database. Now, the latter might be a viable option but in some cases complicates matters. Remeber when you just…

Java: Too many choices?

During my time with Tallan I have worked in both the MS camp and the Java camp. I prefer the Java side but I acknowledge that neither side is perfect. One of the main issues I see on the Java side is the huge variety choices that an architect has when starting a new project. I saw this article on DZone that seemed to summarize the situation well:
http://icedjava.blogspot.com/2007/12/dear-java-thanks-for-complexity-of.html [dead link]
There is an interesting link from this blog posting. I have not read it in depth. It looked good on an initial skim. The author seems to be trying to be objective, rather than selling one framework over another. (Go past the pictures of his family… would be interesting to hear the presentation that goes along with this PDF):
Comparison of frameworks:
https://equinox.dev.java.net/framework-comparison/WebFrameworks.pdf [dead link]
I am interested in hearing others point of view…

EclEmma – Unit Test Coverage Analysis in Eclipse

I was recently looking for a unit test coverage analyzer such as JCoverage for a project I’m working on. After reviewing several tools I discovered an amazing free tool called EclEmma.
I’ve used JCoverage in the past and while it’s HTML based reports are useful for project managers they are less so for developers. This tool essentially gives you the same information, but directly in Eclipse. You simply run the analyzer on either a single class or a set of classes and viola… you have your coverage report.
It even color codes each line of code within your editor window.

Use the http://update.eclemma.org/ update site to install EclEmma.