Hi all, I've recently inherited a couple of projects that I am having a terrible time getting my head around. As I stare at a method of 600+ lines that is doing all manner of unrelated things, trying to make sense of it I wonder: Is there a formal name for what I am doing here? Surely this has a name, surely thousands of people have done this sort of thing before, surely there are resources to be had. Any pointers I could get here? A generic approach maybe? Point me in a direction? blah, -Jack
Jack Vanderhorst
Posts
-
Deconstructing a mess -
Codeproject programming test?Dude that's exactly it, I never would have found it. Thanks muchly -Jack
-
Codeproject programming test?no
-
Codeproject programming test?G'day all, I vaguely remember reading at some point a Programming Interview sort of question for a position working here at Codeproject, I'd like to track it down. It was something to the tune of "Along with your CV, please include an application, as complex or as simple as you like, that does xyz with key-value pairs" Am I imagining this? Could someone direct me to it? Cheers, -Jack Disclaimer: I'm interested in scamming it, or at least an idea from it, for my own purposes :)
-
Issue with threading behaviour ... I thinkFirst of all, sorry for the tardy reply. With your suggestion I was able to confirm DoWork was running, the Test Framework was on thread 12, DoWork was on 14. Now I'm wondering, if the BackGroundWorker only knows how to notify the "main" thread, and the Test Framework is not on the main thread, doesn't that mean I'm sort of stuck with testing this BackGroundWorker business? Since I know the DoWork methods are running I suppose I could run a separate set of tests to confirm their results, but ick :) Or, maybe I could ditch the BackGroundWorker and code the necessary threading behaviour myself? Do you think I could work around my issue in this way?
-
Issue with threading behaviour ... I thinkI have a class, call it Inventory, it does some basic database tasks using a
BackgroundWorker
like SaveChanges(), LoadFirstItem() etc. In my RunWorkerCompleted method PropertyChanged events are fired to notify the UI to update itself. This works swimmingly in my WinForms app and the BackGroundWorker is clearly doing it's thing successfully, but I'm having trouble writing[TestMethod()]
's for the class in a test project. In a test project, it seems like after calling RunWorkerAsync the DoWork method doesn't get called, and as a result neither does RunWorkerCompleted, and my tests always fail. Breakpoints in DoWork or RunWorkerCompleted are not hit. I assumed this was because my test method was not waiting for the background thread to finish so I've tried sleeping the main thread to see if the BackgroundWorker can catch up, I've tried the Application.DoEvents() thing, but I'm a bit of a rookie in the threading department... and the authoring of Unit Tests department for that matter! uh oh :) Any pointers on how to please my BackgroundWorker in a[TestMethod()]
? -
Javascript printing questionGood to know, cheers :)
-
Javascript printing questionYes sir! Thank you, exactly what I needed
-
Javascript printing questionIn Javascript I am trying to create a new window, write some html into it, and then bring up the print dialog for this newly created window automatically. The follow code demonstrates what I am trying to do, the new window appears and is successfully written to but the print dialog does not show up. What gives?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Printing Example</title><script type="text/javascript" language="javascript">
function HelloPrint()
{
var winPrint = window.open("", "");
winPrint.document.write("<H3>Hello World</H3>");
winPrint.print();
}</script>
</head><body>
<a href="" onclick="HelloPrint()">Go</a>
</body>
</html> -
Integer conversion for dummiesThink I figured it out:
$objResult = $pdoCmd->fetch(PDO::FETCH_OBJ);
$intValue = (int)$objResult->MyColumnName;Cheers
-
Integer conversion for dummiesI'm successfully calling a mysql stored procedure using PDO with the following line:
$pdoCmd->fetch(PDO::FETCH_OBJ)
It returns an object that I need to get converted into an integer, seems straightforward enough but when the object is say "1000" and I cast to an int I get a value of 1. How can I convert an object to an integer and keep my zeroes?
-
Sending E-mail through default settingsHrmph. Thanks very much both of you, I suspected as much. Cheers! -Jack
-
Sending E-mail through default settingsMorning CPians, dig me out here :) I need to send an E-mail from my app through the default E-mail setup on a client system. (invoices and order confirmations, exciting stuff) I have learned through some Googles that MAPI used to do this (no I haven't tried, it looks pretty old), then MAPI was replaced by System.Web.Mail, which has now been replaced by System.Net.Mail. Great, BUT, these .NET replacements both need to be told the E-mail server's address and/or domain, which my users will definitely not know. The Outlook automation assemblies look like an easy option, but I'd just as soon not limit myself to Outlook, or move outside .NET Is there some way to have System.Net.Mail just send the mail through whatever default E-mail settings exist on a user's machine? Perhaps I can look up the E-mail settings somewhere? Magically impersonate the user? Ideas? Guidance?
-
Date formatting issueWell I'll be, thanks.
-
Date formatting issueI'm using
DateTime.Now.ToString("M/d/yyyy")
to try and format today's date. I've noticed that when I change my regional settings through control panel, it changes the result I get from this method. When I set my default date format to dd-MMM-yy in Control Panel, it changes the output of my ToString method from containing slashes (as I've specified in my format string) to dashes, which I can only assume are coming from my regional settings. I thought the point of specifying my own format string was so that I could, oh I dunno, specify my own format?! Are my control panel settings really affecting this method call? Why in the heck? I realize I can just code my own cheesey routine to format dates and avoid the issue, but I'd like to understand what's going on here.
-
Leasing and sponsoring .netFor the first response, neither did I! I just changed the renewed lease time to 5 days so I could easily see it was working. For the second, I agree it sounds less than ideal, but I'm not sure how else you would do it. Maybe your design could change a little? Perhaps the client-side object can quietly "phone home" asychronously for some new info? Perhaps the client-side object could raise an event that you handle on the server?
-
Leasing and sponsoring .netFor the first question, this code runs fine for me and the lease is being successfully renewed. :wtf: For the second question, you already are, when you run this code the client is interacting with the remote (ie. proxy) object and the actual object exists and is even outputting text onto the Server's console. I haven't done much with remoting, but that's my two cents, hope it helps.
-
How to detect when an application is about to exitI think you may be looking for a specific Windows message... You can override
PreProcessMessage
in your form and basically "hook" all manner of unusual things. I wish I knew which one you were looking for exactly or if it even exists, but whenever I've had to handle unusual user actions that didn't really exist as ordinary events, this has worked for me. It's just been a matter of finding the correct combination ofmsg.Msg
,msg.HWnd
, andmsg.LParam
that you are looking for in the overridenPreProcessMessage
routine. -
Customization of the Installation setup in .net framework 2.0I believe this is what you are looking for: http://msdn.microsoft.com/en-us/library/system.configuration.install.installer.aspx[^]
-
datagridviewIf your
DataGridView
is bound to aDataTable
then this may be what you're looking for: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx[^] I love these columns, they're smokin' fast :)