• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 12:28
CET 18:28
KST 02:28
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL Offline Finals Info - Dec 13 and 14! StarCraft Evolution League (SC Evo Biweekly) RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread ZeroSpace Megathread Nintendo Switch Thread The Perfect Game 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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
Physical Exertion During Gam…
TrAiDoS
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1420 users

The Big Programming Thread - Page 762

Forum Index > General Forum
Post a Reply
Prev 1 760 761 762 763 764 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.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-09-11 08:03:48
September 11 2016 07:56 GMT
#15221
On September 11 2016 15:19 teamamerica wrote:
Show nested quote +
On September 11 2016 13:21 Blisse wrote:
Also you don't have to make getters and setters unless you need to control access. Just make the members public.


The downside is in Java is that if you wanna change it to a method you have to change every callsite. You can argue that in the case you're refactoring a public property into a method that's not a big deal, but other languages let $object.property be either a direct instance variable lookup or a method call.


To be honest while I've heard that argument I don't really feel like this is an issue, besides ease of IDE refactoring, it's just straightforward manual work. If it's an area you already believe will change often you would have already added it as a g/setter. And if it wasn't predicted to be used like this it often requires more thought into what the actual intended usage is. I never felt this to be an annoyance irl.

The only big issue with this is when you're flipflopping between having the g/setters and not having them, which if you're planning well, just means requirements are changing a lot, and should be normal.


On September 11 2016 16:31 spinesheath wrote:
Show nested quote +
On September 11 2016 12:09 Hhanh00 wrote:
In case you are stuck with Java, you may want to take a look at Project Lombok that uses AOP to inject the boiler plate.

The java code becomes

@Data
public class Animal {
private String type;
private int age;
private String size;
}


and ends up being the same bytecode.

I've looked into AOP but never actually used it. You probably have some actual experience with it. I've always wondered how it affects debugging - you obviously can't step through single lines of code if you never write them. How's that working out for you?


I believe that the annotations are used to compile the annotated class into some generated code before being fed to the actual Java compiler, so debugging should work as normal? I feel like I've done that before...
There is no one like you in the universe.
Acrofales
Profile Joined August 2010
Spain18139 Posts
Last Edited: 2016-09-11 09:16:15
September 11 2016 09:13 GMT
#15222
On September 11 2016 06:55 travis wrote:
Sensing I needed to review and make sure I understand java basics I wrote a pointless program. I wanted to check that I knew how to write things like equals, toString, getters/setters, constructors, and use inheritance correctly.

If anyone has free time could they look at my code and make sure I am not doing anything naughty?
Also I have 3 questions about the code (one in particular is important)


animal class
+ Show Spoiler +

package life;

public class animal {

private String type;
private int age;
private String size;

public animal(){
this.type = "unknown";
this.age = 0;
this.size = "unknown";
}

public animal(int a, String t, String s){
this.age = a;
this.type = t;
this.size = s;
}

public animal(animal oldAnimal){
this.age = oldAnimal.age;
this.type = oldAnimal.type;
this.size = oldAnimal.size;
}




public String toString(){
return ("This is a " + this.type + ", it is " + this.age + " years old, and it is " + this.size);
}


public boolean equals(Object other){
if(this == other){
return true;
}
if(!(other instanceof animal)){
return false;
}

animal a = (animal) other;
return this.toString() == a.toString();
}


public void move(){
System.out.println(this.type + " moved");
}

public void eat(String f){
System.out.println(this.type + " ate " + f);
}











public void setType(String t){
this.type = t;
}

public void setAge(int a){
this.age = a;
}

public void setSize(String s){
this.size = s;
}

public String getType(){
return this.type;
}

public int getAge(){
return this.age;
}

public String getSize(){
return this.size;
}


}




Human Class
+ Show Spoiler +

package life;

public class human extends animal {

private String name;

public human(){
super();
this.name = "unnamed";
}

public human(String n, String t, String s, int a){
super(a, t, s);
this.name = n;
}

public human(human oldHuman){
super(oldHuman);
this.name = oldHuman.name;
}

public String toString(){
return (super.toString() + " and it's name is " + this.name);
}

public boolean equals(Object other){
if(this == other){
return true;
}
if(!(other instanceof human)){
return false;
}

human h = (human) other;

return this.toString() == h.toString();
}






public void complain(String c){
System.out.println(this.name + " complains about " + c);
}

public void setName(String n){
this.name = n;
}

public String getName(){
return this.name;
}

}



"engine"
+ Show Spoiler +

package life;

import java.util.ArrayList;
import java.util.Iterator;

public class life {

public static void main(String[] args) {

ArrayList<human> humanList = new ArrayList<human>();

humanList.add(new human());
humanList.add(new human("Tim", "mammal", "medium", 25));
humanList.add(new human("Burt", "mammal", "huge", 43));
humanList.add(new human(humanList.get(1)));

Iterator<human> iterate = humanList.iterator();

while(iterate.hasNext()){
human thisHuman = iterate.next();
System.out.println(thisHuman.getName());
}

for(human h : humanList){
System.out.println(h.toString());
}

System.out.println(humanList.get(0).equals(humanList.get(1)));

System.out.println(humanList.get(1).equals(humanList.get(3)));


}

}



my questions
+ Show Spoiler +

1.) my equals method is based on what I was taught in lecture. my question is, what is the point of casting the object type when I am already checking if it is an instance of that object type?

in the specific example in lecture the professor does call an equals method within the equals method - he uses super.equals(other), but even with that example I don't understand why the casting is necessary.


2.) when I call super(oldHuman) in my constructor - what sorcery is this. it seems like magic. is this one of those things that java can "just do" ?



3.) System.out.println(humanList.get(1).equals(humanList.get(3))); is returning false. why? shouldn't this return true?




thank you to any kind souls who help me out



In addition to all the useful advice the others have given you, l personally like took keep the order of my parameters the same. So if in your animal constructor you use (age, type, size), it is best to do so for your human class as well. Also, try to use variable names that make sense. While you can now still remember what a, t and s are, I guarantee you won't recall that when you have to extend or revise your code in a few weeks (or some other poor shmoe has to do that).

Oh, and talking about debugging, do you really need that constructor for humans? Do you ever want humans to be of type "dog" and size "microscopic"?
Manit0u
Profile Blog Joined August 2004
Poland17496 Posts
September 11 2016 10:18 GMT
#15223
On September 11 2016 15:19 teamamerica wrote:
Show nested quote +
On September 11 2016 14:44 Wrath wrote:
On September 11 2016 11:11 Manit0u wrote:
On September 10 2016 22:59 Wrath wrote:
Call me a retard but is it normal to waste full day on setting up eclipse with Symfony and run the code against apache httpd server and still not working?


First of all, if you're developing with Symfony you don't even need Apache. Symfony has its own built-in server for development purposes if you need one.

You can of course still use Apache, Nginx or whatever else you need (for Apache note that Symfony doesn't use .htaccess and you must have proper Require All Granted etc. set in your host settings, you can look those up in the Symfony docs).

Second thing is the fact that you should not use Eclipse for that. NetBeans would be better but still shitty. Just for learning you could be using PhpStorm (with super duper mega excellent symfony plugin) in its 30-day free trial (or endless trial if you're a student). Trust me, it's miles apart from any freeware solution. I can't even look at Eclipse or NetBeans after using jetbrains products...


I'm not a student and I can't guarantee that the workplace will provide me a phpstorm. That is why I'm trying to get a free IDE...


If for some reason work refuses to pay for it I'd really recommend just buying it yourself. Idk if you're not in US but if you are it's pretty cheap; I did that for my first job and I didn't regret it at all.


It was the same for me. I did the 30-day trial to see if it's any good and then simply bought it for myself. The additional benefit is that if I go to work somewhere else I still have my phpstorm since it's mine and not company's. It's a good investment that earns its price back tenfold pretty soon in all the work saved and general quality of life.

And I have no idea how come it's super hard to get a good looking dark theme going on with Eclipse or NetBeans. I simply can't stand working with code on white background (NetBeans takes the cake for dumbest implementation here since you have some potential errors shown as light yellow underline which is pretty much invisible). Displaying all the whitespace characters is also a huge pain in those IDEs.
Time is precious. Waste it wisely.
Hhanh00
Profile Joined May 2016
34 Posts
September 11 2016 11:09 GMT
#15224
On September 11 2016 16:31 spinesheath wrote:
Show nested quote +
On September 11 2016 12:09 Hhanh00 wrote:
In case you are stuck with Java, you may want to take a look at Project Lombok that uses AOP to inject the boiler plate.

The java code becomes

@Data
public class Animal {
private String type;
private int age;
private String size;
}


and ends up being the same bytecode.

I've looked into AOP but never actually used it. You probably have some actual experience with it. I've always wondered how it affects debugging - you obviously can't step through single lines of code if you never write them. How's that working out for you?


When the tool generates bytecode directly, you won't have source code but some of the IDE can decompile it for you automatically. Since it's just boilerplate code, it is best stepped over and treated like library code.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 20:46:23
September 11 2016 17:52 GMT
#15225
-.-
Acrofales
Profile Joined August 2010
Spain18139 Posts
Last Edited: 2016-09-11 18:21:07
September 11 2016 18:20 GMT
#15226
The problem sounds underspecified, but it depends a lot on the size of your arrays. If your match list is small, you can do it that way, and never really have too many permutations to handle. But the number of possible permutations grows exponentially (n! in fact), so it can get intractable pretty quickly.

Another option is to use a sliding window on your target array, and see if it contains all of your search terms. You start with windows of the same size as your search array, and if you don't find any matches, increase by 1 and repeat. Stop when you find a match (which is guaranteed to be (one of) the shortest).

You can start by sliding your window one item at a time, but can speed up the algorithm by skipping windows you know cannot possibly match.
Hhanh00
Profile Joined May 2016
34 Posts
September 11 2016 18:26 GMT
#15227
Can the lists have duplicate values?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 20:46:35
September 11 2016 19:00 GMT
#15228
-.-
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-09-11 19:27:54
September 11 2016 19:23 GMT
#15229
It's interesting that they're asking problems like that for you to solve this early. That's something that I would expect in a programming interview.

If you're comfortable, I believe using a dynamically-sized sliding window is the "optimal" solution, but it probably involves a few new concepts you haven't learned yet. Using a dictionary/map can help.
There is no one like you in the universe.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-09-11 21:45:00
September 11 2016 19:48 GMT
#15230
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
September 11 2016 19:59 GMT
#15231
geeze does that really not have flaws because that solution not only sounds efficient but also pretty easy to do


can't really think of any problems with it..
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
September 11 2016 20:28 GMT
#15232
Did you consider the possibility that some of the values to look for are duplicates? Would you have to match as many duplicates in the list?
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18139 Posts
September 11 2016 20:30 GMT
#15233
Nesserev wins. Far more efficient.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 20:47:46
September 11 2016 20:46 GMT
#15234
I am actually going to edit my posts because I carefully read about academic integrity for our CS department and apparently discussing projects on forums at all is a violation. they are so vague about it

which is complete bullshit since that's basically saying you can't go learn about what you are doing

and anyone could do google searches to find algorithms to do exactly this

but w/e, better safe than sorry

next time I will discuss these concepts in a safer way

and yeah I know this is paranoid but my school is very big and I am sure there are some CS students who go to TL
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
September 11 2016 21:28 GMT
#15235
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 21:38:55
September 11 2016 21:37 GMT
#15236
it wouldn't hurt I guess

based on other things I have seen professors say this shouldn't really be a violation, but the rules are so vague that I could get screwed over if they wanted

they literally say that it is an academic integrity violation to:

"Using online forums to ask for help regarding our assignments."

which is the vaguest nonsense ever

it's kind of like saying that I can't use online forums to discuss how to program
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-09-11 22:00:06
September 11 2016 21:52 GMT
#15237
Yeah, academic integrity policy is intentionally vague so that it's a lot easier on them when they provide proof. Generally it's fine as long as you're just talking about the solution and not given exact pseudo/code. All reasonable professors I've seen encourage discussion, just not discussion with code being written.

I've consulted TL for a bunch of things too.

Instead of giving the problem description, you should abstract it one step up. I know it's a bit harder to do since you're starting out, but asking, "how do you find the smallest range of numbers in a list that contains a given set of numbers?" gives essentially the same solutions, and as long as no one is writing out a program for you, it should be fine asking for help.

-----

Actually it's kind of annoying/interesting that a lot of programming questions essentially rely on tricks that you need to learn first before you can actually solve them. Using sets and dictionaries IMO don't come intuitively, but instead from me reading advice that they're generally how to best solve a problem, and then I base my thinking with that in mind. I think the extreme example is being asked to find a loop in a linked list. No way you can reason yourself to a solution.
There is no one like you in the universe.
Shaella
Profile Blog Joined January 2013
United States14828 Posts
September 12 2016 03:41 GMT
#15238
Gentlemen i am inspired.

Inspired by the azarkon mute script, I've been trying to create a version for a completely different forum that accomplishes the same task.

Problem being this is a zetaboards forum and everything in it seems to be contained in endless fucking tables.

Any advice? It shouldn't be that hard if I know what i'm looking for i just don't know where to start.
don't tell me to provide a legend for those charts cause we already got shaella in this thread - eieio | Bulba is my waifu
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
Last Edited: 2016-09-12 04:06:20
September 12 2016 04:05 GMT
#15239
I haven't done much with userscripts before but pretty sure they have easy access to the DOM, so you just need to find how posts are stored in the DOM and then find the element with the username you want to hide, then remove it. IDK if that's enough to go off or you need more specifics though.

E.g.

<tr id="post-8073303">
<td class="c_username">
<a href='http://s9.zetaboards.com/Ultimate3D_community/profile/44616/' class='member'>AZARKON THE GREAT</a><a name='post8073303'></a>
</td>

So you just navigate the DOM for anything with id = post-SOMETHING, then within its children, check class=member, check the text for the usernames you want to hide, and if so use whatever DOM manipulation userscripts have to hide/remove the whole post tr.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
September 12 2016 04:25 GMT
#15240
On September 12 2016 06:52 Blisse wrote:
Yeah, academic integrity policy is intentionally vague so that it's a lot easier on them when they provide proof. Generally it's fine as long as you're just talking about the solution and not given exact pseudo/code. All reasonable professors I've seen encourage discussion, just not discussion with code being written.

I've consulted TL for a bunch of things too.

Instead of giving the problem description, you should abstract it one step up. I know it's a bit harder to do since you're starting out, but asking, "how do you find the smallest range of numbers in a list that contains a given set of numbers?" gives essentially the same solutions, and as long as no one is writing out a program for you, it should be fine asking for help.

-----

Actually it's kind of annoying/interesting that a lot of programming questions essentially rely on tricks that you need to learn first before you can actually solve them. Using sets and dictionaries IMO don't come intuitively, but instead from me reading advice that they're generally how to best solve a problem, and then I base my thinking with that in mind. I think the extreme example is being asked to find a loop in a linked list. No way you can reason yourself to a solution.

I mean, I'm not particularly good, but couldn't you just put the pointer values of each node in a dict when visited, and if you come to a node already in the dict, then you've got a loop?
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Prev 1 760 761 762 763 764 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
16:00
OSC Elite Rising Star #17
Nicoract vs MixuLIVE!
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
SteadfastSC120
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 696
Lowko466
ProTech122
SteadfastSC 120
Codebar 31
MindelVK 28
StarCraft: Brood War
Britney 21592
Calm 3009
Shuttle 730
GuemChi 571
EffOrt 497
Larva 275
Rush 215
firebathero 161
BeSt 128
Dewaltoss 107
[ Show more ]
PianO 67
yabsab 29
Mong 23
Aegong 19
Sacsri 19
soO 18
scan(afreeca) 11
SilentControl 10
Terrorterran 9
HiyA 7
JulyZerg 7
NaDa 5
Dota 2
Gorgc7060
Dendi935
420jenkins318
XcaliburYe188
Counter-Strike
fl0m3678
zeus289
chrisJcsgo31
minikerr2
Heroes of the Storm
Khaldor152
Other Games
Grubby3494
hiko852
ArmadaUGS113
Livibee78
Mew2King66
QueenE54
Trikslyr51
KnowMe39
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• poizon28 17
• Reevou 7
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2738
• WagamamaTV579
Other Games
• Shiphtur115
Upcoming Events
Replay Cast
6h 32m
Korean StarCraft League
1d 9h
CranKy Ducklings
1d 16h
WardiTV 2025
1d 18h
SC Evo League
1d 19h
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
2 days
WardiTV 2025
2 days
OSC
2 days
[ Show More ]
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
3 days
Wardi Open
3 days
StarCraft2.fi
3 days
Monday Night Weeklies
3 days
Replay Cast
4 days
WardiTV 2025
4 days
StarCraft2.fi
4 days
PiGosaur Monday
5 days
StarCraft2.fi
5 days
Tenacious Turtle Tussle
6 days
The PondCast
6 days
WardiTV 2025
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
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

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 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.