• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:35
CEST 17:35
KST 00:35
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL62Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event21Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays FEL Cracov 2025 (July 27) - $8000 live event Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL SC uni coach streams logging into betting site Flash Announces Hiatus From ASL Practice Partners (Official) ASL20 Preliminary Maps
Tourneys
CSL Xiamen International Invitational [BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Summer Games Done Quick 2025! Trading/Investing Thread Things Aren’t Peaceful in Palestine
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 645 users

The Big Programming Thread - Page 761

Forum Index > General Forum
Post a Reply
Prev 1 759 760 761 762 763 1031 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
Spain17971 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
Poland17243 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 1031 Next
Please log in or register to reply.
Live Events Refresh
FEL
12:00
Cracov 2025: Qualifier #2
CranKy Ducklings603
IndyStarCraft 331
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 340
IndyStarCraft 331
Hui .221
StarCraft: Brood War
Calm 4761
Rain 2555
Shuttle 1433
Horang2 1336
EffOrt 956
Bisu 925
Jaedong 739
Hyuk 377
Mini 376
Stork 328
[ Show more ]
TY 297
GuemChi 197
Soma 131
ToSsGirL 121
hero 121
Barracks 96
Hyun 83
Sacsri 78
PianO 55
GoRush 47
Free 28
Terrorterran 27
HiyA 9
ivOry 4
sas.Sziky 1
Stormgate
TKL 285
Dota 2
qojqva3338
Fuzer 345
canceldota274
LuMiX1
League of Legends
singsing3133
Counter-Strike
byalli279
edward69
Super Smash Bros
Chillindude54
Heroes of the Storm
Khaldor648
Liquid`Hasu443
Other Games
Gorgc3373
B2W.Neo1540
FrodaN1190
ArmadaUGS99
KnowMe75
Organizations
Other Games
EGCTV1265
StarCraft: Brood War
Kim Chul Min (afreeca) 10
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• StrangeGG 74
• Adnapsc2 13
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3735
• WagamamaTV767
• Ler138
Upcoming Events
BSL: ProLeague
2h 25m
Dewalt vs Bonyth
Replay Cast
1d 8h
Sparkling Tuna Cup
1d 18h
WardiTV European League
2 days
The PondCast
2 days
Replay Cast
3 days
RSL Revival
3 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
4 days
RSL Revival
4 days
Classic vs Cure
FEL
5 days
[ Show More ]
RSL Revival
5 days
FEL
5 days
FEL
6 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
FEL
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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.