November 30th, 2007 — .NET, Code, Work
At work we are going through a fairly large migration process, converting all of our .NET 1.1 applications in VS 2003 to .NET 3.0 using VS 2005/2008 (when it comes out). During the process, I have fallen in love again with coding. Generics just sweep me away like the first romance I ever had.
The .NET 3.0 features are just astounding, and it doesn’t just stop with Generics. I truly find all pieces quite equal, from WCF to Generics to the enhancements in VS 2005. Generics allowed me this week to take a very complex boxing and unboxing section of code and turn it into a fine tuned type specific beast that only took two lines to accomplish.
Not only do I throughly enjoy the new features in the actual framework and IDE, but Unit Testing is of great advantage, especially with the ability to publish your results. We have been finding Team System Foundation to be the best decision we could of ever made, as the benefits were not only noticeable immediately, but the productivity was too.
Anyways, I wanted to share my enthusiasm, as if you are still writing in 1.1, you are missing out.
October 22nd, 2007 — .NET, Code, Work
The past two/three days (work days), I have been plagued with the task of working on a complex portion of a project. The piece I am working on, I did not start, but I did write the foundation of it for 5 other projects and its’ success and easy maintenance was largely due to how I designed it.
To keep a long story short, the architecture I used was not followed in this piece and now I am paying the price for something I didn’t do. The original code was developed so the code would do 50-70% of the work for me dynamically. Yes, this has performance cost implications but they were minimal (1-2 seconds at best), but the time it saves is nearly 60-75% of development time.
Now the particular piece I am referring to does a lot of output work. It takes the data inputted by the user and develops a results page to the user describing the information the user typed. Now, to make my life easier, I build a hash table of the user’s values and associate them with a code. The code is related to a table that defines the text to display regarding that entry.
By creating code to associate the hash table data with the database table, the results page can be generated dynamically saving me the countless time of programming each possibility the user can come up with.
Thus, sometimes it is smarter to go a dynamic route at the cost of performance, than it is to develop the most efficient masterpiece you can imagine.
That is my food for thought.
October 5th, 2007 — Code, JavaScript
What? There is more?! Of course. Previously I tackled the horizontal setup of dual monitors, now we tackle the vertical!
So just like window.screenLeft versus window.screenX, window.screenTop only works in IE and window.screenY works in everything else. So here is the code I used to setup a window.*property*:
// Find Top Boundary of current Window
function FindTopWindowBoundary()
{
// In Internet Explorer window.screenTop is the window's top boundry
if (window.screenTop)
{
return window.screenTop;
}
// In Firefox window.screenY is the window's top boundry
if (window.screenY)
return window.screenY;
return 0;
}
window.topWindowBoundary = FindTopWindowBoundary;
Then just like the horizontal setup, I needed to find the Monitor’s Top Border. Like the horizontal counter-part, you need to check the negative y-axis scenario, which left me with this code:
// Find Top Boundary of the Screen/Monitor
function FindTopScreenBoundary()
{
// Check if the window is off the primary monitor in a positive axis
// X,Y S = Screen, W = Window
// 0,0 ----------
// | |
// | |
// | S |
// ----------
// X,Y
// 0,1280 ----------
// | --- |
// | | W | |
// | --- S |
// ----------
if (window.topWindowBoundary() > window.screen.height)
{
return window.topWindowBoundary() - (window.topWindowBoundary() - window.screen.height);
}
// Check if the window is off the primary monitor in a negative axis
// X,Y S = Screen, W = Window
// 0,-1024 ----------
// | --- |
// | | W | |
// | --- S |
// ----------
// X,Y
// 0,0 ----------
// | |
// | |
// | S |
// ----------
// This only works in Firefox at the moment due to a bug in Internet Explorer opening new windows into a negative axis
// However, you can move opened windows into a negative axis as a workaround
if (window.topWindowBoundary() < 0 && window.topWindowBoundary() > (window.screen.height * -1))
{
return (window.screen.height * -1);
}
// If neither of the above, the monitor is on the primary monitor whose’s screen Y should be 0
return 0;
}
So now that we have the Top and Left boundaries written, we can open a window in any setup (2 monitors to 4 monitors to X monitors) using the following and be guaranteed that the new window will open in the same monitor as the parent window (except for IE where IE will not open windows in a negative axis).
window.open(thePage, 'windowName', 'resizable=1, scrollbars=1, fullscreen=0, height=200, width=650, screenX=' + window.leftScreenBoundary() + ' , left=' + window.leftScreenBoundary() + ',screenY=' + window.topScreenBoundary() + ',top=' + window.topScreenBoundary() + ', toolbar=0, menubar=0, status=1');
And thus the finale of opening a child window in a dual, quad, whatever monitor setup.