Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
From things like this article, Nader might not even be an option. -ner
-
Forgot to address your "real" question - where do business rules belong. That can't really be answered with one answer, it's one of those "it depends" kinda things. For simple objects with unchanging rules, you can embed business rules right in the object. Or, if your archictecture is relatively small and doesn't require more robust rules, then embedding them in the object might work great! In other scenarios, you may want to separate out business rules and apply them at a specified time. That answer is kinda fuzzy, so let me tell you the way I've done it. A "big" transaction has many business rules; some are small (this field is required and has maxlength=30), some are very complex even requiring a call to the database to verify information. All business rules for a given transaction live in a single file. We currently use a combination of XPath and asserts to detect errors (our transactional data is all stored in DataSets). We test for errors at a couple of different times: sometimes when a user leaves a field (or tries to), sometimes when they leave a row (such as editing in a grid), and sometimes not until the "save" button is pressed. Our more recent coding efforts have been using C# code in a separate file. The C# code is downloaded to the client (all in-memory) and compiled on the fly. This code validates the business rules instead of the XPath and asserts. Both of these last two solutions requires a good framework and lots of standards to make sure everyone does things the same way. If your classes are smaller, I would embed the rules right in the object. With a good set of unit tests you should have very robust objects. Check out Test-Driven Development in Microsoft .NET if you want to go this route - it might help. -ner
-
Business rules aside, how do you want to use the object? What would the code on the outside (using the object) look, ideally? First, assume good data, then figure out where and how you might want to check for bad data. In your case, it sounds like you create the object, change two properties repeatedly, then use it to draw a line (or lines)? If so, you only need to check the business rule when you go to draw (maybe?). If you were going to save the data (after changing the two properties), then I'd say check the rules before you save. Sometimes it makes sense to validate a business rule sooner. But in your scenario, you say you can't easily validate the business rule on the change of a single property. Let the use of the object drive it's design, business rules, and implementation rather than using what you think a robust object should look like. -ner
-
I think you need to overload = for that to work, because of the line "c=t+f". You should have had a warning, I believe... -ner
-
The types that you specify for an operator are the types you want to cover. If it makes sense that your type work with the base types, such as int, then you would have to write an operator overload to use both types: yours and int. For example: public static Complex operator +(Complex lhs, int rhs) { return new Complex(lhs.real + rhs, lhs.imaginary); } This says allow adding a Complex type with an int, only like this: Complex a = new Complex(1, 2); int b = 6; Complex c = a + b; If you tried "Complex d = b + a;" it wouldn't compile as you didn't define an operator for a Complex type on the right, with an int on the left. Some books like to use lhs and rhs for each param in an operator overload to help spell out "left hand side" and "right hand side". -ner
-
Just be honest with your answers. If you know the answer, tell them. If you might know, but not 100% sure - tell them what you know and which parts you think you know. If you don't know, just say "I don't know". Also, if you don't know but know how to find out, tell them! Tell them how you use MSDN library as a reference, or a certain book, etc. If they're good developers they know that not everyone memorizes every detail. Finding an answer quickly is the sign of a good developer, too. Of course, if they ask "Why would you want to use the Response object" and you say "I don't know" then you might be applying for the wrong job... -Ner
-
The best way to design your object, is to first figure out how you want to use it. It sounds like you're trying to force limitations on the user based on how you want to implement it. An object is only as good as the interface it exposes to the code calling/using it. While I wouldn't worry too much about the performance, is there a need to check that the start is less than end (and vice versa) every time you set it? If you plan on making x number of changes before using the object, maybe the object supports an IsValid property or method? -ner
-
Syntax error in update statement
Nerseus replied to shootsnlad's topic in Database / XML / Reporting
Surround all the columns/tables with brackets. Some words, like Year, are reserved words. For example: SELECT [Year], ... instead of SELECT Year, ... -ner -
I'm not sure if your database supports it, but you can usually do a "sub select" to combine your queries: select count(*) from StimulanzResult WHERE substr(br_date,0,11) = ( select distinct substr(br_date,0,11) as myDate from StimulanzResult WHERE br_DATE LIKE '%%%%-09-%%' ) If your database supports it, I'd suggest using a MONTH or DATEPART function (those both exist in SQL Server, not sure about your database). For example: SELECT count(*) FROM StimulanzResult WHERE MONTH(br_date) = 9 OR SELECT count(*) FROM StimulanzResult WHERE DATEPART(month, br_date) = 9 -ner
-
You need the "GROUP BY" clause of SQL: SELECT Course_Name, Count(StudentID) as Population FROM Details GROUP BY Course_Name The group by will give you a distinct list by its very nature. -ner
-
I have a Microsoft Internet Pro keyboard at work - they don't make them anymore though. Has ALL the buttons (multimedia, office, etc.) plus 2 USB ports (handy for my mouse). I LOVE that keyboard. I LOVE the multimedia keys at work - play, next, prev, etc. controls WinAmp, Windows Media Player, or whatever you like. At home I have a $10 cheapie from BestBuy - PC Concepts iMMT. It's very light, worked well for years. It has some multimedia functionality but without a manual and the drivers being from 1999, I don't use that functionality. I also have a nice Logitech keyboard/mouse combo - both BlueTooth wireless. They work/feel great! That was the first Logitech mouse I liked. As for drivers, I wish I could have used the MS 4.x driver at work since it allows remapping mouse buttons to ANY keystroke - even PER application! I loved having the middle mouse button (the wheel) be "Ctrl - -" (control dash), which was "go to previous cursor position". But alas, the 5.x drivers don't have that functionality. :( -ner
-
Controlling it yourself in an automated way...? I suppose you could write an add-in for Visual Studio to bump the version in the file. If you want to build outside of Visual Studio, such as a batch file, that batch file could launch a WSH file or similar to modify the version number. I prefer to do it manually by modifying the AssemblyInfo.cs file. It's not as bad as it seems, even with SourceSafe involved (have to check it out/in each time you change it). In some cases it gives greater control - such as when you don't actually want to change a build/revision number on child assemblies. If you use SourceSafe, an automated solution would likely require you to remember to check out the file before running/building, or would have to work with SourceSafe (ole automation) directly to automatically check the file out/in. -ner
-
Thanks for the comments! I don't think anyone here is getting paid, to the best of my knowledge. It constantly surprises me (in a good way, like finding out you get free candy on halloween) that so many helpful and useful people come here and post their questions and answers. -nerseus
-
I don't believe the build or revision numbers have anything to do with the system's date or time. If you specify a * for a build or revision, .NET generates a random number (I believe). Could be wrong, but that's what I thought I read - the help files for .NET 1.1 don't indicate that the date/time is used for a *. I would strong suggest NOT using * for any part of the build number or revision if you want to check versions. The * does NOT auto-increment the number like it did in VB6 and prior. If you want an incrementing number, you'll have to specify the values manually or use a 3rd party tool. -ner
-
If this is for a managed C++ project, you're in luck! Just add a reference to the VB.NET DLL (or project, if both projects are in the same solution)! If this is for unmanaged C++, you're outta luck, mostly. You can probably wrap the VB.NET code as a COM object and create/use the object from unmanged C++, but that's a LOT of work. -ner
-
When you cast to a type from object (an unknown type at compile time) there will be a slight performance cost. The thing is, you MUST cast it if you want to use it as that type so it doesn't matter too much :) If you cast a string to a string (I've seen it done!) then, I would guess, the compiler would ignore the cast: string s = "hello"; string s2 = (string)s; That would be true for any object being cast to its native type. On a similar note, if you have a class hierarchy and you cast to a lower-level type, there shouldn't be a performance hit - the compiler will know how to convert it internally and the compiled code will call directly into whatever method/property you referenced. For example: public class ClassA { public string Test() { return "hello"; } ... } public class ClassB : ClassA { public string Test2() { return "world"; } ... } ClassB b = new ClassB(); string s = ((ClassA)b).Test(); Of course, in the above example, you don't have to cast variable b as ClassA - the compiler will let you call Test directly. But for the purposes of asking about performance, casting as the base type (ClassA) on a variable declared as a "higher" type (ClassB) should have no performance impact. -ner
-
Select method works for String, not DateTime.ToString?
Nerseus replied to Gladimir's topic in Database / XML / Reporting
I can't think of anything different on Windows 2000 from Windows XP that would affect the way your code is working. I have multiple clients including two QA machines that work fine with the same code you have (well, similar, not the same). I wonder about the date format: What does the string latestFileDate show? You're not specifying a format for the date string and so it will be up to Windows Regional settings. Maybe try forcing something like "MM/dd/yyyy hh:mm:ss" (that may not be right, going from memory as an example). Can you verify this is a problem on the client machine using a small test program? When I have "client" issues, I'll write a small EXE that mimics the code in question. Something that creates the DataSet, fills it with two rows, and performs the filter you describe. Try running that on the client machine and see if it works/doesn't work. If it doesn't, you can upload that for us to try. Note (nothing to do with your problem): I'm not sure which is better, but I like to use the following when adding columns dynamically: fileinfo.Columns.Add("LastModified", typeof(System.DateTime)); Using typeof can generate compile error if System.DateTime isn't spelled right, whereas using Type.GetType from a string might have runtime errors. -ner -
You can VERY easily do a "preserve" yourself, if it's what you need: int[] a = new int[] {1, 2, 3, 4, 5}; int[] b = new int[10]; // the array to preserve "to" a.CopyTo(b, 0); If this is in a function, just return b. If you need the array back in a, just assign a to b: a = b; As a note: Generally, you won't need to preserve an array. If you really need to keep resizing an array, you're probably better off with ArrayList and converting to a true array when you're done (if that's even needed). If you're resizing in a loop, you likely know the size of the array to begin with and you can just set the size of the array once, before getting in the loop. The "Preserve" keyword in VB works like the code posted above. That is, it's *copying* the array every time. If you do this a lot on big arrays, that's a LOT of extra overhead. -ner
-
That's a good book, but not a lot of in-depth detail. It's great for getting a big picture of common problems though. -ner
-
You're probably not going to learn much about Linux until you've used it for awhile, just like any operating system or tool. I'd suggest going with one, all the way, use it for awhile - at least a week. Then maybe you'll come up with a list of things you like or don't like - something you can compare when reading up on each distro of linux. Since there are so many variations, it's going to be hard to find one you like just by what you read. -ner
-
Lots and lots of things! The big question right now: when will half life 2 *really* come out? -ner
-
I have a P4 3ghz at work with 1gig of memory and it runs pretty good. At home I have a P4 1.7ghz with 1.5 gig of memory and it seems to run at the same speed - very nice. Prior to this setup, my work machine had only 512 meg memory. The increas in memory had a noticible improvement. Based on this limited info, I'd say that an increase from 512 to 1 gig makes a difference, at least for large WinForm projects. It might be possible that the increase of 1gig to 1.5gig also has an improvement as my slower processor with more memory seems the same speed. -ner
-
You don't, you include it in the project as a resource. -ner
-
My filter (very simple): Any mail from people in my address book stay Everything else is put in a folder I call "Junk", which I delete about twice a day (it gets big quick). If anyone wants to send me something, they'd better be on my list or they don't get through. If I sign up for something new (like a Credit Card service), then I have to scan the Junk folder for a little while to catch all their emails and add them to my filter. This is the "I only keep what I'm sure I want" filter - everything else is Junk by default as opposed to most filters which try to spot the junk. -ner
-
I didn't see a question in that last post... As P said, why not tell us what you're trying to do rather than what you're doing (and it sure seems odd, whatever it is). -ner