Object Oriented programming is great when it comes to dealing with relatively complex datasets and structure as it makes it easy to keep organized and write clean code with less lines.
HOWEVER, there is several things that are really f*** up and in all OO languages I've learn (C++, Java and Javascript so far), and I'm surprised nobody fixed this.
1) Constructors.
In at least 90% of the cases it will look like this :
Honestly I feel so dumb every time I have to write something like this. Why can't this be done automatically ?
Like if you could do :
and it would automatically call the constructor with correct parameters. In addition, you could change the order and it won't screw things up.
2) calling methods related to an object is poorly worded
It's common to do things like this :
Why didn't anyone invent a .= operator so you could just write
This would look way cleaner. In this case it's allright because "str" is a short name, but if you do this with a complex name with already several "." in them (which is a common thing to do), it'll really make things more readable, as in :
3) Getters and setters
Those are not compulsory thanks god but apparently for some obscure reason they have been included in "good practice" by computer science teachers, so you'll encounter them as soon as you'll have to deal with someone else's code. What's the point, honneslty ? Why write :
When you could instead do :
Personally I'd say it's not good practice...
4) Function can only return one thing
It's not restricted to OO but to high level languages in general. For some reason computer scientists used to decide that two kinds of subroutines exists, "procedures" which doesn't return anything, and "function" which returns a value.
What if I want to return multiple things ? Well the answer is : "You should make an object with those two values and return it". In other words "go to hell, declare a new class and a new constructor just for this, at least 10-15 lines of code, when it could be done in 1 if the language was better made".
So sorry for complaining here but I have to share my anger with someone.
HOWEVER, there is several things that are really f*** up and in all OO languages I've learn (C++, Java and Javascript so far), and I'm surprised nobody fixed this.
1) Constructors.
In at least 90% of the cases it will look like this :
Code:
constructor(string name, int age, string address, boolean male)
{
this.name = name;
this.age = age;
this.address = address;
this.male = male;
}
{
this.name = name;
this.age = age;
this.address = address;
this.male = male;
}
Honestly I feel so dumb every time I have to write something like this. Why can't this be done automatically ?
Like if you could do :
Code:
Person = new person(name = 'John', age = '99', address = 'somewhere', male = 'true');
and it would automatically call the constructor with correct parameters. In addition, you could change the order and it won't screw things up.
2) calling methods related to an object is poorly worded
It's common to do things like this :
Code:
String str = "Hello guys what's up ?";
[...]
str = str.substring(3, 4);
[...]
str = str.substring(3, 4);
Why didn't anyone invent a .= operator so you could just write
Code:
str .= substring(3, 4);
This would look way cleaner. In this case it's allright because "str" is a short name, but if you do this with a complex name with already several "." in them (which is a common thing to do), it'll really make things more readable, as in :
Code:
group.person.get(i).name .= substring(3, 4);
3) Getters and setters
Those are not compulsory thanks god but apparently for some obscure reason they have been included in "good practice" by computer science teachers, so you'll encounter them as soon as you'll have to deal with someone else's code. What's the point, honneslty ? Why write :
Code:
person.get(name)
When you could instead do :
Code:
person.name
Personally I'd say it's not good practice...
4) Function can only return one thing
It's not restricted to OO but to high level languages in general. For some reason computer scientists used to decide that two kinds of subroutines exists, "procedures" which doesn't return anything, and "function" which returns a value.
What if I want to return multiple things ? Well the answer is : "You should make an object with those two values and return it". In other words "go to hell, declare a new class and a new constructor just for this, at least 10-15 lines of code, when it could be done in 1 if the language was better made".
So sorry for complaining here but I have to share my anger with someone.