![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Usage of Array in C#.NET I have a colleague who used to program in S-PLUS. My impression about S-PLUS is that it's based on matrix calculations and consumes a lot of memory. It takes a long time to run a small program in S-PLUS. Now he wants to learn C# in order to speed things up. He simply uses Array in C#.NET (to resemble matrix in S-PLUS). He refers to everything in the Array by indexes, i.e., integer numbers. It seems fairly abstract. I asked him to use objects and ArrayList. He is not used to the concept of object-oriented programming. So he sticks to the Array with those indexes. Each time when he asks me to help debug, it's a headache because I have to remember the indexes that reference to different things. All meaningless numbers pointed to by indexes. A question for you folks: Is it a good idea to use Array? Wouldn't it be better to use ArrayList instead? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Usage of Array in C#.NET I must say, I know nothing about S-Plus, and you don't really say what he's storing in these arrays. If he's just storing ints then why not use int[]? or at least List<int>? Quote: > He refers to everything in the Array by indexes, i.e., integer numbers. Why do you think using an int to index into the array is wrong? Cheers, Adam. "Curious" <fir5tsight@xxxxxx> wrote in message news:a5676adb-3ea9-489a-8e43-ceb58407975e@xxxxxx Quote: >I have a colleague who used to program in S-PLUS. My impression about > S-PLUS is that it's based on matrix calculations and consumes a lot of > memory. It takes a long time to run a small program in S-PLUS. > > Now he wants to learn C# in order to speed things up. He simply uses > Array in C#.NET (to resemble matrix in S-PLUS). He refers to > everything in the Array by indexes, i.e., integer numbers. It seems > fairly abstract. > > I asked him to use objects and ArrayList. He is not used to the > concept of object-oriented programming. So he sticks to the Array with > those indexes. Each time when he asks me to help debug, it's a > headache because I have to remember the indexes that reference to > different things. All meaningless numbers pointed to by indexes. > > A question for you folks: Is it a good idea to use Array? Wouldn't it > be better to use ArrayList instead? > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Usage of Array in C#.NET "Curious" <fir5tsight@xxxxxx> wrote in message news:a5676adb-3ea9-489a-8e43-ceb58407975e@xxxxxx Quote: >I have a colleague who used to program in S-PLUS. My impression about > S-PLUS is that it's based on matrix calculations and consumes a lot of > memory. It takes a long time to run a small program in S-PLUS. > > Now he wants to learn C# in order to speed things up. He simply uses > Array in C#.NET (to resemble matrix in S-PLUS). He refers to > everything in the Array by indexes, i.e., integer numbers. It seems > fairly abstract. > > I asked him to use objects and ArrayList. He is not used to the > concept of object-oriented programming. So he sticks to the Array with > those indexes. Each time when he asks me to help debug, it's a > headache because I have to remember the indexes that reference to > different things. All meaningless numbers pointed to by indexes. > > A question for you folks: Is it a good idea to use Array? Wouldn't it > be better to use ArrayList instead? > typically the highest-performance way to do it, In general, this is a case where object-oriented approaches just don't work out in practice because of the inevitable overhead (please, no uninformed flames from the gallery on this - it's well known to be true). So if you're going to do his debugging for him, get comfortable with multidimensional arrays. One thing you can do is ask him to rename the index variables so that it's a little easier to visualize what the dimensions mean. However, indexed arrays are NOT necessarily the high-performance solution to all problems he may be solving. There are places where the CLR types are appropriate - for instance dictionaries for lookups, where the underlying hashtable will beat a binary search on an array of keys. It's not a certainty, by the way, that using C# will speed things up. There's a good reason why Fortran, for instance, is still used heavily by people who do compute-intensive math for a living. The optimizing performance of Fortran compilers is legendary. Good luck, Tom Dacon |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Usage of Array in C#.NET It's a financial application to read price and volume information for a period of time for each security on the stock market from a huge file. Then based on the changes in price or volume during the recent days, come up with a selection of securities. I've created a program with a Security class, and ArrayList containing a collection of Security instances. I've also created a method in the Security class to do the calculation. Then I use Sort to sort the ArrayList to come up with a list. It's fast, and straight-forward. I still fail to understand why he doesn't accept the concept of object- oriented programming. Yes, he uses a lot of int[], double[], string[], etc. You have to go to different Arrays to get different values for a same security. They are not together. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Usage of Array in C#.NET "Curious" <fir5tsight@xxxxxx> wrote in message news:628d40d7-76c3-41f6-a7fd-d5d0660cfd9f@xxxxxx Quote: > It's a financial application to read price and volume information for > a period of time for each security on the stock market from a huge > file. > > Then based on the changes in price or volume during the recent days, > come up with a selection of securities. > > I've created a program with a Security class, and ArrayList containing > a collection of Security instances. I've also created a method in the > Security class to do the calculation. Then I use Sort to sort the > ArrayList to come up with a list. It's fast, and straight-forward. > > I still fail to understand why he doesn't accept the concept of object- > oriented programming. > > Yes, he uses a lot of int[], double[], string[], etc. You have to go > to different Arrays to get different values for a same security. They > are not together. are. If your object-oriented solution doesn't impose a significant penalty (that is, your solution lies comfortably within the performance requirements of the problem), then you've got a good case for using the CLR classes in favor of his solution. Maintainability and understandability count for a lot, as long as you haven't put a bullet in the head of the application because of unacceptable performance. Tom Dacon Dacon Software Consulting |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Usage of Array in C#.NET In article <628d40d7-76c3-41f6-a7fd- d5d0660cfd9f@xxxxxx>, fir5tsight@xxxxxx says...> Quote: > I still fail to understand why he doesn't accept the concept of Quote: > oriented programming. ![]() -- de gustibus disputandum esse |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Usage of Array in C#.NET Curious wrote: Quote: > > I still fail to understand why he doesn't accept the concept of object- > oriented programming. > abandon S-PLUS. Until you show them why abandoning it 1) gives the same answers, and 2) gets those answers faster, or more optimally, you've got a hard sell. Look at another point of view. They probably feel that their routine in S-PLUS will not only solve your type of problem, but because the matrices are generic, could also solve other problems. Your OO methods and app are domain specific. -- Mike |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Usage of Array in C#.NET Curious He should look at all the implementations of the Collection Generic namespace not the arraylist. http://msdn.microsoft.com/en-us/libr...ic(VS.80).aspx Then he can simple make classes and make all his calculation with that. Be aware that straight arrays, which are immutable can be the fastest as long as they don't change after instancing. Cor "Curious" <fir5tsight@xxxxxx> wrote in message news:a5676adb-3ea9-489a-8e43-ceb58407975e@xxxxxx Quote: >I have a colleague who used to program in S-PLUS. My impression about > S-PLUS is that it's based on matrix calculations and consumes a lot of > memory. It takes a long time to run a small program in S-PLUS. > > Now he wants to learn C# in order to speed things up. He simply uses > Array in C#.NET (to resemble matrix in S-PLUS). He refers to > everything in the Array by indexes, i.e., integer numbers. It seems > fairly abstract. > > I asked him to use objects and ArrayList. He is not used to the > concept of object-oriented programming. So he sticks to the Array with > those indexes. Each time when he asks me to help debug, it's a > headache because I have to remember the indexes that reference to > different things. All meaningless numbers pointed to by indexes. > > A question for you folks: Is it a good idea to use Array? Wouldn't it > be better to use ArrayList instead? > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Fast copy method of sub array (=array range) possible? | VB Script | |||
| How to create array without quotes? $array = (a,b,c) | PowerShell | |||
| Array indexing: Want to say "Item #2 through the rest of the array." | PowerShell | |||
| Stupid Array Tricks: Initializing an Array to a Certain Size | PowerShell | |||
| how to assign values to array and how to create array via variable | PowerShell | |||