• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:06
CEST 16:06
KST 23:06
  • 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
Team Liquid Map Contest #22 - The Finalists14[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21
Community News
2026 GSL Season 1 Qualifiers11Maestros of the Game 2 announced32026 GSL Tour plans announced11Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid22
StarCraft 2
General
MaNa leaves Team Liquid 2026 GSL Tour plans announced Team Liquid Map Contest #22 - The Finalists Weekly Cups (April 6-12): herO doubles, "Villains" prevail Oliveira Would Have Returned If EWC Continued
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament GSL CK: More events planned pending crowdfunding 2026 GSL Season 1 Qualifiers Master Swan Open (Global Bronze-Master 2) SEL Doubles (SC Evo Bimonthly)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Gypsy to Korea Pros React To: Tulbo in Ro.16 Group A Data needed
Tourneys
Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro16 Group A [ASL21] Ro16 Group B
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion Cricket [SPORT]
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Reappraising The Situation T…
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1681 users

The Big Programming Thread - Page 720

Forum Index > General Forum
Post a Reply
Prev 1 718 719 720 721 722 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.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 18 2016 07:53 GMT
#14381
On April 18 2016 05:32 waffelz wrote:
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.


That's why I don't have any faith in people that became programmers in university.

Too many people get through it without being able to actually program properly. We currently have two students working as programmers in our company, and one of them is meh, the other would write pretty much the same code as your student and wonder why it doesn't work. Sometimes it takes more work to clean up their mess of 300 line methods and huge classes than to actually write it from scratch myself.

One one hand it's of course a recruiting fail to even employ such a student, on the other you'd expect someone studying to become a programmer to at least know the basics of programming.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 18 2016 17:12 GMT
#14382
On April 18 2016 16:53 Morfildur wrote:
Show nested quote +
On April 18 2016 05:32 waffelz wrote:
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.


That's why I don't have any faith in people that became programmers in university.

Too many people get through it without being able to actually program properly. We currently have two students working as programmers in our company, and one of them is meh, the other would write pretty much the same code as your student and wonder why it doesn't work. Sometimes it takes more work to clean up their mess of 300 line methods and huge classes than to actually write it from scratch myself.

One one hand it's of course a recruiting fail to even employ such a student, on the other you'd expect someone studying to become a programmer to at least know the basics of programming.

I learnt programming while I was at university, but university sure didn't help a lot with that. The basic math courses are fine (because you learn logic and proof concepts). But the CompSci courses... I can't remember anything worthwhile from those.
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18265 Posts
Last Edited: 2016-04-18 17:50:28
April 18 2016 17:49 GMT
#14383
On April 19 2016 02:12 spinesheath wrote:
Show nested quote +
On April 18 2016 16:53 Morfildur wrote:
On April 18 2016 05:32 waffelz wrote:
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.


That's why I don't have any faith in people that became programmers in university.

Too many people get through it without being able to actually program properly. We currently have two students working as programmers in our company, and one of them is meh, the other would write pretty much the same code as your student and wonder why it doesn't work. Sometimes it takes more work to clean up their mess of 300 line methods and huge classes than to actually write it from scratch myself.

One one hand it's of course a recruiting fail to even employ such a student, on the other you'd expect someone studying to become a programmer to at least know the basics of programming.

I learnt programming while I was at university, but university sure didn't help a lot with that. The basic math courses are fine (because you learn logic and proof concepts). But the CompSci courses... I can't remember anything worthwhile from those.


Algorithms and Data Structures are fairly useful. Other than that, maybe the course on OOMP and Design Patterns was decent. I guess the course on functional programming was probably useful, because it really hammered in how to use recursion (although learning how to build your own parser, and compiler, taught that lesson quite thoroughly too). But most of the CS 101 are things I either knew already (programming) or you look up when you need it (courses on network architectures, databases).

I tend to agree that a university (BSc) degree says very little other than that the prospective employee passes a minimum level of intelligence and persistency. I can attest to the fact that you don't actually need to program at all to get a BSc. with a major in CS. I helped plenty of people in group assignments (who had already passed all the 101 programming courses) who couldn't code to save their lives. On the other hand, I am perfectly happy to admit that some of my friends were infinitely better coders than I was, easily navigating complex C libraries to deal with distributing our code across dozens of cores in a supercomputer (probably one of the hardest programming assignments I did in uni... ironically, it was a math course, and not a CS one).
Manit0u
Profile Blog Joined August 2004
Poland17727 Posts
April 18 2016 20:59 GMT
#14384
On April 19 2016 02:49 Acrofales wrote:
Show nested quote +
On April 19 2016 02:12 spinesheath wrote:
On April 18 2016 16:53 Morfildur wrote:
On April 18 2016 05:32 waffelz wrote:
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.


That's why I don't have any faith in people that became programmers in university.

Too many people get through it without being able to actually program properly. We currently have two students working as programmers in our company, and one of them is meh, the other would write pretty much the same code as your student and wonder why it doesn't work. Sometimes it takes more work to clean up their mess of 300 line methods and huge classes than to actually write it from scratch myself.

One one hand it's of course a recruiting fail to even employ such a student, on the other you'd expect someone studying to become a programmer to at least know the basics of programming.

I learnt programming while I was at university, but university sure didn't help a lot with that. The basic math courses are fine (because you learn logic and proof concepts). But the CompSci courses... I can't remember anything worthwhile from those.


Algorithms and Data Structures are fairly useful. Other than that, maybe the course on OOMP and Design Patterns was decent. I guess the course on functional programming was probably useful, because it really hammered in how to use recursion (although learning how to build your own parser, and compiler, taught that lesson quite thoroughly too). But most of the CS 101 are things I either knew already (programming) or you look up when you need it (courses on network architectures, databases).

I tend to agree that a university (BSc) degree says very little other than that the prospective employee passes a minimum level of intelligence and persistency. I can attest to the fact that you don't actually need to program at all to get a BSc. with a major in CS. I helped plenty of people in group assignments (who had already passed all the 101 programming courses) who couldn't code to save their lives. On the other hand, I am perfectly happy to admit that some of my friends were infinitely better coders than I was, easily navigating complex C libraries to deal with distributing our code across dozens of cores in a supercomputer (probably one of the hardest programming assignments I did in uni... ironically, it was a math course, and not a CS one).


Math be hard man. Programming is something you don't have to learn at the uni (I have bachelor's in sociology for example and did 3 years of history + philosophy beforehand). All I can tell you is that philosophy is actually really good course for programming as it should teach you to think in abstracts (I guess that people who fail at that will also fail at programming). Logic is useful too.
Time is precious. Waste it wisely.
lilwisper
Profile Joined April 2010
United States2515 Posts
April 18 2016 21:05 GMT
#14385
On April 16 2016 18:44 Ropid wrote:

What I wonder is, are you sure you don't want just this here:

> echo "%USERPROFILE%\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"               
"C:\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"



This worked once I took the extra \ out at the end of my script. Thanks for the idea!
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2016-04-19 07:58:03
April 19 2016 07:47 GMT
#14386
Our university never really taught us "how" to program, just concepts and the best practices kind of stuff was left untouched unless it came up randomly. I'd love it if someone went through and reviewed code for you and told you why it's bad to do X, but you kinda just have to learn that for yourself through reading or fucking up tremendously to where your program won't work.

To my next point though... I'm working on a project which needs to store objects (bitmap images) in a list. This list gets shuffled and I need to know when this list is back in order again after various swaps. What I'm planning on doing is storing each bitmap in a map container with an integer key so <Integer, Bitmap> where the integer represents the index where the image should be in the list to be in correct order. I feel like I might be misusing the map container since I'm actually just storing a value pair rather than storing an object with a key so maybe there's a better data structure I could use. Is this how you guys would go about it?
Acrofales
Profile Joined August 2010
Spain18265 Posts
Last Edited: 2016-04-19 14:42:00
April 19 2016 12:10 GMT
#14387
On April 19 2016 16:47 Itsmedudeman wrote:
Our university never really taught us "how" to program, just concepts and the best practices kind of stuff was left untouched unless it came up randomly. I'd love it if someone went through and reviewed code for you and told you why it's bad to do X, but you kinda just have to learn that for yourself through reading or fucking up tremendously to where your program won't work.

To my next point though... I'm working on a project which needs to store objects (bitmap images) in a list. This list gets shuffled and I need to know when this list is back in order again after various swaps. What I'm planning on doing is storing each bitmap in a map container with an integer key so <Integer, Bitmap> where the integer represents the index where the image should be in the list to be in correct order. I feel like I might be misusing the map container since I'm actually just storing a value pair rather than storing an object with a key so maybe there's a better data structure I could use. Is this how you guys would go about it?

Depends. If given the key you want access to the bitmap, then yes. But it doesn't really sound like what you want. It sounds like you want a list of bitmaps that you can shuffle (can't shuffle dictionaries), and seperately, a way of recognizing when they're back in the original order. It's worth noting that if your list is large enough and the shuffle is random, this can take a very very very long time. I'd store them in an array (or a linked list, which makes shuffling a bit faster at the cost of retrieval, but this type of optimization can wait til you figure out what are the commonly used operations, and you can profile your app to see if it makes sense), with each object in the list being a tuple (original index, bitmap).

That said, you can easily do this with an array of the bitmaps and your dictionary idea too, but it makes insert and remove operations more costly (and prone to forgetting to maintain both datastructures, introducing bugs).
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2016-04-19 13:02:35
April 19 2016 13:00 GMT
#14388
On April 19 2016 21:10 Acrofales wrote:
Show nested quote +
On April 19 2016 16:47 Itsmedudeman wrote:
Our university never really taught us "how" to program, just concepts and the best practices kind of stuff was left untouched unless it came up randomly. I'd love it if someone went through and reviewed code for you and told you why it's bad to do X, but you kinda just have to learn that for yourself through reading or fucking up tremendously to where your program won't work.

To my next point though... I'm working on a project which needs to store objects (bitmap images) in a list. This list gets shuffled and I need to know when this list is back in order again after various swaps. What I'm planning on doing is storing each bitmap in a map container with an integer key so <Integer, Bitmap> where the integer represents the index where the image should be in the list to be in correct order. I feel like I might be misusing the map container since I'm actually just storing a value pair rather than storing an object with a key so maybe there's a better data structure I could use. Is this how you guys would go about it?

Depends. If given the key you want access to the bitmap, then yes. But it doesn't really sound like what you want. It sounds like you want a list of bitmaps that you can shuffle (can't shuffle dictionaries, and seperately, a way of recognizing when they're back in the original order. It's worth noting that if your list is large enough and the shuffle is random, this can take a very very very long time. I'd store them in an array (or a linked list, which makes shuffling a bit faster at the cost of retrieval, but this type of optimization can wait til you figure out what are the commonly used operations, and you can profile your app to see if it makes sense), with each object in the list being a tuple (original index, bitmap).

That said, you can easily do this with an array of the bitmaps and your dictionary idea too, but it makes insert and remove operations more costly (and prone to forgetting to maintain both datastructures, introducing bugs).

I actually misused the word Map to mean an entry of Map, so just a key, value container rather than something like a hashmap. In java there's an AbstractMap.SimpleEntry class I can use so I was planning on using that and using them as my array elements rather than building my own class container from scratch just to hold an extra integer. It'd basically be what you were suggesting. I'm just not entirely sure if it'd be better practice to go ahead and build that class in this scenario.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
April 19 2016 13:32 GMT
#14389
Why don't you add a pointer to the next bitmap in each entry instead of an index?
I'll always be your shadow and veil your eyes from states of ain soph aur.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 19 2016 13:33 GMT
#14390
On April 19 2016 21:10 Acrofales wrote:
Show nested quote +
On April 19 2016 16:47 Itsmedudeman wrote:
Our university never really taught us "how" to program, just concepts and the best practices kind of stuff was left untouched unless it came up randomly. I'd love it if someone went through and reviewed code for you and told you why it's bad to do X, but you kinda just have to learn that for yourself through reading or fucking up tremendously to where your program won't work.

To my next point though... I'm working on a project which needs to store objects (bitmap images) in a list. This list gets shuffled and I need to know when this list is back in order again after various swaps. What I'm planning on doing is storing each bitmap in a map container with an integer key so <Integer, Bitmap> where the integer represents the index where the image should be in the list to be in correct order. I feel like I might be misusing the map container since I'm actually just storing a value pair rather than storing an object with a key so maybe there's a better data structure I could use. Is this how you guys would go about it?

Depends. If given the key you want access to the bitmap, then yes. But it doesn't really sound like what you want. It sounds like you want a list of bitmaps that you can shuffle (can't shuffle dictionaries, and seperately, a way of recognizing when they're back in the original order. It's worth noting that if your list is large enough and the shuffle is random, this can take a very very very long time. I'd store them in an array (or a linked list, which makes shuffling a bit faster at the cost of retrieval, but this type of optimization can wait til you figure out what are the commonly used operations, and you can profile your app to see if it makes sense), with each object in the list being a tuple (original index, bitmap).

That said, you can easily do this with an array of the bitmaps and your dictionary idea too, but it makes insert and remove operations more costly (and prone to forgetting to maintain both datastructures, introducing bugs).


That would probably be my solution as well. I'd stick with an array since you can shuffle in place and so still get a constant time when switching two elements.

Have a list like
[
{
originalIndex: 0,
bitmap: bitmapdata
},
{
originalIndex: 1,
bitmap: bitmapdata2
}
]


Then you can easily check if it's ordered with

bool isOrdered = true;
for (int i = 0; i < bitmaps.length; ++i)
{
if (bitmaps[i].originalIndex != i)
{
isOrdered = false;
break;
}
}


Not sure which language you are using, but C# has a class "System.Tuple<A, B>" that can store two values in one variable without requiring a new class. However, fear of creating classes is a bad thing, so don't be afraid to create a class just for one purpose, no matter how small.
Propelled
Profile Joined October 2010
Denmark184 Posts
Last Edited: 2016-04-19 13:59:24
April 19 2016 13:51 GMT
#14391
I'm getting a weird error in some php code of mine for a hobby project.
I've created a sort function inside a class, but I get the following error whenever I try to run the code
Fatal error: Cannot redeclare card_compare() (previously declared in E:\xampp\htdocs\ML\Deck.php:62) in E:\xampp\htdocs\ML\Deck.php on line 62
This is the code for the function:
private function board_sort(&$board) {
function card_compare($a, $b) {
if(Deck::type_enum($a[3]) === Deck::type_enum($b[3])) {
return 0;
}
return Deck::type_enum($a[3]) < Deck::type_enum($b[3]) ? -1 : 1;
}
return usort($board, 'card_compare');
}
At the moment, the only time I'm calling board_sort is twice in my class constructor. The only time card_compare is mentioned is on line 62 where I declare it and on line 68 where I call it as a parameter for usort. type_enum() is a simple workaround for enumerating strings to integers since enums aren't built into php. I am including the Deck.php file, used exclusively for defining the class, in single other php file, where I'm using require_once to include it, then creating a number of instances of the class through a loop.

I've tried google for the solution, but I've only been able to find cases where there was another function named the same, which does not seem to be the case here. I honestly how no idea what is going on, considering it how it complaining about it already being declared in the same file and line as where I am actually declaring it.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 19 2016 14:01 GMT
#14392
Don't create named functions inside other functions. I didn't even knew it was possible anyways. I assume it tries to create a new function with that name every time that method is called and so on the second call it fails.

Just use
private function board_sort(&$board) {
return usort(
$board,
function($a, $b) {
if(Deck::type_enum($a[3]) === Deck::type_enum($b[3])) {
return 0;
}
return Deck::type_enum($a[3]) < Deck::type_enum($b[3]) ? -1 : 1;
}
);
}


or

private function board_sort(&$board) {
return usort($board, [$this, 'card_compare']);
}

private function card_compare($a, $b) {
if(Deck::type_enum($a[3]) === Deck::type_enum($b[3])) {
return 0;
}
return Deck::type_enum($a[3]) < Deck::type_enum($b[3]) ? -1 : 1;
}

Propelled
Profile Joined October 2010
Denmark184 Posts
Last Edited: 2016-04-19 14:10:35
April 19 2016 14:10 GMT
#14393
That was the issue. I didn't know php had anonymous functions, so now I know that as well.

Thanks for the quick answer
Acrofales
Profile Joined August 2010
Spain18265 Posts
April 19 2016 14:37 GMT
#14394
On April 19 2016 22:00 Itsmedudeman wrote:
Show nested quote +
On April 19 2016 21:10 Acrofales wrote:
On April 19 2016 16:47 Itsmedudeman wrote:
Our university never really taught us "how" to program, just concepts and the best practices kind of stuff was left untouched unless it came up randomly. I'd love it if someone went through and reviewed code for you and told you why it's bad to do X, but you kinda just have to learn that for yourself through reading or fucking up tremendously to where your program won't work.

To my next point though... I'm working on a project which needs to store objects (bitmap images) in a list. This list gets shuffled and I need to know when this list is back in order again after various swaps. What I'm planning on doing is storing each bitmap in a map container with an integer key so <Integer, Bitmap> where the integer represents the index where the image should be in the list to be in correct order. I feel like I might be misusing the map container since I'm actually just storing a value pair rather than storing an object with a key so maybe there's a better data structure I could use. Is this how you guys would go about it?

Depends. If given the key you want access to the bitmap, then yes. But it doesn't really sound like what you want. It sounds like you want a list of bitmaps that you can shuffle (can't shuffle dictionaries, and seperately, a way of recognizing when they're back in the original order. It's worth noting that if your list is large enough and the shuffle is random, this can take a very very very long time. I'd store them in an array (or a linked list, which makes shuffling a bit faster at the cost of retrieval, but this type of optimization can wait til you figure out what are the commonly used operations, and you can profile your app to see if it makes sense), with each object in the list being a tuple (original index, bitmap).

That said, you can easily do this with an array of the bitmaps and your dictionary idea too, but it makes insert and remove operations more costly (and prone to forgetting to maintain both datastructures, introducing bugs).

I actually misused the word Map to mean an entry of Map, so just a key, value container rather than something like a hashmap. In java there's an AbstractMap.SimpleEntry class I can use so I was planning on using that and using them as my array elements rather than building my own class container from scratch just to hold an extra integer. It'd basically be what you were suggesting. I'm just not entirely sure if it'd be better practice to go ahead and build that class in this scenario.

A Map is a Map is a Map. Don't confuse your conceptual datastructures with your implemented datastructures (although i guess my original post kinda invited that by going into the details of what list implementation is better). A Map, inherently, is a datastructure that has two sets, and a surjective function between them. In (mathematical) theory, the surjection is not required (any function will do), but in computing, it'd be extremely weird for your map to not be surjective (often, in fact, your map will be bijective, as is the case in your example).

Now your map has to be implemented in some way. The usual Java implementation is with a hash table (Hashmap), but as you say, there are many other ways of doing this. For instance, you could create a horribly inefficient Map by storing your keys in one array, and your objects in another array. Your lookup could then find the key in the first array, and return the element at the same index in the object array. This has an O(n) average efficiency for search and for delete, whereas a hash table has O(1) average efficiency for those operations.

Now I realize this is all a tangent, as it seems you weren't interested in Map at all, but some nested class of the Java SDK's AbstractMap. You can obviously do this, but it seems rather silly. The reason why is best explained by referring to a recent fubar concerning Node.js libraries (and while the Java SDK is a lot better maintained than Node.js random assortment of libraries, the philosophy is similar):

http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/

Every package that you use adds yet another dependency to your project. Dependencies, by their very name, are things you need in order for your code to function. The more dependencies you take on, the more points of failure you have. Not to mention the more chance for error: have you vetted any of the programmers who have written these functions that you depend on daily?

Take on a dependency for any complex functionality that would take a lot of time, money, and/or debugging to write yourself. Things like a database access layer (ORM) or caching client should be dependencies because they’re complicated and the risk of the dependency is well worth the savings and efficiency.


Not to mention, the confusion that this adds for someone debugging or extending the code (probably you in 6 months time). You'll be looking at the code asking yourself where the Map is that makes use of these AbstractMap.SimpleEntry objects, and how you can extend this to not only store a bitmap, but also a textual descriptor of the image. If, however, you write your own nested class with about 10 lines of code (most of it autogenerated by your IDE), and give it a sensible name (e.g. OrderedBitmap), then you won't have to worry about this. You also won't have to worry about Oracle deprecating AbstractMap.SimpleEntry in a future Java version (not that that seems likely to happen, but presumably the programmers using the padleft "library" didn't expect that to get removed from github either).
Acrofales
Profile Joined August 2010
Spain18265 Posts
April 19 2016 14:46 GMT
#14395
On April 19 2016 22:32 Blitzkrieg0 wrote:
Why don't you add a pointer to the next bitmap in each entry instead of an index?

While that will obviously work too to maintain the original order (there's more than one way to skin a cat), I don't see the advantage?
carmon
Profile Joined December 2010
United States220 Posts
Last Edited: 2016-04-19 15:44:21
April 19 2016 15:38 GMT
#14396
On April 18 2016 05:32 waffelz wrote:
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.



Someone correct me if I am wrong, but to be pedantic the code you supplied could work and depends entirely on the context, such as the modifiers of the method. If

Classname1.doSomethingWhichAccessesAttributes();


is static and is correctly written (i.e. uses static attributes only) then it is correct. This means that this line:

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();



could also work if this same static method returns a ClassType of Classname1.
amazingxkcd
Profile Blog Joined September 2010
GRAND OLD AMERICA16375 Posts
April 19 2016 15:39 GMT
#14397
https://live.awsevents.com/

AWS Summit keynotes going on atm for though who use AWS
The world is burning and you rather be on this terrible website discussing video games and your shallow feelings
waffelz
Profile Blog Joined June 2012
Germany711 Posts
April 19 2016 15:54 GMT
#14398
On April 20 2016 00:38 carmon wrote:
Show nested quote +
On April 18 2016 05:32 waffelz wrote:
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.



Someone correct me if I am wrong, but to be pedantic the code you supplied could work and depends entirely on the context, such as the modifiers of the method. If

Classname1.doSomethingWhichAccessesAttributes();


is static and is correctly written (i.e. uses static attributes only) then it is correct. This means that this line:

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();



could also work if this same static method returns a ClassType of Classname1.


Yes. But unfortunately this was neither the reason for said student to make this mistake, nor did he understood the situation like you. And in both cases said student was just plain wrong.
I wish I had more people like you in the groups I oversee
RIP "The big travis CS degree thread", taken from us too soon | Honourable forum princess, defended by Rebs-approved white knights
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-19 20:08:37
April 19 2016 20:05 GMT
#14399
On April 19 2016 23:46 Acrofales wrote:
Show nested quote +
On April 19 2016 22:32 Blitzkrieg0 wrote:
Why don't you add a pointer to the next bitmap in each entry instead of an index?

While that will obviously work too to maintain the original order (there's more than one way to skin a cat), I don't see the advantage?


Simplicity mainly. I think shuffling my solution kinda loses its meaning though.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Wrath
Profile Blog Joined July 2014
3174 Posts
April 21 2016 21:14 GMT
#14400
How to gain experience without job?
Prev 1 718 719 720 721 722 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Map Contest Tou…
11:00
Group D
WardiTV1016
TKL 292
IndyStarCraft 259
Rex113
3DClanTV 64
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 292
IndyStarCraft 259
Rex 113
NoRegreT_ 69
Codebar 45
herO (SOOP) 34
StarCraft: Brood War
Britney 113492
Calm 5206
EffOrt 1579
Horang2 1513
Mini 573
ggaemo 406
BeSt 331
ToSsGirL 255
firebathero 254
Mind 132
[ Show more ]
Soulkey 127
PianO 104
Last 96
Hyun 83
[sc1f]eonzerg 63
Killer 59
sSak 52
Sexy 46
Sharp 46
Shinee 37
Movie 37
yabsab 19
zelot 16
Hm[arnc] 16
GoRush 12
IntoTheRainbow 10
SilentControl 10
Rock 10
Dota 2
Gorgc6607
BananaSlamJamma153
ODPixel41
League of Legends
Reynor29
Counter-Strike
olofmeister3231
fl0m2979
byalli295
Super Smash Bros
Mew2King112
Heroes of the Storm
Khaldor450
Liquid`Hasu87
Other Games
singsing1934
B2W.Neo1526
Beastyqt584
Mlord461
mouzStarbuck213
XaKoH 204
Hui .127
Fuzer 84
Organizations
Dota 2
PGL Dota 2 - Main Stream12396
PGL Dota 2 - Secondary Stream1389
Other Games
BasetradeTV326
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Adnapsc2 12
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• FirePhoenix8
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1896
• Nemesis1860
• TFBlade983
Upcoming Events
Ladder Legends
55m
IPSL
1h 55m
JDConan vs TBD
Aegong vs rasowy
BSL
4h 55m
StRyKeR vs rasowy
Artosis vs Aether
JDConan vs OyAji
Hawk vs izu
CranKy Ducklings
9h 55m
Replay Cast
18h 55m
Wardi Open
19h 55m
Afreeca Starleague
19h 55m
Bisu vs Ample
Jaedong vs Flash
Monday Night Weeklies
1d 1h
RSL Revival
1d 11h
Afreeca Starleague
1d 19h
Barracks vs Leta
Royal vs Light
[ Show More ]
WardiTV Map Contest Tou…
1d 20h
RSL Revival
2 days
Replay Cast
3 days
The PondCast
3 days
KCM Race Survival
3 days
WardiTV Map Contest Tou…
3 days
Replay Cast
4 days
Escore
4 days
RSL Revival
5 days
WardiTV Map Contest Tou…
5 days
Ladder Legends
6 days
uThermal 2v2 Circuit
6 days
BSL
6 days
Sparkling Tuna Cup
6 days
WardiTV Map Contest Tou…
6 days
Liquipedia Results

Completed

Escore Tournament S2: W3
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W4
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
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 © 2026 TLnet. All Rights Reserved.