• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 10:57
CET 16:57
KST 00:57
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation6Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Master Swan Open (Global Bronze-Master 2) Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
BW General Discussion FlaSh on: Biggest Problem With SnOw's Playstyle Terran 1:35 12 Gas Optimization BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
EVE Corporation Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1246 users

The Big Programming Thread - Page 10

Forum Index > General Forum
Post a Reply
Prev 1 8 9 10 11 12 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 12 2010 15:27 GMT
#181
Oh, the code I showed wasn't supposed to be C#, just how I'd do it in C/++. I thought about this;

foreach (int i in arrayA)
{
foreach (int ii in arrayB)
{
if (i == ii)
return true;
}
}

But it would seem natural for i and ii to be the indexes rather than the values. Maybe I'm too used to references in C++. arrayA[i] would make more sense, y'know?

About this:
return arrayA.Intersect(arrayB).Count()>0

You're saying I can't Console.WriteLine(function()) if function returns the above code? The result has to be stored in a buffer first, is that what you mean by "doesn't support early out"?
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2010-07-12 15:33:58
July 12 2010 15:29 GMT
#182
On July 13 2010 00:00 Adeny wrote:
However in C# I'm sitting on two arraylists (whatever the hell that is)]



An ArrayList is a list which uses a backing array (as opposed to a non-array backed list, such as a linked list). There are many types of list which have the same functionality but are handled it in a completely different way. All lists are self expanding, they can be iterated through, and their indexes manually accessed and modified, much like an array.

In OOP you should always try to hide as much information as possible (use encapsulation), in order to reduce side-effects, de-couple and simplify your code. With the case of the ArrayList, when you instantiate an ArrayList, you should use a List variable (as MasterOfChaos said). You can do this by type-casting (down casts such as ArrayList->List are automatic), it part of a principle of OOP called polymorphism.

This means other programmers won't know whether it is a LinkedList or an ArrayList, which means he/she can't make assumptions on its functionality. This is good because it means you can switch from a LinkedList to an ArrayList without any problems if you need to later on.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 12 2010 15:51 GMT
#183
See how confusing that is? Think I got it though, checking out LINQ and it's some really funky stuff.
var lowNums =
from n in numbers
where n < 5
select n;

SQL-syntax for C#...
SchAmToo
Profile Blog Joined April 2010
United States1141 Posts
July 12 2010 15:57 GMT
#184
So, I figured I would share.

VBA Excel Macro coding...is the devil.
twitch.tv/schamtoo | twitter.com/schamtoo
Epsilon8
Profile Blog Joined May 2010
Canada173 Posts
Last Edited: 2010-07-12 16:34:07
July 12 2010 16:30 GMT
#185
On July 13 2010 00:00 Adeny wrote:
C# question time!
in C++ i would do this: if (a[i] == b[ii]). However in C# I'm sitting on two arraylists (whatever the hell that is), and I want to loop through both of them the way you'd solved one of the bike-locks with codes... 001, 002, 003 etc. which I'd usually do by nesting for loops, i < 9, ii < 9 and so on... I don't know if I'm making any sense. Let's try again, what I'm looking for is a replacement to this, but with arraylists;

for (int i = 0; i < 9; i++)
{
for (int ii = 0; ii < 9; ii++)
{
if (arrayA[i] == arrayB[ii])
return true;
}
}



List<int> list1 = new List<int>();
List<int> list2 = new List<int>();

//add whatever you want to lists i.e. list1.add(3)

foreach (int i in list1) {

foreach (int y in list2) {

if (i == y) {
return true;
}
}

}

I hope this helps! : )
This might help as well : http://msdn.microsoft.com/en-us/library/d9hw1as6.aspx
If you wish to travel far and fast, travel light. Take off all your envies, jealousies, unforgiveness, selfishness, and fears.
Epsilon8
Profile Blog Joined May 2010
Canada173 Posts
July 12 2010 16:36 GMT
#186
+ Show Spoiler +
On July 13 2010 00:27 Adeny wrote:
Oh, the code I showed wasn't supposed to be C#, just how I'd do it in C/++. I thought about this;

foreach (int i in arrayA)
{
foreach (int ii in arrayB)
{
if (i == ii)
return true;
}
}

But it would seem natural for i and ii to be the indexes rather than the values. Maybe I'm too used to references in C++. arrayA[i] would make more sense, y'know?

About this:
return arrayA.Intersect(arrayB).Count()>0

You're saying I can't Console.WriteLine(function()) if function returns the above code? The result has to be stored in a buffer first, is that what you mean by "doesn't support early out"?



I didn't see this post until after I was done writing it : P.
If you wish to travel far and fast, travel light. Take off all your envies, jealousies, unforgiveness, selfishness, and fears.
Epsilon8
Profile Blog Joined May 2010
Canada173 Posts
Last Edited: 2010-07-12 16:52:15
July 12 2010 16:37 GMT
#187
On July 13 2010 00:57 Schamus wrote:
So, I figured I would share.

VBA Excel Macro coding...is the devil.


I completely agree. This is actually what I do for my day job at the moment. VBA macros and user forms for excel. If I had a choice I would be using .NET but alas my company does not have the funds.
If you wish to travel far and fast, travel light. Take off all your envies, jealousies, unforgiveness, selfishness, and fears.
TanGeng
Profile Blog Joined January 2009
Sanya12364 Posts
July 12 2010 16:54 GMT
#188
On July 13 2010 00:27 Adeny wrote:
Oh, the code I showed wasn't supposed to be C#, just how I'd do it in C/++. I thought about this;

foreach (int i in arrayA)
{
foreach (int ii in arrayB)
{
if (i == ii)
return true;
}
}

But it would seem natural for i and ii to be the indexes rather than the values. Maybe I'm too used to references in C++. arrayA[i] would make more sense, y'know?

About this:
return arrayA.Intersect(arrayB).Count()>0

You're saying I can't Console.WriteLine(function()) if function returns the above code? The result has to be stored in a buffer first, is that what you mean by "doesn't support early out"?


An "early out" is a fast termination sequence without having to brute force through the entire for loop (worst case). When you don't have an "early out" you completely go through your loops.

In your code, the worst case is when you have no matches - the code goes through both for loops completely. The best cases is when the first member of A matches the first member of B - it only looks at one comparison before terminating with an answer.

Moderator我们是个踏实的赞助商模式俱乐部
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
Last Edited: 2010-07-14 19:08:57
July 12 2010 17:11 GMT
#189
On July 13 2010 00:29 sluggaslamoo wrote:
Show nested quote +
On July 13 2010 00:00 Adeny wrote:
However in C# I'm sitting on two arraylists (whatever the hell that is)]



An ArrayList is a list which uses a backing array (as opposed to a non-array backed list, such as a linked list). There are many types of list which have the same functionality but are handled it in a completely different way. All lists are self expanding, they can be iterated through, and their indexes manually accessed and modified, much like an array.

In OOP you should always try to hide as much information as possible (use encapsulation), in order to reduce side-effects, de-couple and simplify your code. With the case of the ArrayList, when you instantiate an ArrayList, you should use a List variable (as MasterOfChaos said). You can do this by type-casting (down casts such as ArrayList->List are automatic), it part of a principle of OOP called polymorphism.

This means other programmers won't know whether it is a LinkedList or an ArrayList, which means he/she can't make assumptions on its functionality. This is good because it means you can switch from a LinkedList to an ArrayList without any problems if you need to later on.


Both ArrayList and List are backed by arrays, and neither derives from the other. The main difference is that List<T> is generic and ArrayList isn't. So List<object> is pretty much the same as ArrayList. IMO ArrayList is obsolete since .net 2.0.

You can hide information by using IList, ICollection or IEnumerable. But a typical linked list wouldn't implement IList either, since indexed access is O(n) for linked list.



And I there is an easy way to give my linq statement early out behavior:
return arrayA.Intersect(arrayB).Take(1).Count()>0

It probably evaluates one of the sides, puts it in a hashtable and then lazily evaluates the other side. So the average case runtime is something like O(arrayA.Count+arrayB.Count) provided the hashes are evenly distributed. Your code on the other hand is O(arrayA.Count*arrayB.Count), which is much slower for large lists.

edit: changed Limit to Take, I always mix that up
LiquipediaOne eye to kill. Two eyes to live.
Catch]22
Profile Blog Joined July 2009
Sweden2683 Posts
July 12 2010 17:18 GMT
#190
On July 13 2010 02:11 MasterOfChaos wrote:
Show nested quote +
On July 13 2010 00:29 sluggaslamoo wrote:
On July 13 2010 00:00 Adeny wrote:
However in C# I'm sitting on two arraylists (whatever the hell that is)]



An ArrayList is a list which uses a backing array (as opposed to a non-array backed list, such as a linked list). There are many types of list which have the same functionality but are handled it in a completely different way. All lists are self expanding, they can be iterated through, and their indexes manually accessed and modified, much like an array.

In OOP you should always try to hide as much information as possible (use encapsulation), in order to reduce side-effects, de-couple and simplify your code. With the case of the ArrayList, when you instantiate an ArrayList, you should use a List variable (as MasterOfChaos said). You can do this by type-casting (down casts such as ArrayList->List are automatic), it part of a principle of OOP called polymorphism.

This means other programmers won't know whether it is a LinkedList or an ArrayList, which means he/she can't make assumptions on its functionality. This is good because it means you can switch from a LinkedList to an ArrayList without any problems if you need to later on.


Both ArrayList and List are backed by arrays, and neither derives from the other. The main difference is that List<T> is generic and ArrayList isn't. So List<object> is pretty much the same as ArrayList. IMO ArrayList is obsolete since .net 2.0.

You can hide information by using IList, ICollection or IEnumerable. But a typical linked list wouldn't implement IList either, since indexed access is O(n) for linked list.



And I there is an easy way to give my linq statement early out behavior:
return arrayA.Intersect(arrayB).Limit(1).Count()>0

It probably evaluates one of the sides, puts it in a hashtable and then lazily evaluates the other side. So the average case runtime is something like O(arrayA.Count+arrayB.Count) provided the hashes are evenly distributed. Your code on the other hand is O(arrayA.Count*arrayB.Count), which is much slower for large lists.


Lists in Java and C# arent backed by arrays, they are objects with references to the next object.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 12 2010 17:21 GMT
#191
On July 13 2010 01:54 TanGeng wrote:
Show nested quote +
On July 13 2010 00:27 Adeny wrote:
Oh, the code I showed wasn't supposed to be C#, just how I'd do it in C/++. I thought about this;

foreach (int i in arrayA)
{
foreach (int ii in arrayB)
{
if (i == ii)
return true;
}
}

But it would seem natural for i and ii to be the indexes rather than the values. Maybe I'm too used to references in C++. arrayA[i] would make more sense, y'know?

About this:
return arrayA.Intersect(arrayB).Count()>0

You're saying I can't Console.WriteLine(function()) if function returns the above code? The result has to be stored in a buffer first, is that what you mean by "doesn't support early out"?


An "early out" is a fast termination sequence without having to brute force through the entire for loop (worst case). When you don't have an "early out" you completely go through your loops.

In your code, the worst case is when you have no matches - the code goes through both for loops completely. The best cases is when the first member of A matches the first member of B - it only looks at one comparison before terminating with an answer.


Gotcha, thanks for the explanation.
AssuredVacancy
Profile Blog Joined September 2008
United States1167 Posts
July 12 2010 18:22 GMT
#192
On July 13 2010 02:18 Catch]22 wrote:
Show nested quote +
On July 13 2010 02:11 MasterOfChaos wrote:
On July 13 2010 00:29 sluggaslamoo wrote:
On July 13 2010 00:00 Adeny wrote:
However in C# I'm sitting on two arraylists (whatever the hell that is)]



An ArrayList is a list which uses a backing array (as opposed to a non-array backed list, such as a linked list). There are many types of list which have the same functionality but are handled it in a completely different way. All lists are self expanding, they can be iterated through, and their indexes manually accessed and modified, much like an array.

In OOP you should always try to hide as much information as possible (use encapsulation), in order to reduce side-effects, de-couple and simplify your code. With the case of the ArrayList, when you instantiate an ArrayList, you should use a List variable (as MasterOfChaos said). You can do this by type-casting (down casts such as ArrayList->List are automatic), it part of a principle of OOP called polymorphism.

This means other programmers won't know whether it is a LinkedList or an ArrayList, which means he/she can't make assumptions on its functionality. This is good because it means you can switch from a LinkedList to an ArrayList without any problems if you need to later on.


Both ArrayList and List are backed by arrays, and neither derives from the other. The main difference is that List<T> is generic and ArrayList isn't. So List<object> is pretty much the same as ArrayList. IMO ArrayList is obsolete since .net 2.0.

You can hide information by using IList, ICollection or IEnumerable. But a typical linked list wouldn't implement IList either, since indexed access is O(n) for linked list.



And I there is an easy way to give my linq statement early out behavior:
return arrayA.Intersect(arrayB).Limit(1).Count()>0

It probably evaluates one of the sides, puts it in a hashtable and then lazily evaluates the other side. So the average case runtime is something like O(arrayA.Count+arrayB.Count) provided the hashes are evenly distributed. Your code on the other hand is O(arrayA.Count*arrayB.Count), which is much slower for large lists.


Lists in Java and C# arent backed by arrays, they are objects with references to the next object.


In java a List is simply an interface. You cannot instantiate a List.
We spend our youth attaining wealth, and our wealth attaining youth.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
Last Edited: 2010-07-12 18:33:56
July 12 2010 18:26 GMT
#193
Finished Project Euler's 23, but it's slow as ASS. http://pastie.org/1041271 . Ran for hours, anyone have a suggestion for a better algorithm?

Edit: Left an extra arraylist in there from a previous attempt.
Edit2: Took that out, re-ran it because why not... It's a lot faster now, what? It was only a declaration.
Edit3: Maybe I'm just an idiot, I had a lot of programs running earlier...
tec27
Profile Blog Joined June 2004
United States3702 Posts
July 12 2010 18:44 GMT
#194
On July 13 2010 02:18 Catch]22 wrote:
Show nested quote +
On July 13 2010 02:11 MasterOfChaos wrote:
On July 13 2010 00:29 sluggaslamoo wrote:
On July 13 2010 00:00 Adeny wrote:
However in C# I'm sitting on two arraylists (whatever the hell that is)]



An ArrayList is a list which uses a backing array (as opposed to a non-array backed list, such as a linked list). There are many types of list which have the same functionality but are handled it in a completely different way. All lists are self expanding, they can be iterated through, and their indexes manually accessed and modified, much like an array.

In OOP you should always try to hide as much information as possible (use encapsulation), in order to reduce side-effects, de-couple and simplify your code. With the case of the ArrayList, when you instantiate an ArrayList, you should use a List variable (as MasterOfChaos said). You can do this by type-casting (down casts such as ArrayList->List are automatic), it part of a principle of OOP called polymorphism.

This means other programmers won't know whether it is a LinkedList or an ArrayList, which means he/she can't make assumptions on its functionality. This is good because it means you can switch from a LinkedList to an ArrayList without any problems if you need to later on.


Both ArrayList and List are backed by arrays, and neither derives from the other. The main difference is that List<T> is generic and ArrayList isn't. So List<object> is pretty much the same as ArrayList. IMO ArrayList is obsolete since .net 2.0.

You can hide information by using IList, ICollection or IEnumerable. But a typical linked list wouldn't implement IList either, since indexed access is O(n) for linked list.



And I there is an easy way to give my linq statement early out behavior:
return arrayA.Intersect(arrayB).Limit(1).Count()>0

It probably evaluates one of the sides, puts it in a hashtable and then lazily evaluates the other side. So the average case runtime is something like O(arrayA.Count+arrayB.Count) provided the hashes are evenly distributed. Your code on the other hand is O(arrayA.Count*arrayB.Count), which is much slower for large lists.


Lists in Java and C# arent backed by arrays, they are objects with references to the next object.


You're wrong.

http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/util/ArrayList.html
Resizable-array implementation of the List interface.

http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
The List(Of T) class is the generic equivalent of the ArrayList class. It implements the IList(Of T) generic interface using an array whose size is dynamically increased as required.


Please actually know this stuff before stating it as fact, it makes things a lot less confusing for newcomers.

Can you jam with the console cowboys in cyberspace?
catamorphist
Profile Joined May 2010
United States297 Posts
Last Edited: 2010-07-12 19:15:38
July 12 2010 19:11 GMT
#195
whoa, stuff happening itt

The most idiomatic C# way to write that is this (for the naive n*m algorithm):

return arrayA.Any(x => arrayB.Contains(x));


Or for the intersection method, which as surmised does put one list into a hashtable first:

return arrayA.Intersect(arrayB).Any(); // .Any() short-circuits, unlike Count()


I don't know where the above poster pulled the Enumerable.Limit() function out from; it's not a framework function.

Project Euler guy: Your function for grabbing divisors is unnecessarily slow. You only need to search up to sqrt(n) for potential divisors, not all the way up to N -- when you pick up on a divisor you can automatically add the corresponding divisor that multiplies with it to N. That's the easiest way to improve it significantly. I don't remember what that problem actually is, but I'll check it out after work and see if I can think of anything else -- the PE problems often admit clever mathematical solutions. (Although I do know there's no known fast method to enumerate all perfect/deficient/abundant numbers in general.)
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 12 2010 19:21 GMT
#196
Some of the other solutions on project euler inspired me, I think I'll re-do it completely for an acceptable completion time.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2010-07-13 03:53:55
July 13 2010 03:47 GMT
#197
On July 13 2010 02:11 MasterOfChaos wrote:
Show nested quote +
On July 13 2010 00:29 sluggaslamoo wrote:
On July 13 2010 00:00 Adeny wrote:
However in C# I'm sitting on two arraylists (whatever the hell that is)]



An ArrayList is a list which uses a backing array (as opposed to a non-array backed list, such as a linked list). There are many types of list which have the same functionality but are handled it in a completely different way. All lists are self expanding, they can be iterated through, and their indexes manually accessed and modified, much like an array.

In OOP you should always try to hide as much information as possible (use encapsulation), in order to reduce side-effects, de-couple and simplify your code. With the case of the ArrayList, when you instantiate an ArrayList, you should use a List variable (as MasterOfChaos said). You can do this by type-casting (down casts such as ArrayList->List are automatic), it part of a principle of OOP called polymorphism.

This means other programmers won't know whether it is a LinkedList or an ArrayList, which means he/she can't make assumptions on its functionality. This is good because it means you can switch from a LinkedList to an ArrayList without any problems if you need to later on.


Both ArrayList and List are backed by arrays, and neither derives from the other. The main difference is that List<T> is generic and ArrayList isn't. So List<object> is pretty much the same as ArrayList. IMO ArrayList is obsolete since .net 2.0.

You can hide information by using IList, ICollection or IEnumerable. But a typical linked list wouldn't implement IList either, since indexed access is O(n) for linked list.



And I there is an easy way to give my linq statement early out behavior:
return arrayA.Intersect(arrayB).Limit(1).Count()>0

It probably evaluates one of the sides, puts it in a hashtable and then lazily evaluates the other side. So the average case runtime is something like O(arrayA.Count+arrayB.Count) provided the hashes are evenly distributed. Your code on the other hand is O(arrayA.Count*arrayB.Count), which is much slower for large lists.


Sorry for some reason I was thinking about Java. In Java, List is IList, and ArrayList is List.

Another thing I often forget with C# is that LinkedList implements IList in Java and not in C#. My biggest gripe with C# is it doesn't slavishly follow OO principles, LinkedList should really implement IList. It does implement ICollection but ICollection doesn't have the functionality to required to be useful in most situations, where as IList does.

Not using the interface allows programmers to make assumptions about the List object, and end up making code maintenance harder (or impossible) in the long-run. In OO you should always access interfaces, rather than concrete classes. It is up to the original programmer to decide whether the List should be optimised for indexing or expanding. Everyone else should just view it as a list and not refer Big O to decide how the List is going to be used (the goal of OOP is easier code maintenance, not performance ). This way if the business rules change, and indexing becomes more crucial (and for example you make a more optimised concrete list class), you could switch the concrete class without any problems.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
catamorphist
Profile Joined May 2010
United States297 Posts
Last Edited: 2010-07-13 03:57:28
July 13 2010 03:56 GMT
#198
I see your point of view, but I have to disagree. I think that a valuable piece of information communicated by your return type (or your parameter type) is what "kind" of thing you are returning, in a general sense. If I am returning an IList, which implements an indexer, that really implies that the indexer is going to be constant time, because that's the example set by all the other IList implementations. Similarly, if you have an ISet, you expect Contains to be at least better than linear. I don't think there's anything wrong with having conventions like that, and it helps communicate things that you would have to put in a comment otherwise.
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
Hidden_MotiveS
Profile Blog Joined February 2010
Canada2562 Posts
Last Edited: 2010-07-13 03:58:38
July 13 2010 03:57 GMT
#199
nvm
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2010-07-13 04:35:04
July 13 2010 04:34 GMT
#200
On July 13 2010 12:56 catamorphist wrote:
I see your point of view, but I have to disagree. I think that a valuable piece of information communicated by your return type (or your parameter type) is what "kind" of thing you are returning, in a general sense. If I am returning an IList, which implements an indexer, that really implies that the indexer is going to be constant time, because that's the example set by all the other IList implementations. Similarly, if you have an ISet, you expect Contains to be at least better than linear. I don't think there's anything wrong with having conventions like that, and it helps communicate things that you would have to put in a comment otherwise.


But again you are making assumptions about List when you should be looking at it at face value. The "kind" of thing being returned is a List. Programmers shouldn't have to look at the code of every type of List class to find a pattern and then derive its usage based on that, it just over-complicates programming. A List is simply a list, you look at the methods of list, which tells you what it can do, that is all you need to know. If you start thinking in this manner, programming becomes much much simpler. One principle of OOP is encapsulation, part of of this principle involves encapsulating code.

Design patterns often (if not always) use this method (a simple example is the factory pattern), it is not just my opinion, it is a best practice. The problem may be that I am using Lists as an example, where the results are clearly obvious from research on data-structures. What happens though, when you are programming for a company that has its own libraries?

Wouldn't I be a much more efficient programmer if I could just look at the interface to find out how to use it, rather than looking at every concrete class its based on and have to figure out which one is the best, and how to best use it?
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Prev 1 8 9 10 11 12 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
11:30
Mid Season Playoffs
Krystianer vs PercivalLIVE!
WardiTV1125
TKL 235
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 235
SteadfastSC 94
Rex 85
StarCraft: Brood War
Calm 3285
Rain 2279
Bisu 1720
Hyuk 1637
Horang2 920
Soma 531
Stork 334
Rush 299
Shuttle 188
Backho 101
[ Show more ]
Soulkey 79
sas.Sziky 53
Barracks 53
hero 39
Rock 35
zelot 23
sSak 23
Aegong 19
Killer 16
Terrorterran 11
Dota 2
Gorgc3723
qojqva1869
Dendi1212
BananaSlamJamma147
XcaliburYe101
Super Smash Bros
Mew2King91
Other Games
DeMusliM434
hiko380
Sick378
Hui .313
Fuzer 203
QueenE52
ceh949
Trikslyr13
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 11
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• poizon28 11
• 3DClanTV 6
• LaughNgamezSOOP
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• HerbMon 11
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 3073
• WagamamaTV442
League of Legends
• Nemesis4286
• TFBlade1021
Upcoming Events
Tenacious Turtle Tussle
7h 3m
The PondCast
18h 3m
RSL Revival
18h 3m
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
20h 3m
WardiTV Korean Royale
20h 3m
PiGosaur Monday
1d 9h
RSL Revival
1d 18h
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
1d 20h
CranKy Ducklings
2 days
RSL Revival
2 days
herO vs Gerald
ByuN vs SHIN
[ Show More ]
Kung Fu Cup
2 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
3 days
RSL Revival
3 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
3 days
WardiTV Korean Royale
3 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
4 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.