• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 13:16
CET 19:16
KST 03:16
  • 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
StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win10
StarCraft 2
General
SC: Evo Complete - Ranked Ladder OPEN ALPHA Mech is the composition that needs teleportation t TL.net Map Contest #21: Winners StarCraft, SC2, HotS, WC3, Returning to Blizzcon! RotterdaM "Serral is the GOAT, and it's not close"
Tourneys
Constellation Cup - Main Event - Stellar Fest Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
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
FlaSh on: Biggest Problem With SnOw's Playstyle BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions BW General Discussion Where's CardinalAllin/Jukado the mapmaker?
Tourneys
[Megathread] Daily Proleagues [ASL20] Grand Finals [BSL21] RO32 Group A - Saturday 21:00 CET [BSL21] RO32 Group B - Sunday 21:00 CET
Strategy
PvZ map balance Current Meta How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Nintendo Switch Thread Path of Exile Dawn of War IV
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
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread US 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
Learning my new SC2 hotkey…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1383 users

The Big Programming Thread - Page 761

Forum Index > General Forum
Post a Reply
Prev 1 759 760 761 762 763 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.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
Last Edited: 2016-09-10 10:53:40
September 10 2016 10:02 GMT
#15201
edit: I suck at posting
On September 10 2016 08:42 Manit0u wrote:
Show nested quote +
On September 10 2016 01:37 phar wrote:
Yea this is likely not the important part of the error message. (In fact if you run with sudo the bit about a file not found may go away depending on your setup).


Please give me some credit...

1. I've tried running it with sudo (same result).
2. I've read somewhere on the interwebz that it might be the result of someone using their libraries and paths to compile the code which breaks on my machine. I've created a new C file with a single assert that's failing, compiled it and dbg'd it, the result is the same.
3. I've installed a ton of additional libraries I don't need but might be used by it (libc6-dev etc.), same thing.
4. People on the interwebz keep saying that you should ignore this error but it's driving me mad.

I did stuff like whreis file.c, which returned a manual but not the file. I've found the file eventually but under completely different path (somewhere inside /usr/share/).

I don't even know what provides this specific file and there's no info about it on the net. Please help. My perfectionist soul is dying here because I don't know if valgrind/dbg stop because of this error or errors in the application...

Edit: So far it seems to only show up on uncaught throws and asserts. Need to do more testing but I'm too drunk atm.


Browsing the internet watching GSL - you can get rid of error by putting that file in the path relative to the executable you're running as a quick fix if you rly care (but shouldn't matter tbh).

Real fix is you probably need to recompile whatever is calling it.

based off http://stackoverflow.com/questions/13152775/debugging-c-nptl-sysdeps-unix-sysv-linux-raise-c-no-such-file-or-directo and my testing just run (which is how I'm confident putting the file at relative path will get rid of error at least)


edit: looked into this a bit more since gsl finals sucked and it seems to be something about glibc. keep in mind i literally have written no c++ code ever but glibc abort.c includes signal, signal defines "raise" as an extern function, and has both a raise.c in a few places, including https://github.com/lattera/glibc/blob/master/nptl/sysdeps/unix/sysv/linux/raise.c. I'm not sure how extern is resolved by compiler but I'd assume that when it was compiled it resolved that^^ raise.c, even though it seems the glibc on ubuntu I downloaded from https://launchpad.net/glibc doesn't have the sysdeps under nptl.
RIP GOMTV. RIP PROLEAGUE.
gswittiness
Profile Joined September 2016
4 Posts
September 10 2016 10:47 GMT
#15202
When I skim through the discussions and whatnot I feel like an absolute noob, which I am haha. Started my first year through evening classes for a graduate degree in IT (choose to take the programming road and not networks) after working like an animal in something I really don't see myself doing for another 5 years, going through C# first, are there any websites (like hackerrank for example) where you can practice your C# skills? For exampe being presented with a problem and trying to find the solution and whatnot?
Ktk
Profile Blog Joined May 2010
Korea (South)753 Posts
September 10 2016 11:17 GMT
#15203
On September 10 2016 19:47 gswittiness wrote:
When I skim through the discussions and whatnot I feel like an absolute noob, which I am haha. Started my first year through evening classes for a graduate degree in IT (choose to take the programming road and not networks) after working like an animal in something I really don't see myself doing for another 5 years, going through C# first, are there any websites (like hackerrank for example) where you can practice your C# skills? For exampe being presented with a problem and trying to find the solution and whatnot?


Do the problems have to mention C#?

What do you plan on doing with C#?

but here are some mathy problems: https://projecteuler.net/
and bioinformatics problems: http://rosalind.info/problems/locations/

probably not very useful for you though, practically speaking :p
gswittiness
Profile Joined September 2016
4 Posts
September 10 2016 11:21 GMT
#15204
On September 10 2016 20:17 Ktk wrote:
Show nested quote +
On September 10 2016 19:47 gswittiness wrote:
When I skim through the discussions and whatnot I feel like an absolute noob, which I am haha. Started my first year through evening classes for a graduate degree in IT (choose to take the programming road and not networks) after working like an animal in something I really don't see myself doing for another 5 years, going through C# first, are there any websites (like hackerrank for example) where you can practice your C# skills? For exampe being presented with a problem and trying to find the solution and whatnot?


Do the problems have to mention C#?

What do you plan on doing with C#?

but here are some mathy problems: https://projecteuler.net/
and bioinformatics problems: http://rosalind.info/problems/locations/

probably not very useful for you though, practically speaking :p


Well, our prof told us we'd be focusing on C# only (at least this semester) so right now that's also the only thing I want to focus on instead of getting ahead of myself by including other languages, one step at a time. Anything that can be helpful to learn and improve my C# knowledge is basically what I'm looking for.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
September 10 2016 11:30 GMT
#15205
--- Nuked ---
Acrofales
Profile Joined August 2010
Spain18112 Posts
September 10 2016 11:53 GMT
#15206
On September 10 2016 20:21 gswittiness wrote:
Show nested quote +
On September 10 2016 20:17 Ktk wrote:
On September 10 2016 19:47 gswittiness wrote:
When I skim through the discussions and whatnot I feel like an absolute noob, which I am haha. Started my first year through evening classes for a graduate degree in IT (choose to take the programming road and not networks) after working like an animal in something I really don't see myself doing for another 5 years, going through C# first, are there any websites (like hackerrank for example) where you can practice your C# skills? For exampe being presented with a problem and trying to find the solution and whatnot?


Do the problems have to mention C#?

What do you plan on doing with C#?

but here are some mathy problems: https://projecteuler.net/
and bioinformatics problems: http://rosalind.info/problems/locations/

probably not very useful for you though, practically speaking :p


Well, our prof told us we'd be focusing on C# only (at least this semester) so right now that's also the only thing I want to focus on instead of getting ahead of myself by including other languages, one step at a time. Anything that can be helpful to learn and improve my C# knowledge is basically what I'm looking for.


Simply using it is one of the best ways to improve. Stackoverflow has a nice list of sites and forums that give hundreds of programming problems and puzzles. Some are specific for a language, but plenty are just open puzzles. Pick one that interests you and solve using C#.

http://programmers.stackexchange.com/questions/756/where-can-i-find-programming-puzzles-and-challenges
Wrath
Profile Blog Joined July 2014
3174 Posts
September 10 2016 13:59 GMT
#15207
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?
Hhanh00
Profile Joined May 2016
34 Posts
Last Edited: 2016-09-10 15:08:00
September 10 2016 15:00 GMT
#15208
On September 10 2016 18:58 Manit0u wrote:
Show nested quote +
On September 10 2016 17:55 Hhanh00 wrote:
Your question is about the 'No such file or directory.' or about the reason of the abort?


No such file or directory.


The compiler leaves debugging info (unless you strip them) that relates offsets in the binary code to lines in the source code.
gdb breaks when your app raises SIGABRT (maybe because of an assert?). It tries to decode the stack by looking up return addresses. It found that the closest line is line 56 of raise.c but can't find the actual file on your system. By the way, that line is

int ret = INLINE_SYSCALL (tgkill, 3, pid, tid, sig);

which shows that we are about to go to the kernel which makes sense since we are raising a signal after all.

If you want to get rid of the message, you can download the source code of glibc and specify its location in .gdbinit
https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html

Obviously, you can also simply ignore it.

Edit: You don't have the file because it is a file from the glibc that was compiled by someone else. gdb doesn't care about what code belongs to who. Your code is treated the same way as any user code - including the C runtime.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-10 21:56:24
September 10 2016 21:55 GMT
#15209
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
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2016-09-10 21:58:06
September 10 2016 21:57 GMT
#15210
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?


After 2 years of work experience, I think one could spend hours/days on stupid things which, once you figure out, could be simple. For example, I've spent about 3 work days trying to debug an application hosted by IIS. I couldn't figure out what the problem was when I was debugging from Visual Studio. It was happening, at least quickly, when there was no debugging/attaching to process involved and when there were a lot of requests in a short time. Anyway, solution was just to use 'using' block. What a stupid problem to have! :D
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-09-10 22:46:32
September 10 2016 22:16 GMT
#15211
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


1. It's standard practice to do an instanceof on a type before you cast it. In this specific case, you're checking if it isn't an instance of Human because if it's not an instanceof Human then it can't be equal. The way you're comparing the objects seems strange though. You should be ensuring that the fields have the same values rather than checking their toString output even though these technically produce the same thing.

2. This is a copy constructor. I'll just let you google java copy constructor and read about it.

Conventions wise; are all your class names lower case? Class names should be uppercase.
I'll always be your shadow and veil your eyes from states of ain soph aur.
ShAsTa
Profile Joined November 2002
Belgium2841 Posts
Last Edited: 2016-09-10 22:22:05
September 10 2016 22:17 GMT
#15212
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


I advise you to test for equals using the attributes themselves and not the toString. Also you need to call equals on the toString result because now you're testing for reference equality (which will fail) and not the kind of equals you want. That's probably the reason for 3)
Most IDEs can generate the equals (and hashCode) for you. Btw, if you define your own equals you should also define a hashCode method that's compatible.
If we hit that bull's eye, the rest of the dominoes will fall like a house of cards. Checkmate.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
September 10 2016 23:21 GMT
#15213
ah thanks guys

okay so class names capitalized, got it

shasta, you are correct about the problem with my equals method and your explanation makes sense. Don't know what a hashCode method is but I guess that's something new to learn
Manit0u
Profile Blog Joined August 2004
Poland17423 Posts
Last Edited: 2016-09-11 02:15:01
September 11 2016 02:11 GMT
#15214
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...
Time is precious. Waste it wisely.
Hhanh00
Profile Joined May 2016
34 Posts
Last Edited: 2016-09-11 03:21:58
September 11 2016 03:09 GMT
#15215
The amount of boilerplate code required to implement a trivial struct in Java is sad.

+ Show Spoiler +


public class Animal {
private String type;
private int age;
private String size;

public Animal(String type, int age, String size) {
this.type = type;
this.age = age;
this.size = size;
}

public String getType() {
return type;
}

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

public int getAge() {
return age;
}

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

public String getSize() {
return size;
}

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

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Animal animal = (Animal) o;

if (age != animal.age) return false;
if (type != null ? !type.equals(animal.type) : animal.type != null) return false;
return size != null ? size.equals(animal.size) : animal.size == null;
}

@Override
public int hashCode() {
int result = type != null ? type.hashCode() : 0;
result = 31 * result + age;
result = 31 * result + (size != null ? size.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "Animal{" +
"type='" + type + '\'' +
", age=" + age +
", size='" + size + '\'' +
'}';
}
}



Fortunately some IDEs can generate this for you but it's still a hassle when you don't have one or you want to update the class definition later.

It's also so easy to forget about checking for null values and forgetting about hashCode() when you implement equals.

Compare this to scala:


case class Animal(tpe: String, age: Int, size: String)


A single line is all it takes.

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.

PS: To the @OP, in additional to what other people told you, the main issue in your code is that equals doesn't handle null values and will throw an exception.
Also, equals is supposed to return true only if both values have the same class so an animal cannot be equal to a human. With instanceof T you are checking if the right hand side is T or derived from T.
phar
Profile Joined August 2011
United States1080 Posts
September 11 2016 03:25 GMT
#15216
Ideally you never construct a new struct-like class yourself and just use some autogens like AutoValue.
Who after all is today speaking about the destruction of the Armenians?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
September 11 2016 04:21 GMT
#15217
Also you don't have to make getters and setters unless you need to control access. Just make the members public.
There is no one like you in the universe.
Wrath
Profile Blog Joined July 2014
3174 Posts
September 11 2016 05:44 GMT
#15218
On September 11 2016 11:11 Manit0u wrote:
Show nested quote +
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...
teamamerica
Profile Blog Joined July 2010
United States958 Posts
September 11 2016 06:19 GMT
#15219
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.


On September 11 2016 14:44 Wrath wrote:
Show nested quote +
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.
RIP GOMTV. RIP PROLEAGUE.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
September 11 2016 07:31 GMT
#15220
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?
If you have a good reason to disagree with the above, please tell me. Thank you.
Prev 1 759 760 761 762 763 1032 Next
Please log in or register to reply.
Live Events Refresh
Wardi Open
12:00
#60
WardiTV2250
IndyStarCraft 228
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 235
UpATreeSC 87
StarCraft: Brood War
Rain 3549
Horang2 1587
Shuttle 779
firebathero 160
scan(afreeca) 52
sSak 37
Mong 30
Aegong 22
JulyZerg 17
ivOry 6
[ Show more ]
SilentControl 5
Dota 2
Gorgc5362
qojqva3580
420jenkins277
BananaSlamJamma178
XcaliburYe153
League of Legends
rGuardiaN20
Counter-Strike
fl0m572
byalli525
Other Games
FrodaN1033
Beastyqt715
ceh9567
KnowMe280
Lowko263
Sick257
Hui .188
Mew2King150
Liquid`VortiX147
ArmadaUGS79
QueenE48
Trikslyr46
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• kabyraGe 105
• Reevou 1
• IndyKCrew
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• Kozan
StarCraft: Brood War
• Michael_bg 9
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV218
League of Legends
• Nemesis3571
• TFBlade957
• imaqtpie471
Other Games
• Shiphtur284
Upcoming Events
Replay Cast
4h 44m
WardiTV Korean Royale
17h 44m
OSC
22h 44m
Replay Cast
1d 4h
Replay Cast
1d 14h
Kung Fu Cup
1d 17h
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
2 days
The PondCast
2 days
RSL Revival
2 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
2 days
[ Show More ]
WardiTV Korean Royale
2 days
PiGosaur Monday
3 days
RSL Revival
3 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
3 days
CranKy Ducklings
4 days
RSL Revival
4 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
4 days
BSL 21
5 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
5 days
RSL Revival
5 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
5 days
WardiTV Korean Royale
5 days
BSL 21
6 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
Wardi Open
6 days
Monday Night Weeklies
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
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
BLAST Rivals Fall 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.