Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
If your work offers a VPN or *can* offer one, you could use that from home to connect to your work machine. -ner
-
If you truly need some debugging in a Release build, you could always make use of the Trace class. I'd go with Release for your final/public build. -ner
-
I haven't used a separate partition for a pagefile though I heard it might help. Here's what I like to do: C: I like 20 gig, but 10 gig if that's all you can spare. Contains the windows and any extra programs that must run on the C drive. For example, when you install Visual Studio to D:\ it will still put some files in C:\Program Files. D: The rest of the main drive (in your case). Everything I install goes here: Office, Visual Studio, UltraEdit, etc. I prefere a P: partition (or drive) for personal stuff: mp3's and anything I want to save if I have to restore. I use E:\ for all my Visual Studio projects and any related files (data files, test files, databases, etc.). Once a week, I copy everything from c:\windows and c:\program files onto a backup folder (currently an M: partition because it was free). Only once have I had to use it, but it was really nice. I reinstalled windows to C:\ then copied everything back and wham! everything worked just fine. That restored everything I had installed, the registry, etc. Worked out pretty nice - a friend had told me about it. Of course, if you have some kind of backup/restore plan already then you can probably do whatever you want :) -ner
-
I don't think even an experienced team other than Vertigo could convert it as fast as they did (5 days total - 4 to get C into C++ and 1 to get that managed). Vertigo software is MS Gold Certified - they have access directly to the C++ compiler team (among others) and are very well educated in C++. Having their foot inside MS's door is a big help. Also of note, the original Quake 2 code is C-based, not C++. The conversion made it C++ first, and then managed C++. Once in managed code, they "easily" added a radar. For those that didn't read the whitepaper, the bottom line was that the managed version was 85% as fast as the native version. -ner
-
I would definitely read the Refactoring book my Martin Fowler. There is only a brief section near the end on moving a large chunk of procedural code and I personally didn't find that section that helpful. But, I did recently refactor a very large chunk of "black box" code into a handful of classes and the design is MUCH easier to read, change, etc. If you read the book, the first thing you'll notice is that you always refactor in small steps and test a lot inbetween to make sure you're not breaking anything. As an example, my blackbox code needed a number of changes to fix some bugs. It was about a week of changes before I was ready to make any changes. First off, my starting class was 4682 lines long. Yep, a big one. One public method to calculate fees based on a DataSet. I did the following, which worked for me: 1. Remove many if not all temp variables from the various functions. This took a day or two to replace them with equivalent named methods. 2. Break up existing code into methods. Many of the existing methods were large, one was about 400 lines and many (10+) were 100-200 lines long. 3. Move some of the "common" functions to a utility class. On day 3 or 4 I started reviewing the now hundreds of methods and deciding what classes I could use and what methods or properties they needed to expose. That involved mostly creating a half dozen or dozen classes and moving my new methods (that were temp variables) into the class. Finally, I did some more advanced OOP like moving stuff out of the DataSet and into full-fledged classes. The previous design had done everything off the DataSet which was a bad idea. It was very easy to use the DataSet for everything but looking back, it was like having a TON of global variables since all the code had access to the dataset. I could never be sure who (which piece of code) was changing what (what tables/rows/fields). The new design requires a lot less comments on the basic flow of the program. The only comments are in the Why's (from a spec) and not the "What this code is doing". The code is now infinitely more clear as to what it's doing. Also, by moving code into classes I can easily see who's changing what values. A final step, which happened after I did the main refactoring was to go back and move some methods around where they made more sense. I also made a lot of the properties private and exposed the needed functionality through methods. For example, rather than have ClassA use a property of ClassB for some calculation, it often made more sense to have ClassB expose a method to do the calculation itself and ClassA just used the result. They key is to take small steps, make sure you're not breaking anything, and don't worry so much about what's Right (big R). Refactoring is all about not having to worry about getting it right the first time, if you don't know what Right is. If you have a bunch of procedural code, refactor in small bits and eventually you'll start to "see" where the classes/methods are. It's hard to explain, but if you start trying it you'll see. -ner
-
Whoops - my bad. To filter on attributes you must prefix them with @. Try this instead: Dim strExpr As String = "/Books/History/English[@Category=1' and @Cost='20]" -ner
-
Ah, just kidding - but the Quake 3 sourcecode is going to be released: http://slashdot.org/comments.pl?sid=116699&cid=9876519 I wonder if Vertigo Software will convert the Q3 source to .NET as well? Very very curious... -ner
-
You're taking the first match and looping through it's child nodes/elements, but English has no child elements. I'm not sure what text you're trying to get at, but to find English nodes and loop through them, try this: Dim expr As string = "/Books/History/English[Category='1' and Cost='20']" Dim matches As XmlNode For Each match In document.SelectNodes(expr) lstOut.Items.Add(match.InnerXml) Next From your snippet, there is nothing I see that you'd select to put into a listbox. If you show me the full sample xml I might be able to help more. Keep in mind that SelectNodes returns a nodelist of matches. You were grabbing the first match (an English node, if one matched) and looping through it's child nodes. For that to work, your xml would have to look like: <Books> <History> <English> <InnerNode/> </English> </History> </Books> In that case, InnerNode would be a childnode. -nerseus
-
Try: /Books/History/English[Category=1' and Cost='20] That will return the English nodes that match the criteria. Feel free to use * for nodes you don't care about, such as: /*/*/English[Category=1' and Cost='20] Or if "English" nodes only appear at the one level, you can shorten it to: //English[Category=1' and Cost='20] I would guess the first sample is fastest (maybe/maybe not) because of the fully qualified path. -ner
-
I don't think there's a way to do properties with params in C# directly. You would have to do a combination of JoeMamma's and cyclonebri solutions to get what you want. Joe showed how to use an indexer to expose a property like an array. cyclone showed how to expose a private member as a property. If you create a new class that has an indexer and expose your private member variable of that new class type, you'd end up with something like: classA.PropA["hi"] = 123; In this case, PropA is a property in ClassA (classA being the instance). It would likely expose a private member variable such as propA that was of type NewClass. NewClass would expose the indexer as a string ("hi") and return an int value. If you need a sample, let me know. Not that I'd write one up, but I'd think about it :) -ner
-
Sql (Access) needed to search for string within a string
Nerseus replied to zubie's topic in Database / XML / Reporting
You could try something like: SELECT * FROM MyTable WHERE MyField LIKE '*Murph*' Would return rows where MyField contained "Murphy Is Nice", "Is Murphy Nice" but not "Bob is Nice". -ner -
You have the right idea - using Application.Run() will create a running thread that stays alive until you use Application.Exit(). When you call Exit is up to you. One solution might be to have every form register itself into some static class/array/hashtable on load and remove itself on unload. When unloading, simply see if it's the last form and have it issue Application.Exit. You can wrap all that up in a base form (the registering, unregistering, and Application.Exit) if it works for you (you don't already have a base form). As for creating/showing the first or subsequent forms, you simply do something like: Form startupForm = null; if(myProperty == true) { startupForm = new Form1(); } else { startupForm = new Form2(); } startupForm.Show(); Application.Run(); Hopefully that will spark some ideas... -ner
-
I don't know if Goto's are ever acceptible :p In all honesty, a Goto in Refactoring terms would be a smell. It points that you are skipping around some code - maybe a method to check first would get you out, or the code your skipping needs to be in a method so that you don't mind skipping over it. Generally, a Goto is used as a convenience to skip over a LOT of code or to get out of a bunch of nested code. In either case (lots of code or big nests), the code is probably somewhat unreadable and a good dose of refactoring would make the goto unnecessary. But, a bad smell doesn't mean anything needs to change. If it works and is easy to understand then keep it - even a Goto. -ner
-
I'm no DB Admin, but I don't think anything like that exists in SQL Server (null out the child table's FK). You could probably do it with triggers assuming the foreign key allowed nulls. -ner
-
@Cuffee: Your solution should be the same as his. You can use the @ to NOT have to double up the backslashes or just double them up. I think he had the file in the wrong place. Bad backslashes usually mean syntax errors - but his MessageBox showed the right path (at least, one that looked "good"). -ner
-
I'm a nerd, not a geek, but I also have a house/picket fence (or the desert equivalent). I went with the house/picket fence just because my son may be reading this one day :p -ner
-
First, it seemed slow to me in IE but I didn't compare it to anything. The source seems very cookie-heavy. If you have a lot of cookies or if their cookie is large, maybe it's all the cookie processing by IE? Since it uses a javascript file maybe you're using an old/new/inbetween Java VM (if that's what's interpreting the javascript)? Of course, IE is far from perfect :) As for spyware removal, I use Spy Sweeper. It was $25 at a local Costco. I had previously tried Spybot S&D but they don't appear to be updating their checkers anymore. I had one nasty browser plugin that neither Spybot nor AD-Aware would remove. I tried them first but it was Spy Sweeper that finally got it out. If you want to try it, they have a "full" trial edition that lets you download their spyware definitions one time. Good to see if it finds anything even if you don't want to buy it. -ner
-
<Off topic a bit> If a boss thinks OOP is just code-bloat then they need to be informed (if you're going to attempt it, make sure you know what you're talking about first!). There are more and more books coming out that explain OOP a LOT better than most universities teach. Meaning, it's more than just objects that encapsulate stuff. Sure, that's what OOP is but until you've seen a *good* OOP design, it's hard to showoff what it does. From my experience, OO code (when done right, which is VERY hard to teach) is MUCH easier to maintain and enhance. I've tried adding features to non-OO code and the first 2 or 3 enhancements come "easy". After that, they get harder and harder and I generally end up breaking stuff while trying to fix or add something else. With OO code that rarely happens - ie, a good thing :) -ner
-
If this is for sample apps or even some kind of shareware app, I would go with Access for the exact reasons you mentioned: it's easy to setup/copy the ONE file (or two if you add a password) and it's "fast enough". SQL Server is extremely expensive. The version that comes with Visual Studio is a developer edition that can't be redistributed while the Access DB can (assuming you own a copy of Office that came with Access or Access by itself). An alternative is MSDE (Microsoft Data Engine) which is basically a limited version of SQL Server. It's a lot harder to setup than either Access or SQL Server as there are no GUI tools, command line only. I'd take at least 30-60 minutes to read the readme file before attempting to set it up and maybe more if you want to have it run on a network. Its advantage? It's faster than Access, much more robust, and more secure. Don't get pulled into the hype that Access is slow or "old". It's an excellent choice for learning Database "stuff" and even for distributing your EXE. I've seen lots of professional software that use Access including one of my favorite applications: ThumbsPlus. -ner
-
$10 says the file isn't in that folder, but in your \bin\Debug folder. You're using Application.StartupPath which points to where the EXE is (or your working directory) which is \bin\Debug by default. -ner
-
If you're serious, then "liar, liar, pants on fire!". But that's not the point :) We employ two university (USA) teachers (not professors) and they are both excellent. They spend their days teaching and work parttime at night for my company. Unfortunately, most of their students hate them and think their classes are "too hard". From my college days, I found three basic types of students: 1. Those that wanted to learn everything about computers and/or programming and would read/digest everything they could find. 2. Those that wanted to learn computers and/or programming because they wanted a good job - no strong desire to do anything extra, but good at what they learned. 3. Those that picked computer science for some unknown reason and complained about how hard things were. I was in category 1 - I *wanted* extra credit just so I would have more programming to do. Unfortunately, from what I saw, about half the class was in category 3. If a professor tried to teach anything advanced, he'd lose over half his class which was frowned upon at the time (lots of complaints to the head of the department) - I had inside info because I was friends with some of the professors. From talking to two coworkers, things haven't changed. That doesn't explain or excuse why a professor/teacher teaches things *wrong*, such as using MsgBox in .NET. As pointed out, if the class isn't a "learn programming" or ".NET programming" class but strictly a GUI class, then it might not be so "wrong". I'd still talk to the teacher after class and at least mention that there are new, more standard ways of doing a message box. I wouldn't suggest to them that they're "wrong" because that could be subject to debate, if you like pointless debates. Since you're obviously in my category 1 and know the right way to do it, I'd maybe make the suggestion to the teacher but go ahead and do it the right way anyway. -ner
-
You know you've spent too much time on this forum when
Nerseus replied to samsmithnz's topic in Water Cooler
Oddly, these forums are not in my Favorites at all - at home or at work. I usually just type "dotnet" and select it from the drop-down. I'm stingy with my favorites :) I have only five main "favorites" (the ones that aren't in subfolders). The one I use the most: Iowa Code. Sometimes work is fun and exciting and other times I go to that website :) -ner -
Try Environment.CurrentDirectory (or something close to that). -ner
-
The following will get it for you. I assume Date is one field and you can split it into the Date/Time? If not, let me know. SELECT SchoolID, MIN(Date) AS [Date] FROM School GROUP BY SchoolID
-
Another approach to bri's idea is to just set a new, shorter variable to your object (only works if it's a class - not for structs): DataColumn col = dtDataTable.Columns[1]; col.MaxLength = 5; col.SomeProp = "hi"; ... col = null; The last line is optional (setting col to null). It won't null out the column, only the variable reference col. None of these provides the ".Property" syntax that VB offers, just shortcuts for typing. -ner