Is the "object model" inherently flawed?
What went wrong?
Other urls found in this thread:
harmful.cat-v.org
harmful.cat-v.org
twitter.com
C-fags are inherently flawed
It's POO.
Nothing wrong with it
using System;
namespace Love
{
public class Person
{
string name;
public void love(Person someone)
{
Console.Write(name + " loves " + someone.name);
}
public Person(string name)
{
this.name = name;
}
}
class Program
{
static void Main(string[] args)
{
Person i = new Person("i");
Person you = new Person("you");
i.love(you);
}
}
}
Tell me this isn't beautiful
Why love method is camelCase and not PascalCase?
If the function had been private (which it should have been), the case would be correct.
I never argue about the case or the names of private methods. Private is private.
Stop hating on my quiet public love then. I never liked announcing my love loudly faggot.
I have never found an excuse to actually use it, even in languages with OOP support.
99% of the time structs are enough to do anything you want.
I can hear the curry running down your fat stomach from here
C is best language, everything else is a useless abstraction
I prefer __pAjeet-CasE
It's sort of a trade off. Thinking of solving problems is usually a good first step, but you something do so at the cost of being over verbose. It's a popular method to think about structuring problems.
Actually, yes, and I'm not memeing. In programming you have functions and non-functions as data. Functions can be called with non-functions or functions as arguments. What OOP does, is it ties functions to one of their parameters. For instance in a.function(b, c), the parameter a is given a special treatment. But why should that happen? Why couldn't you just call functions normally? What makes one of the parameters special? There's no logical justification for the practice.
It hurts, because a lot of people use that case.
It's grouping of information.
>i don't know how to program very well
> he fell for the object meme is a better way to programming
>he doesn't use design patterns
You can group it by just putting related functions inside modules however you feel like. Still, it's arbitrary.
I can hear the curry running down your fat stomach from here
Assembly is best language, everything else is a useless abstraction
OOP is a good way to structure your program.
Even if you don't like it personally, it is used a lot of places and you should know it and understand it.
Not all applications benefit from this, but a lot of them do.
It makes it easier to interface different parts and it allows for people to split the task of planning, implementing and using.
Having a plan is always a good thing.
Using a template for a plan is good as long as you allow yourself to adapt.
The inherit flaw with any ideology is that there is no true Scotsman. Any example of a failure means that they didn't implement it correctly or something along those lines, so arguing about whether a modeling ideology is flawed, look if there is examples of when it is good and judge it by that.
If you do not like the examples of when it is supposedly good, then it is flawed.
In my language OOP is called "POO" and I always remember the poo in loo meme
>"i loves you"
Good job pajeet.
Now replace 'i' for something else and try it.
Person No_one_can = new Person("No one")
No_one_can.love.()
package main
import "fmt"
type Person struct {
name string
}
func (s Person) say(r Person) {
fmt.Printf("%v loves %v\n", s.name, r.name)
}
func main() {
i := Person{"I"}
you := Person{"you"}
i.say(you)
}
Tell me this isn't beautiful
...
is this go? looks fucking retarded
Yeah that looks dumb
the right one is actually java, not oop in general
>Declare functions not like in oop
>Call them like in oop
Why?
Even in java you don't have to write like this. This is enterprise style retarded spaghetti type coding that pajeets do.
exactly, people hate oop because of pajeet shit code
Yes, and so is every paradigm. There are also huge inherent flaws in functional programming (slow and lack of the ability to express program state), and procedural (hard to scale and maintain). But regardless if you know what your doing then any paradigm can be used in a practical and effective way.
horrible cache safety and inevitable leaky abstractions.
it's a bad model.
>C is best language
walking is the best form of transportation
>oAnimal
>legs=0
horrible example of OOP
oAnimal should be an interface with getLegs() and getBrain() methods.
the problem is pop culture
>design patterns
see
You have no idea how much going through useless hoops like that triggers me.
People don't know how touse it properly. Instead of going for emergent design they over design everything and create dependencies when they are not needed. Why are you inheriting that class? Can't you just make a separate class and call the functions you need? Probably with OOP is that it gets overdone
>Not all applications benefit from this, but a lot of them do.
Such as GUI libraries, and.... what else?
>It makes it easier to interface different parts and it allows for people to split the task of planning, implementing and using.
Functional programming languages have interfaces too. In fact, functional programming style data declarations (variants, pattern matching based) make it easier to plan how an implementation is going to look before you even write it.
>Having a plan is always a good thing.
Opponents of OOP claim that OOP leads to premature over-specification that will bite you in the ass.
>Using a template for a plan is good as long as you allow yourself to adapt.
This is in no way specific to OOP.
>The inherit flaw with any ideology is that there is no true Scotsman.
Very true. However a simpler approach to programming means that it's easy to do things "correctly"
If OOP is so bad why is so much software written in it? Why would companies hurt themselves by making products on inefficient technologies? Wouldn't one company be able to take massive advantage by choosing some other paradigm like functional?
Sometimes I think Sup Forums just hates shit that's mainstream and popular like some kind of weird annoying hipster.
OOP isn't used necessarily because it produces the best programs. It's used because it's easier and makes more sense to programmers that haven't had a whole lot of training invested into them.
The best programs would be written directly in assembly. They would be fast as hell and would would still work on operating systems released decades later. But if you're a company you need to compromise on stuff like that, so they use OOP.
>harmful.cat-v.org
The Dijkstra quote is fabricated. And quoting Carmack is a bit weird since he also said that if you don't see the value of oop for things like ui you're a luddite.
// which is it?
nail.insert(plank)
plank.insert(nail)
// it's neither
insert(plank, nail)
Yeah, I wouldn't take anything on cat-v too seriously.
>what else?
Pretty much anything you can split into semi-discrete parts. Games, pretty much any type of web-application, online storefronts, search engines. Basically anything.
It's a big hammer: It's not necessarily best for things that need a sharp knife, or a surgeon's hand, but a lot of tough problems can be solved by a big hammer.
>Functional programming works
Yup.
>Opponents of OOP claim that OOP leads to premature over-specification that will bite you in the ass.
Okay, I'll argue with those guys. Lemme know if you see any.
>This is in no way specific to OOP.
Yup.
>Very true. However a simpler approach to programming means that it's easy to do things "correctly"
Until you realize that there were costs to the simple choices that make it harder to grow with lots of people.
This is, by analogy, the reason people care about time complexity: its use basically doesn't matter for small cases; when you've got n=50 things to manipulate, just fucking do it however, no one cares. It's when you have n=10^10 things, that's when how fast things are really matters.
Object oriented programming is for the second case, for projects of sufficient complexity organizationally (>1000 people over decades, rather than several hundred or less) because if you let enough people do things "simply", things become an ad-hoc mess of functions without shared and generalized interfaces, code duplication, and generally grinds huge projects to a halt while people try to figure out how the fuck all the interrelated functions work.
OOP at its core is a tool to mentally manage that complexity by limiting the scope of ways to interact with the codebase and the number of things you need to keep in your head at any time. More often than not it helps. This is why big tech companies use it.
You can do all 3 with C#
Interesting. I'm not a C# expert, but does it simply allow you to call object methods as if they were free functions by placing the object as the first parameter?
Get on with the times grandpa.
namespace Love
{
public class Person
{
string name;
public Person(string name) => this.name = name;
public void love(Person someone) => Console.WriteLine($"{name} loves {someone.name}");
public static implicit operator Person(string name) => new Person(name);
}
class Program
{
static void Main(string[] args) => new Person("i").love("you");
}
}
It can be a useful pattern but people who use it exclusively create abominations
Makes sense
No, but it provides enough sugar to do pretty much anything you want.
Checked!
Oh, kinda shame still
But you'd have to name it
plank_insert(plank, nail)
to avoid collision with insert methods for other types.
Thank you for posting this hilarious comic!
Well, there are 2 ways to go about what you want in C#, write all your methods as extensions, or use reflection to get the method pointers, which then would require the object on which to invoke the method as the first parameter.
OOP is in fact *human* oriented programming in how it lets the programmer reflect human perception of reality in their code. Some say it helps large projects be more manageable and come to reality faster, which is mostly what sales and management want. I don't like how OOP makes writing compilers way more difficult due to the addition of new, complicated optimization scenarios. I suppose though that finding less autistic people for hiring as developers is cheaper and for that reason people will long for the easier way.
The procedural approach is more raw and abstract in how it practically only provides the fundamental means for defining algorithms, like arithmetics, functions/procedures, etc. In a language like C, we also have structures which let us avoid long function parameter lists, save memory and time spent on creating local copies of a function's parameters and organise large sets of tightly related variables. They differ from classes and their objects in the lack of inheritance, public/private keywords, compile-time OOP data structures (like vtables) and some other things. I love C, it's elegant and has basically everything I need. I find writing in it very rewarding.
Just to illustrate, the static Insert() method is an infinite loop.
It should be plank = insert(plank, nail);
Gotta put it in its own module
Oh, extension methods seem nice for this. It's probably a hack to use them, but it would serve the purpose. Dat reflection tho.
Why would it _have_ to be?
Too much noise, this is better:
nail plank insert
Reminder.
If you give "insert" the discretion of assigning the result, you remove the choice of passing the result onto a different variable. Maybe you want plank to remain unnailed, but you want to create a new plank that's like the first plank, but nailed. Maybe you just want to evaluate the nailed plank without actually nailing it. Etc.
OOP is shit, I agree.
>what are static funtions
>what is building class libraries where the same object contains its parameters and the functions to work on the object itselfs
>what is the possibility to acces private proprierties of an object just with a function
yeah, no, your answer is shit
Has anyone here who makes fun of OOP ever held a job making front-end software that had any relevance to any market whatsoever?
...
That's a separate issue from how the function/method is called. If you go with copying a la functional programming, you should also not be using variables but constants, so you'd do
newPlank = insert(plank, nail)
really cool meme memester. you get a score of meme/meme
You can't compare C to walking as walking is the safest form of transportation while C is the least safe language.
>>what are static funtions
The best type of functions
>>what is building class libraries where the same object contains its parameters and the functions to work on the object itselfs
A module does the same thing
>>what is the possibility to acces private proprierties of an object just with a function
You really don't need to hide data. If you have a collection of methods to operate on plain records, its the users fault if he messes with the raw data in ways he shouldn't.
Why the hostility?
>what else?
I don't know if it's relevant, but the programming challenge "program an Enigma clone" considered "hard" in the Sup Forums programming roulette took me half a day by heavily relying on OOP.
Implementing:
-the object "disk" to mimic the disks of the enigma machine, which had as properties the switching pattern and the initial position
-the object "enigma" which proprieties are 3 different disks objects and their order
-having the disk contain the function simulating the passage of current from one entrance of the disk to the curresponding exit
-having enigma contain the method to simulate the physical action of the disk rotation
Literally half a day, plus half an hour for the gui.
I don't know how long it would have taken and how ugly the code would have been with functional programming.
Statistically speaking, you're dead wrong. Way more people are killed walking and being struck by cars or attacked by animals than people are killed by airplanes every year.
>dragon
looks like a kite to me
Sure, you just need to define the function as static in the class.
E.g. I make a class cls_math, and in that class I make a method Add
public static int Add(int a, int b)
{
return a+b;
}
then I can just call it with
int x = 1;
int y = 2;
int c = cls_Math.Add(x,y);
You just need to add the static part when writing the method.
Get on my level..
class Person
def initialize() @i = "" end
def to_s() @i end
def method_missing(i)
@i
yes, you can define methods that way, and use them as if they were part of the object. It's called extension methods.
Oh wait, this version is better:
class Person
def initialize() @i = "" end
def to_ary() [@i] end
def method_missing(i)
@i
>222
>222
C# and Ruby confirmed for same power level.
Well, both are shit
(;__;)
You must be either a LISP or C guy.
/thread
You mean like this?
public class Thing {
private string str;
public Thing(string str) {
this.str = str;
}
public void print() {
Console.WriteLine(str);
}
}
Thing t = new Thing("fuck");
t.print(); // normal
print(t); // what you mean
Literally reversed POO
It's fine the problem is that it doesn't play well with concurrency and asynchronous patterns.
The problem is the pajeets trying to sell you Java 8 is good for concurrency
Is so hard to figure out that nobody can even do it correctly
OOP is a meme
In other languages it's called dragon
Agree. Busfags kys.
OOP is good but only when it's used correctly and sparingly, i.e. only when it improves code readability. Fuck Java and other such shit tier OOP languages for making EVERYTHING an object, though. There's no fucking need for that and it completely fucks up the way programmers approach problems. Instead of thinking about how to actually solve it they think about how their class diagram should look.
Java should've done it like C++ does and not enforce OOP on EVERYTHING but simply provide it as an available tool, as it should be.
You literally can not make a complex, full-featured software without OOP.
What are static class
kek
a needlessly verbose language construct?
What about OOLO?
#include "math.h" // C++
using static Math; // C#
where Math is a static class containing math functions.
How are those 2 different?
That's a work-around. It's like pissing on someone and then proudly handing them a poncho to protect them from your piss. Point is you shouldn't have been pissing on him in the first place.
You definitely can, but that's not the point. I said OOP is good. It's just that some languages and a lot of programmers go full retard with it, which is wrong.
one will give you segfaults