Stoneskin's Notes

Navigation for March, 2010 - Caught By .Net!

I don't like to using Struct just for Performance reason. Because it made it easier to has bug in your application.And it is worse in Team environment. If an application has a stuct employeeDTO, because this DTO only hold Employee values and qualify to be a value type .In one place the code got an EmployeeDTO and stored it to a collection(for example, session or ArrayList).

See code like thisArrayList EmpList=new ArrayList();EmpList.add(aEmpDto);

UnBox happen here. Many people will forget that the employeeDTO is value type and treat it as reference type. They change the value and didn't save it back to session.

if in another page, he want to display this updated email address. Response.write(((EmpleoyeeDTO)session["myEmployeeDto"]).email)It will still print the old email address.

you may say a good programmer with good programming habit will not cause that bug. But you can't relay on all the members in your team will never make mistake like this.So I always avoid to create new value type in my code. I may lost some performance, but prevent some potential bugs.

3. after build, you will get a single assembly CommonVoiceUC.dll, in you new web site, add it to your reference.4. in your aspx page, use it like regular Customer Controls.<%@ Register Assembly="CommonVoiceUC"
Namespace="CVUC" TagPrefix="cvuc" %>

<cvuc:CvDistributionGroupUpdateUC runat="server" ID="test" />

Conclusion:so this way you can very easy create a lot of customer controls with lots of Html tag or css in it. and it very easy for other application to use it.the bad thing is if the control have other components, for example "Telerik.Web.UI.dll", and other site want to reuse this control was using a different version of Telerik control.the conflicts will happen.