Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

MtnBiknGuy

@MtnBiknGuy
About
Posts
16
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • The Role of Patents?
    M MtnBiknGuy

    Corneliu, It sounds to me like you need to educate yourself about what intellectual property protections a patent actually grants the inventor. For example, even if you have a patent, someone else can come along and manufacture, market and profit from the exact thing described in your patent. There are no patent police. There is no government force working on behalf of patent holders to protect their rights. Patent rights are enforced through the court system. The only way you can stop an infringer is to take them to court. If you have enough money to put up a good legal defense, then your patent potentially has some value. If many people infringe your patent, but you don't (or can't afford to) sue all of them, then you could possibly end up forfeiting your patent rights due to inaction. On top of this, a US patent only provides protection in the US. Someone can manufacture and sell your product in Canada, Europe, Asia, Africa, etc. and you are powerless (unless you want to obtain expensive patents in each country and defend your rights in the courts in each country). My advice is that you should not waste your time patenting something you already know is not unique. I say this because I presume your capital is limited. You should use your energy to do something that has a greater chance of payoff. Another consequence of the way this works is that you could just go ahead and manufacture a product someone else has patented if you know for a fact that the other person would not sue you. Of course, once the other person sees you making millions of dollars, they will most likely decide to sue you at that point, and they might find a lawyer willing to take the case on contingency.

    The Lounge question csharp com design help

  • Has anyone switched to Team System? Will you?
    M MtnBiknGuy

    My company tried Team Foundation Server (with VSTS) for source code control. We had been using VSS and SOS. We ultimately decided not to use TFS for source code control. You can see some comments about why at the MSDN forums. (For example, see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=267779&SiteID=1) Basically, TFS is way overpriced, demanding to deploy and administer (in spite of testimonials that it is a good fit for small teams, I would have to disagree), and buggy. However, MS did just annouce a service pack. I assume that will solve most of the bugs that we encountered. Once we decided against TFS, we evaluated Vault and Subversion, and we looked at quite a few more. It ended up being a real toss up between Vault and Subversion. These were the two clear winners. Subversion is nice because it is a "standard" in the open source community. Vault is nice because it is easier for someone moving from VSS, it is more flexible in terms of setup/deployment on our servers, and it uses MS SQL for the data. We ended up going with Vault at work. For my personal projects, I could have chosen Vault (because a 1 user license is free), but I decided to use Subversion because that's what everyone in the open source community is using. If the TFS service pack solves the bugs and if your company has the money and has a sys-admin, then TFS would not be a bad choice. It is very feature rich. Starting with DotNet, I became a huge Microsoft fan and my company became a 100% MS shop. However, starting with VS 2005 (more bugs than VS 2003!), the new MSDN pricing, the new licensing schemes, etc., we have started questioning whether we will continue to be a 100% MS shop. Something seems to have changed at MS, and we don't like it. I'm going to start moving more in the direction of open source tools. If Sharp Develop gets an integrated debugger, we'd even give that a look.

    The Lounge c++ visual-studio sysadmin collaboration question

  • New job
    M MtnBiknGuy

    My job is about 3000km away, but my commute takes me about one minute. I just wake up and walk from my bedroom to my home office and connect to the internet. Why aren't you guys telecommuting? Driving hours a day is crazy for someone who is a developer. We just need internet, IM and skype.

    The Lounge question career

  • Your chance to provide input for a book!
    M MtnBiknGuy

    (my post from Tom's forum copied here for the benefit of Code Project users) Tom, I would like to see a C# book with more coverage of the following issues: 1. Performance. For example, an expansion of the stuff in Jan Gray's article (http://msdn.microsoft.com/library/?url=/library/en-us/dndotnet/html/fastmanagedcode.asp) would be excellent! Also have a look at the topics in the dotnet framework performance newsgroup and hit on some of those. 2. Threading and async delegate calls, in depth! Top to bottom, beginning to end, easy to hard. 3. I'm waiting on the equivalent of Scott Myers's "Effective C++" books for C#, so the more such tips you can include, the better! 4. As a continuation of #3, I'd like to see a bit about lazy evaluation in C#. For example, I often use a property that creates the object on demand, and I'd like to find more similar tricks. 5. More on code generation. 6. More on how the C# compiler works. 7. LOTS on generics! This will be exciting. I'm looking forward to your book and the new laguage features!

    C# c++ csharp dotnet com question

  • Unrolling a loop: why can't .NET add 1 + 2 + 3 + ...
    M MtnBiknGuy

    ...probably more like I've taken too many crashes on my head

    C# csharp data-structures help tutorial

  • Unrolling a loop: why can't .NET add 1 + 2 + 3 + ...
    M MtnBiknGuy

    leppie, Does CodeDom CodeSnippetStatement take care of breaking long lines or does it too have a limit on the length of a string it can take? Dave

    C# csharp data-structures help tutorial

  • I need a horizontal tree control
    M MtnBiknGuy

    I think an org chart control would do what I need. I searched on Google and CodeProject, and I only found one org chart component: http://www.anextech.com/AnexTree.htm If anyone has other suggestions, I appreciate them. I don't mind purchasing a good control, but I would like to get source code with it. The above control doesn't include source. Otherwise, it's pretty much what I was looking for. Thanks.

    C# data-structures question

  • I need a horizontal tree control
    M MtnBiknGuy

    That's an excellent tip. Thanks! Dave

    C# data-structures question

  • I need a horizontal tree control
    M MtnBiknGuy

    I need a horizontal tree control that would look like all the trees one sees in data structures textbooks, but have all the usual functionality (check boxes, drag/drop, etc.) Does such a thing exist? The root would be center/top. Nodes would grow down to the left or right. Leaves would all be at the bottom. How hard would it be to convert a std tree control into a horizontal one?

    C# data-structures question

  • Unrolling a loop: why can't .NET add 1 + 2 + 3 + ...
    M MtnBiknGuy

    leppie, Do you happen to know why the following method "is not a valid program"? It compiles fine, but the runtime won't even try to run it. It contains 500 statements (I cut out 497 of them for this post) like those below. The method represents another unrolled loop. (And this is the one I mentioned that is actually 5-10 times slower than the loop after it's unrolled.) I appreciate any comments. Dave P.S. I forgot to mention that the problem is related to the number of statements in the method. 1000 doesn't work. I think it works up to a few hundred statements, then stops being "a valid program." public double DoBruteForceCompute() { double bruteForceSum = 0; point1=coeff1*table[0][0] +coeff2*table[0][1] +coeff3*table[0][2] +coeff4*table[0][3] +coeff5*table[0][4] +coeff6*table[0][5] +coeff7*table[0][6] +coeff8*table[0][7] +coeff9*table[0][8] +coeff10*table[0][9] +coeff11*table[0][10] +coeff12*table[0][11] +coeff13*table[0][12] +coeff14*table[0][13] +coeff15*table[0][14] +coeff16*table[0][15] +coeff17*table[0][16] +coeff18*table[0][17] +coeff19*table[0][18] +coeff20*table[0][19] +coeff21*table[0][20] +coeff22*table[0][21] +coeff23*table[0][22] +coeff24*table[0][23] +coeff25*table[0][24] +coeff26*table[0][25] +coeff27*table[0][26] +coeff28*table[0][27] +coeff29*table[0][28] +coeff30*table[0][29] +coeff31*table[0][30] +coeff32*table[0][31] +coeff33*table[0][32] +coeff34*table[0][33] +coeff35*table[0][34] ; point2=coeff1*table[1][0] +coeff2*table[1][1] +coeff3*table[1][2] +coeff4*table[1][3] +coeff5*table[1][4] +coeff6*table[1][5] +coeff7*table[1][6] +coeff8*table[1][7] +coeff9*table[1][8] +coeff10*table[1][9] +coeff11*table[1][10] +coeff12*table[1][11] +coeff13*table[1][12] +coeff14*table[1][13] +coeff15*table[1][14] +coeff16*table[1][15] +coeff17*table[1][16] +coeff18*table[1][17] +coeff19*table[1][18] +coeff20*table[1][19] +coeff21*table[1][20] +coeff22*table[1][21] +coeff23*table[1][22] +coeff24*table[1][23] +coeff25*table[1][24] +coeff26*table[1][25] +coeff27*table[1][26] +coeff28*table[1][27] +coeff29*table[1][28] +coeff30*table[1][29] +coeff31*table[1][30] +coeff32*table[1][31] +coeff33*table[1][32] +coeff34*table[1][33] +coeff35*table[1][34] ; [...] point500=coeff1*table[499][0] +coeff2*table[499][1] +coeff3*table[499][2] +coeff4*table[499][3] +coeff5*table[499][4] +coeff6*table[499][5] +coeff7*table[499][6] +coeff8*table[499][7] +coeff9*table[499][8] +coeff10*table[499][9] +coeff11*table[499][10] +coeff12*table[499][11] +coeff13*table[499][12] +coeff14*table

    C# csharp data-structures help tutorial

  • Unrolling a loop: why can't .NET add 1 + 2 + 3 + ...
    M MtnBiknGuy

    I found the problem. I think you could have guessed it -- it was related to the line limit. Here's what I was doing. I was using code to generate my unrolled loop code. I was then compiling this in a process and using reflection to load the assembly and invoke the method. I was not getting any compiler errors, nor was I getting any runtime errors. I was just getting incorrect math results. However, when I posted the code (without the reflection part) everyone else got the correct results. This prompted me to look at the reflection/compilation code more closely. It turns out the when I pasted the generated code into the IDE I discovered the line limit you mentioned. I inserted a new line in my generated code after every 200 terms, and presto- the math results were now correct. It's a bit disconcerting that I didn't get a compiler error from the command line compiler. I don't know why yet. Does the command line compiler have that same line limit? I assume so, given my experience. I guess the compiler just took as many terms as it could and somehow terminated the statement and produced a runnable program ... all very strange. I wouldn't have thought that possible.

    C# csharp data-structures help tutorial

  • Unrolling a loop: why can't .NET add 1 + 2 + 3 + ...
    M MtnBiknGuy

    Yes, I'm unrolling the loops for performance reasons. So far, in my timing tests, the unrolled loops are about 5-10 times SLOWER (it's not the example code I posted. In that code, the unrolled loops are faster). Figure that one out. There is a range of performance differences. Unrolling a loop AND hard-coding the logic (via reflection emit) is about 3000% faster according to Jesse Liberty in his Programming C# book. On the other hand, in my complex case where I unroll the loop but still require 2 dimensional array lookups in the unrolled lines of code, I see the slower performance I quoted above (average loop 190ms, average unrolled code 980ms). When I get a chance, I could post my code (if anyone is interested, that is). Dave

    C# csharp data-structures help tutorial

  • Detect cause of application memory leak
    M MtnBiknGuy

    I see that the word "defererenced" has taken on a whole new meaning in C#! This is very funny! :omg:

    C# csharp performance question

  • Unrolling a loop: why can't .NET add 1 + 2 + 3 + ...
    M MtnBiknGuy

    Take some standard code such as shown below. It simply loops to add up a series of terms and it produces the correct result. // sum numbers with a loop public int DoSumLooping(int iterations) { int result = 0; for(int i = 1;i <=iterations;i++) { result += i; } return result; } Now translate this into a specific solution that doesn't use looping (and use the same value for the number of iterations the loop performs). This code returns an incorrect result. The method consists entirely of a very straightforward code statement, but in this case .NET adds the numbers incorrectly. public double ComputeSum( ) { // Brute force sum method // For iterations == 10000 double sum = 0+ 1+ 2+ 3+ 4+ 5+ 6+ 7+ 8+ 9+ 10+ 11+ 12+ 13+ 14+ 15+ ... + 9997+ 9998+ 9999+ 10000; return sum; } The above method returns an incorrect result with any number of terms above about 200. It will correctly add 1 + 2 + ... + 200, but it will NOT correctly add 1 + 2 + ... + 1000. I have just run across this, and I have not yet researched the possible reasons for this behavior. It may be a known issue related to either stack size or the length of a code line, but to my knowledge it hasn't been discussed in any of the "popular" literature on C# and .NET. I need to write code like this, so if anyone has already encountered this issue, please advise me. Here's another example that also creates problems, but of a somewhat different nature. Take the following code and translate it into a specific, non-looping method and try to execute it using reflection. It fails. public double LoopToCompute() { double sumOfProducts = 0; double grandTotal = 0; for (int i = 0; i < maxRows; ++i) { for (int j = 0; j < maxCols; ++j) { sumOfProducts += coeff[j] * table[i][j]; } a_point[i] = sumOfProducts; grandTotal += sumOfProducts; sumOfProducts = 0; } return grandTotal; }//LoopToCompute The above code works -- but it's equivalent code with loops unrolled (shown below) doesn't work unless the maxRows is set very small. For small values, the 2 methods (above and below) produce identical results. There is nothing "wrong" with the code in that sense. It's similar to the above situation. If the "size" of the code statement or the number of code statements is too large, .NET fails. In this case (using reflection) it doesn't return the incorrect result, as the first example did. In this case, reflection calls it an invalid program and refuses to

    C# csharp data-structures help tutorial

  • Opening a form inside another
    M MtnBiknGuy

    One other approach would be to derive all your *ListForms from UserControl instead of Form. You can still use the forms designer with a UserControl. I don't think you will lose much, if any, functionality that you need, but you may have more flexibility for reusing the *ListForms and for hosting them in any type of control or form. I've also been wondering about the best approach for something like this, so I would like to pose a general question to the group. To create the type of "Outlook" UI Ricky asks about, is it better to use Forms or Controls (such as UserControl)? Which has more flexibility? Which is easier for RAD UI development? Which has more support and is more widely used? Which is easier for integrating menus, toolbars, etc.? In my case, I have two choices. I could use either a tabbed MDI host (like in VS.NET) with multiple forms, or I could use various host controls (including tab controls, etc.) to display my own UserControl-derived objects. Any comments are appreciated. Dave

    .NET (Core and Framework) design question

  • Writing Faster Managed Code
    M MtnBiknGuy

    Jan Gray of the Microsoft CLR Performance Team wrote an excellent article titled "Writing Faster Managed Code: Know What Things Cost" (http://msdn.microsoft.com/library/?url=/library/en-us/dndotnet/html/fastmanagedcode.asp). This article has motivated me to seek answers to the following questions. Any replies from the group are appreciated. The questions probably (hopefully) have very simple answers. Between these two foreach loops, is there any difference in performance, safety or correctness? (All examples are in C#) 1. declare and initialize new type in body of loop: foreach (T t in tList) { A a = new A(t.ID); //do more work myCollection.Add(a); } 2. declare new type outside loop, and 'new' it inside loop: A a = null; foreach (T t in tList) { a = new A(t.ID); //do more work myCollection.Add(a); } I would think #2 is preferrable, but I see that most C# examples use the style of #1. In fact, I often see the following in C# examples: T MyMethod() { T t = new T(); return t; } This would be a big problem in C++, but in C# the garbage collector makes it OK. But does that mean it's a good practice? Why is it so common in examples? Finally, I'm curious if there are any performance differences between the following two loops. The reason I ask is that I'm one of those people who (prior to reading the above mentioned article) pulled the array.Length property out of the loop header in the interest of avoiding extra calls to get the length value. I now understand why that is not optimal. I'm curious if any processor optimizations or compiler optimizations make choice 1 equal to or better than choice 2 below: 1. repeat same property calls inside a loop: for (int i = 0; i < 10; ++i) { DoAlgorithm1(i, T.x); DoAlgorithm2(i, T.x + y); DoAlgorithm3(i, T.x + y); } 2. pull property calls outside the loop: double x = T.x; double w = x + y; for (int i = 0; i < 10; ++i) { DoAlgorithm1(i, x); DoAlgorithm2(i, w); DoAlgorithm3(i, w); } All input is appreciated!

    C# csharp c++ html dotnet com
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups