[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
OOP meme
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 19
File: Q0vFcHd.png (152 KB, 1948x858) Image search: [Google]
Q0vFcHd.png
152 KB, 1948x858
So when did you grow up of OOP?
>>
when I looked at functional code and realised how retarded OOP was in comparison
>>
There is no programming language, no paradigm, no framework, no methodology that is ideal for all projects.

OOP is perfect for certain projects, and useless for others. The same goes for literally everything else.

The only thing anyone needs to "grow out" of is the idea that they can pick and learn one language-to-end-all-languages, paradigm-to-end-all-paradigms, etc and do everything with that. You cannot. If you try- and many do- you will fail to produce a good, performant, readable, extensible, maintainable codebase.
>>
I grew up out of programming in general.
Back in the days you had to be smart and knowledgeable but now we invented enough tool for monkies to program, so it's a job for monkies.
>>
>>54816920
this
>>
I was doing an animation library.
I started by setting up a clusterfuck of OOP hierarchies like I've taught all my life, but them something clicked inside my head, I trashed it all and rewritten it using only funcions.
The result was a clean, elegant, flexible, highly readable, highly testable awesomes with almost 10 times less sloc than the OOP bullshit.
Since then I'm hooked.

>>54816938
Give me an example where you think OOP is the best choice.
>>
>>54816779
Every programming paradigm can be used in a poor and overly complex manner. It just so happens that most people who program in oop languages do it in a very poor way. Also, what this guy said >>54816938
>>
>>54817144
What programming language?
>>
>>54817144
Game engine
Show me commercial game engine that is not build with OOP in mind from the ground up
Source: I am an engine dev for one of the biggest mmorpg developers.
>>
>>54818116
>Source: I am an engine dev for one of the biggest mmorpg developers.
No you're not
>>
>>54818111
Whichever.
>>
>>54818177
I don't need to prove anything to some fucking NEET from the internet.
>>
>>54818116
> I am an engine dev for one of the biggest mmorpg developers.
No you're not. Gamedev community is bashing OOP for the last several years, trying to move to things like EBD.
>>
>>54818198
Yeah, you don't need to prove anything you can't prove. Nice assumptions too
>>
>>54818198
Lol you're the one who tried to qualify your statement with some made up crap to impress anonymous internet people but somehow everyone else is the NEET. Sounds like you're projecting.
>>
>>54818059
Yeah, when you present all the arguments to the oopfag's face he falls back to this position "well surely there's a domain where an OOP is the only possible solution"
Except no oop fag has been able to show me such a domain.
>>
>>54818216
What's EBD?
I thought Entity Component System
>>
>>54818216
>trying to move to things like EBD.
>trying
and where did you read about that? I'll give you a tip: Mike Acton does not speak for the whole industry. My company still develops using in-house made engine which makes heavy use of OOP and the previous gamedev company that I used to work at used UE which is not much different.
>>
>>54818255
Call it Entity Oriented Programming or however you like, you understood what I'm talking about.
That's not the point, though. The point is that gamedev is actively seeking a way out of OOP.
I remember reading some years ago some article about a former Blizzard employee that coded Starcraft: BW, and he was telling how they did it in an OOP way because it was the hot shit at the time, and the disaster that ensued.
Let me try googling it.
>>
I have never used OO. It is spaghetti code garbage used by idiot "code designers" that think abstract design is more important than simplicity and functionality.
>>
>>54818329
There's much more "spaghetti code garbage" in non-OOP projects (like linux kernel) than there is in well-thought oop projects. Fucking semen, looking for an excuse for the messed up, unmaintenable shit they call code.
>>
>>54818370
>linux kernel
If you think the Linux kernel is spaghetti code, you've never seen spaghetti code. Jesus, kids, please actually know your shit before commenting and pretending you do.
>>
>>54818301
>EBD
>I don't know what I'm talking about so I will mention blizzard employee blog post about how they did fuck up by not knowing how to design and implement software in oop manner.
TOP KEK
>>
>ITT : retards think the linux kernel is spaghetti code
>>
>>54818291
>my company
Well let me take a wild fucking guess, it's a not a very successful company, is it?

>The more of an IT flavor the job descriptions had, the less dangerous was the company. The safest kind were the ones that wanted Oracle experience. You never had to worry about those. You were also safe if they said they wanted C++ or Java developers. If they wanted Perl or Python programmers, that would be a bit frightening. If I had ever seen a job posting looking for Lisp hackers, I would have been really worried.
>>
>>54816779
Java is by far the worst OOP IN LOO language though.
At least use something decent as a comparison.
>>
>>54818430
>Well let me take a wild fucking guess, it's a not a very successful company, is it?
Well you're wrong.
>>
>>54818448
Which language has a good OOP implementation in your opinion?

>>54818478
Surely you can at least give your company's name? That won't deanonomize you. Or will you fall back to your
>hurr durr i don't have to prove shit herp derp neets derp derp
bullshit?
>>
>>54816979
Plot twist: he's 15
>>
>>54818505
Not him but Go has a pretty good one.
No inheritance, structurally typed interfaces, methods are merely functions attached to structs and work as special syntax for stateful operations, type embedding and only package-private encapsulation.
In Go people use OOP when state needs to be encapsulated, and that's about it. Not for everything, only for encapsulating state.
>>
>>54818505
>Which language has a good OOP implementation in your opinion?
Python. Unfortunately people learn maybe 25% of the language and then conclude that it's shit.

There are a couple things I dislike about it (like how special method lookup ignores instance attributes, it does that for a reason but you'd think they could find a better way). But ultimately, things like metaclasses and descriptors really make it a good language.
>>
>>54818370
>Linux kernel
>Spaghetti code
Kek
>>
>>54816920
this
>>
Why the fuck do you care so much about someone's job? Do you want to get to him to suck his fucking cock?
>>
>>54818639
>>54818505
>>
>>54818370
Nice b8
>>
>>54816779
I never fell for it. I've fallen for the multi-paradigm meme though.
>>
>>54818569
Encapsulating state is the first and biggest bullshit of OOP. With encapsulation you do not get rid of the state, you just make it less accessible, but you still have to worry about it. Whenever you send a message to an object you're potentially modifying state.

>>54818618
How is Python OOP different from Java? Multiple inheritance? You know not only multiple but regular inheritance is considered harmful and even OOP apologets advise to you the facade or some similar pattern instead of inheritance?

>>54818639
Nice samefagging, kiddo.
>>
File: 1452287302297.jpg (7 KB, 250x236) Image search: [Google]
1452287302297.jpg
7 KB, 250x236
>>54818448
>OOP IN LOO

Majestic
>>
>>54818679
>Whenever you send a message to an object you're potentially modifying state.
>what is const
>>
>>54818701
I don't even...
>>
>>54818769
clearly you don't
>>
>>54818679
>you just make it less accessible
yes that's the point
you know why people tried to abolish state in the first place, right?
because firstly it's harder to follow control flow involving state (especially global state, local state isn't that much of an issue), secondly because state opens up lots of possibilities for invariances.
encapsulation reduces the damage of the second issue by encapsulating state in a way that reduces invariances for the public API.
when you've got scope in your language then that's some sort of encapsulation. scope reduces name collisions and possible invariances. EVERY relevant language has this, because working without *any* kind of encapsulation would be extremely painful.

of course you should reduce state as much as possible, but you cannot get rid of all state, "necessary" state (as defined by tarpit) exists.
>>
>>54818679
I've noticed something funny.
About 90% of people that bash oop didn't even take part in development of anything larger than fizzbuzz-tier programs, they don't know how and when apply design patterns and are shit programmers overall.

Welp, I guess this description fits most of c programmers.
>>
>>54818801
Yes, I know why people tried to abolish the state, my point is OOP doesn't simplify state, it often makes it even worse. And it's not as much state as its mutability.
>>
>>54818848
Google Paul Graham's pyramid and take a wild fucking guess where exactly your post would be situated on it
>>
>>54816779
Shouldn't both oHuman & oPet have ``legs = 0;''? I mean a oSnek has 0 legs, a oDumburd has 2, and a oMikeCoots has 1.
Is that the joke?
>>
>>54818679
>How is Python OOP different from Java
Classes are first-class objects.
The can be modified on the fly like any other object, or generated dynamically.
Classes themselves have a class, called the metaclass. By default, it is 'type', but you can make a subclass of type and use that to construct a class. A common use of that would be to track every class and subclass made from that metaclass, so that a DB table can be made for each class you want to store instances for.

Instances are very bare. If you define something on the class, the instance doesn't actually keep track of that. A variable only gets put in the instance dictionary once the instance assigns a value to it. This allows for things like modifying class attributes after creating instances, or even changing existing instances to other classes.

Descriptors are also nice. Everyone uses descriptors without even knowing it, since that's how object methods are implemented. @property is the simplest one, which lets you convert a plain attribute to a getter/setter pair without breaking anything.

Then there's stuff like __instancecheck__ and __subclasshook__ that let you override the behavior of isinstance() and issubclass(), allowing you to do duck typing while still using the easier to read and understand inheritance-based typing.

There's a lot more. You can learn something about python every day but still never know it all.
>>
>>54818921
Yepp, that's when your manager tells you you need to implement the feature ``oSnek'', and you realize you'll have to rewrite the whole fucking hierarchy to make it happen. That's basically OOP in a nutshell.
>>
Encapsulation can only ever be sufficient to control state if you also have linearity, where every object is owned by at most one other object (or the main function). This forces you to structure your entire program as a tree, where objects have to propagate messages up and down the tree in various ways to get anything done. So why not just have a linear type system in the first place, but make it more powerful, in that you can have either a unique, mutable reference (or the object itself) or N immutable references, like in Rust?

OOP failed at what it was designed to do: control mutation of state. It might still be alright as an abstraction tool in rare cases, but it's not something that needs to be a "paradigm" anymore.
>>
>>54818936
It's all just syntactic sugar. I thought you'd bring up something like Eiffel, or Smalltalk, or even CLOS.
>>
>>54818885
what you're saying is absolutely unrelated to mutability, though
encapsulation is useful in *any* regard, especially to reduce name collisions
it allowing you to reduce mutability state invariances for necessary state is just a strong bonus

sure, when people start applying OOP to everything it's gonna be shit because they're intentionally causing state where none needs to be, but that's the fault of education trying to force OOP into every problem, not of encapsulation
>>
>>54819076
You're basically describing modules. No one is arguing against modules, they're just common sense. No one in their sane mind would put state in their modules, though.
Well, maybe except for Java developers, takes a special kind of retard to decide that module = class and design a whole fucking language around that idea.

Well, I guess
>The phrase "object-oriented” means a lot of things. Half are obvious, and the other half are mistakes.
>>
>>54818116
The only time I would say OOP is alright for a game engine is having an interface like IVertexBuffer and then implementing it with D3DVertexBuffer, GLVertexBuffer, etc. Because you won't be using the different implementations at the same time, the cost of virtual method calls is avoided through branch prediction.

Otherwise, no, OOP isn't any more useful for game engines than it is anywhere else. And it's not very useful anywhere else. I guarantee that if you started writing in something like Rust, which solves the problem OOP tried to solve (control over state mutation) in a much better way, while having niceties like a decent module system and method syntax for procedural programming, you'd never go back.
>>
>>54816779
the underlying implementation doesn't matter. do you even abstraction mate
>>
>>54819076
Encapsulation doesn't have anything to do with name collisions. It's about hiding the field or method, not putting them in a "namespace".
>>
was:
>int a
became
>class Bullshit{
>private int a;
>public set(){}
>public get(){}
>}

Hey, everybody! I've just solved our state problem!
>>
>>54818111
Java
>>
>>54818301
If you find the article, I'd like a link.
>>
>>54816779
>take original picture
>copy it over
>add a bunch of THROW THROW THROW EXCEPTIONLOGGING
>call it what OOP really looks like

So you're saying OOP users claim to never use exception handling when they actually do?
>>
File: image.jpg (28 KB, 254x204) Image search: [Google]
image.jpg
28 KB, 254x204
>>54819151
How would you build a module in ?Java without classes? Not trying to call you out, just genuinely curious
>>
>>54819284
Does you boyfriend like to fuck you in the eyesockets? Didn't you notice anything else except the throws?
Exceptions are an exception-ally(get it? get it?) bad idea, too, but that's another matter.
>>
>>54819214
mate you forgot to implement the IBullshit interface
>>
when I realized what OOP backwards spells
>>
>>54816779
Lotsa ISomethingable and duck typing is the best way.
>>
>>54819337
OOL NI OOP!!!
>>
>>54818848
I'm sure you know more about big projects than Mike Acton :)
>>
#define private public
#define protected public

Thank me later.
>>
>>54819276
Found it! http://www.codeofhonor.com/blog/tough-times-on-the-road-to-starcraft
>>
>>54818689
Well it is Pure Object Oriented Programming, better known by its acronym
>>
>>54819325
You can't. That's my point.
>>
>>54819325
You can't.

You can VERY LOOSELY think of a module as a class with only static members that can't be initialized into an object. They're more powerful than, say, a namespace in C++, though, because they can be used to encapsulate as well. Languages like OCaml have metaprogramming with modules too, but I won't get into that.
>>
File: image.jpg (138 KB, 955x708) Image search: [Google]
image.jpg
138 KB, 955x708
>>54819412
Java pleb here again

How do other languages organize modules, aside from classes?
>>
>>54819446
What do you mean ``organize''? A module is usually just a file hidden from outside world and you specify what to export(show to the outside world) from it.
Check Haskell, ELM, Python, even JS has them now.
>>
>>54819446
structs?
>>
>>54818639
Because he's using his job to lend weight to his point.
>>
>>54819333
Kek, you're right. Also BullshitChangeListener
>>
File: image.jpg (63 KB, 628x447) Image search: [Google]
image.jpg
63 KB, 628x447
>>54819483
I said "organize" but it just as well could have been create, implement, etc, I'm sure you get the picture.

That makes more sense now, I think I get your OP. Java forces modules to dress as classes whether it really is necessary or not. I can understand why that is a disadvantage
>>
>>54816779
Yeah fuck OOP so much.

I'm doing an employee management system for school. This MVC shit is a mess.
>>
>>54819554
Yes, that's what I meant. I also leads to one-method ``doer'' classes, like MessageSender, BullshitDoer, onShitHappennedListener which shouldn't be classes in the first place.
>>
>>54819565
Condolences, bro. I like how the industry is just trying to patch this OOP bullshit with patterns, which only makes it worse, instead of just acknowledging the fact that the King is naked.
>>
>>54819587
That's more a failure of nominal typing vs. structural typing. Interfaces are really just types, and an object that "implements" the interface inhabits the type (with its full type as a subtype of the interface). Just look at how OCaml does its OOP.
>>
File: image.jpg (37 KB, 625x415) Image search: [Google]
image.jpg
37 KB, 625x415
>>54819587
I've made classes like that too many times to count. I thought the single-method megaclasses from our Panjeets were bad, but now I realize my code is shit too. I think you just redpilled me on my choice of language and by extension the basis of my career
>>
>>54819642
No, I meant like classes-classes, not interfaces. How many times did you find yourself doing something like:

>BullshitDoer bullshitDoer = new Bullshit()
>bullshitDoer.doBullshit()

That's what I call one-method ``doer'' classes.
>>
>>54819698
Oh, I see. Yeah, the fact that Java has lambdas but you still have to use them with "functional interfaces" is just silly.
>>
>>54816920
this
>>
>>54819687
Try Haskell, Erlang, Elixir. If it's too unusual try ELM, it's like Haskell-lite.
But those languages are virtually unemployable, you'll have to write/maintain OOP for a living and wait about 5-10 years until FP becomes the mainstream for the industry.
You can decrease the entropy by opting for the FP paradigm instead of OOP paradigm if you're writing in a multi-paradigm language. You can even do FP in JS, lol.
I Java, though, it's either OOP or procedural programming, some people told me even procedural programming is better than OOP, but I'm not that sure.
>>
>>54818911
Interesting read I guess
>>
>>54819446
A python module is basically just an object, and every variable defined in the module becomes an attribute of that object.
However, a module can find its own entry in sys.modules and replace that with an object of its choosing, allowing a module to expose itself as something other than a module.
In NodeJS, you have to manually export stuff, by stuffing it into module.exports.
>>
File: reactive-boring.png (492 KB, 1200x1941) Image search: [Google]
reactive-boring.png
492 KB, 1200x1941
>OOP
>Literally poo spelled backwards
I still struggle to find a practical use for it.
Are there even any?
>>
>>54819384
Did you even read the article? He was complaining about the implementation
>>
>>54820851
Yes, I've read it, but it was a long time ago.
>>
>>54820891
Looking over it he doesn't sound like he is complaining about oop, but how the teams implemented inheritance.

I do C, mainly C++, and little C# at my job working with backend and custom raid servers, coming from a C only background. The company is very strict about how we code and I feel the C++ is very well done and have few complaints about oop. This is purely anecdotal of course
>>
>>54821087
Yes, I know, but he describes a lot of OOP related problems, only that he offers workarounds instead of just trashing OOP altogether. He didn't take the red pill, obviously.
>>
>>54816920
this
>>
>>54819587
But that's a good thing. What if you want to change the implementation of doBullshit()? If you don't have a class, you'd have to replace every single call to it in every single class that uses it. With a Bullshitter class, you just change a few lines in that class and every class that uses a Bullshitter will use the new implementation.
>>
>>54821461
What if you add new arguments to Bullshiter constructor? Or to the doBullshit method?
>>
>>54821518
the new constructor is easy. Just add a second constructor, and modify the original constructor to call the second constructor with a default value for the new argument.

The new doBullshitter is more difficult. I can't think of a solution - but it'll still take about as much work to change as it would if you had that method implemented in each class that uses it. Maybe even less, depending on how complex the implementation is.
>>
>>54821601
>you had that method implemented in each class that uses it
Who the fuck said anything about implementing it in each class that uses it?
>>
>>54821639
If you don't have a separate class for it, where else are you going to implement it?
>>
>>54821666
Well in a normal language it would just be a plain function.
That's the point, you can't have a plain function in Java, that's why you have to do all this doer class bullshit.
>>
File: 1383504924607.png (94 KB, 992x1856) Image search: [Google]
1383504924607.png
94 KB, 992x1856
>>54817143
>>54818626
>>54819739
>>54821170
samefag
>>
>>54821701
Then just make a public static method in a static class, dumbass. It's pretty much the same thing, but you still get to take advantage of the benefits of OOP.
>>
>>54821765
> benefits of OOP
Which are none
>>
>>54821791
Good joke. Have fun programming anything beyond a shitty calculator without state.
>>
>>54821836
Name benefits of OOP
>>
>>54821836
What about Linux kernel? Is it a shitty calculator without state?
>>
>>54816779
when more than half of my classes where somethingHandler
>>
>>54821836
>you can't have state without OOP
How do you think state was managed in the days before OOP? Of course, you're probably going to claim that OOP was used since the 50s, claiming arrays, structs, and so on as part of OOP, despite having nothing to do with what we call "OOP" today.
>>
So what's actually the purpose of a whateverFactory in java?
>>
>>54822195
Canonic example from the Quartet's book: suupose you're writting a crossplatform app, you have the baseclasses Button and Label, for each operating system you have those derrived into WButton, WLabel, LButton, LLabel, MButton, MLabel. You should only use the appropriate classes for each OS. Instead of doing

Button button;
if(isMac()) button = new MButton();
if(isWindows()) button = new WButton();
if(isLinux()) button = new LButton();


you'd have a UIFactor baseclass, being extended by a Windows factory, Linux factory and Mac fatory.

abstract class UIFactory(){
abstract Button getButton(){}
abstarct Label getLabel(){}
}

class WFactory extends UIFactory{
public Button getButton(){ return new WButton()}
public Label getLabel(){ return new WLabel()}
}


so that in your code you can avoid writing logic, and just do:

UIFactory factory = //somehow get the factory instance
Button button = factory.getButton();
Label label = factory.getLabel();


so that you can code while not caring about what platform is your app running on

In FP you'd just use higher order functions

//module's internal(private) stuff:
function mkWButton(){}//something something
function mkMButton(){}
function mkLButton(){}

//module's exportable stuff:
function getButtonMaker(){
if(isMac()) return mkMButton;
if(isWindows()) return mkWButton;
if(isLinux()) return mkLButton;
}


and in your code do:

let mkButton = getButtonMaker()
let button = mkButton()
>>
>>54818216
>Gamedev community is bashing OOP for the last several years

Source?
>>
>>54816920
OOP is retarded.. but the rest even more
>>
The problem with OOP is that, when asked "Johnny has an apply, Mary gives him two apples, how many apples does Johnny have?" an OOP monkey will rush to write classes for Mary, Johnny, the apples, and teh AppleList, together with IGiveable, IGiving and IReceiving
>>
>>54821836
This. The loudest complainers of OOP have never coded large programs before.
>>
>>54818413

http://harmful.cat-v.org/software/c++/linus
>>
File: faggot.png (27 KB, 350x176) Image search: [Google]
faggot.png
27 KB, 350x176
>>54821736
>>
File: 1450289962640.webm (2 MB, 500x281) Image search: [Google]
1450289962640.webm
2 MB, 500x281
Netbeans code is some clusterfuck java spaghetti code imho desu baka senpai.
>>
I shudder at the thought of making android apps without classes and objects.
>>
>>54823014
http://hg.netbeans.org/main/file/19ea5a2d03af/javascript.v8debug/src/org/netbeans/modules/javascript/v8debug/ScriptsHandler.java

http://hg.netbeans.org/main/file/19ea5a2d03af/javascript.v8debug/src/org/netbeans/modules/javascript/v8debug/V8Debugger.java

Is this even OOP?
>>
>>54822658
>you'd have a UIFactor baseclass, being extended by a Windows factory, Linux factory and Mac fatory.
Meh. I'd just override the 'new' method on the superclasses to actually instantiate the correct subclasses.

Oh wait. Most people here are using object systems where you can't do that. Carry on.
>>
>>54822863
Yeah, keep telling yourself that
>>
>>54822799
Lolno. They'd have a class Container and a class Apple. When more fruits or different types of holders were required, you might create interfaces or abstract classes. It only seems complicated because you don't understand the reason for all these complex design patterns. I will say that sometimes they are used when not needed, but they can be incredibly useful when you do need them.
>>
#!
>>
>>54823495
You forgot IGiveable, IGiving, IReceiving, IKeepable, IKeeping, ICountable.
Not even mentioning ConcreteAppleFactory < AbstractFruitFactory and AbstractChildrenFactory
>>
>ITT people never done projects bigger than fizzbuzz debating about how useful OOP is for a single file project

there are use cases its stupid to use OOP if it isnt necessary and over complicating things but if you want write duplicate code for every implementation and end up in a huge clusterfuck then be so
>>
>>54823547
Trolling aside, none of those are necessary, and in fact I'd argue they're detrimental by unnecessarily increasing the complexity, until the program becomes more complex than the scenario you laid out.
>>
>>54821130
The problems aren't with OOP though. They are with the programmers; he even quoted Stroustrup saying so, agreeing with him. People with a strong fundamental understanding of OOP who are dealing with properly designed and implemented code aren't spewing the shit that is seen in this thread.

I like /g/ and enjoy seeing people flame each other over bullshit and "facts" (same thing in this case), but it's sad to see people actually buying into the groupthink that builds from people's feelings
>>
>>54816920
functional programming languages are just toys
>>
>>54823875
Your penis is just a toy!
>>
>>54823674
Did it even occur to you that the solution to the Johnny and Marry problem is just 1 + 2?
You didn't get the joke, did you?
>>
>>54822799
Class Kid{
int apples = 0;
Kid(int apples){
this.apples = apples;
}

void addApples(int num){
apples += num;
}

void giveApples(Kid kid, int num){
if( apples < num ) throw FokOffException;
kid.addApples(num);
apples -= num;
}

void printApples(){
System.out.println("I have"+ apples + "apols");
}
}

Class Main{
main(int marys){
try{
Kid johny = new Kid(1);
Kid mary = new Kid(marys);
mary.giveApples(john, 2);
john.printApples();
}catch(FokOffException e){
System.out.println("OP is a faggot");
}
}
}


poo in the loo, my firend
>>
>>54819284
Exceptions are considered harmful.
Expected<T> masterrace
>>
>>54824427
typedef struct Kido{
int apples;
}Kid;

void giveApples(Kid* fromKid, Kid* toKid, int apps){
fromKid->apples -= apps;
toKid->apples += apps;
}

void printApples(Kid* kid){
printf("I have %d apols", kid->apples);
}

void main(int apps){
Kid* john = malloc(sizeof(Kid));;
Kid* mary = malloc(sizeof(Kid));;;
john->apples = 1;
mary->apples = apps;
/*strange things when apps < 2*/
giveApples(mary, john, 2);
printApples(john);
}


C style for comparison
>>
yesterday. but yeah, check this out.

the ancients studied shapes like squares, cubes, spheres, etc. and then derived numbers from that. today we are taught numbers first, which is a weird abstract concept to start with and changes your perspective on mathematics.

starting with oop is like starting with numbers. you dont understand why the numbers are the numbers.
>>
>>54817144
>Stuff That Never Happened
>The Post

What is it with babies who can't into OOP shitposting all day on /g/?

>hurr durr i have a clusterfuck of a hierarchy

Then you don't understand OOP.
>>
>>54816779
You don't grow out of OOP, you grow into it.
>>
>>54824872
Nice memory leak

>C is always better
>>
>>54822658
>In FP you'd just use higher order functions

So you would have the exact same code in FP that you have in the OOP factory?

What was the point of FP again?
>>
Here's a video on the subject, if anyone's interested.

https://www.youtube.com/watch?v=QM1iUe6IofM
>>
>>54818198
>uses a source
>does not prove source
this goes for anything, including yourself.
>>
File: 1292123500755.png (72 KB, 165x115) Image search: [Google]
1292123500755.png
72 KB, 165x115
>>54822799
>he doesn't understand oop
>he bashes it any way
>>
>>54824872
Also, being consistent with the way memcpy and other standard functions work, it should be:
void giveApples(Kid *destination, Kid *src, int apps);
>>
>>54825236
After java life without
try catch
would be suffering.
try{
/*...*/
catch ( Exception e ) {
/*...*/
e.printStackTrace();
}
>>
>>54824872

And what happens when we have a kid who throws away half of the apples he receives?

C++: subclass Kid and override giveApples().

C: if...then bullshit. If...then bullshit every where.
>>
>>54819214
No, that's how you do bad OOP.
If you're not retarded, you won't do that.
>>
>>54823389
I don't need to tell myself that. It's already the truth. Stupid people always complain.
>>
>>54823014
>0:59
WTF HOW
>>
>>54825424
>WTF HOW
multithread data access
>>
>>54825424
What? It's not a complex trick.
>>
>>54816779
>oAnimal
>o
>object
>HUNGARIAN
REEEEEEEEEE
>>
>>54816779
Don't know why everyone is so confused? OOP when it was invented didn't have any encapsulation, abstraction, or exception as you have today. It was invented to be a generalist programming language.

The notion of inheritance was bolted on as a afterthought.If you want look up the history of Simula 1 and 67 then compare the original designer's goals against OOP today and core concepts are vastly different.
>>
>>54825211
mediocre dev will stay mediocre, that's what you're saying? OOP is garbage, it's visible from outside
and you can confirm it by trying
>>
>>54825356
or you can use pointers to functions and get something like this
typedef void (*creator_subfunction)(int a);

typedef struct Kido{
int apples;
creator_subfunction cf;
}Kid;

void normal_creator_subfunction(Kid kid, int a)
{
kid->apples = a;
}

void retarded_creator_subfunction(Kid kid, int a)
{
kid->apples = a<<2;
}

void set_apples(Kid kid, int a){
kid->cf(kid, a)
}

Kid* kid_creator(int app){
Kid* kid = malloc(sizeof(Kid));
kid->cf = &normal_creator_subfunction;
set_apples(kid,app);
return kid;
}

Kid* kid_creator(int app, creator_subfunction sub){
Kid* kid = malloc(sizeof(Kid));
kid->cf = sub;
set_apples(kid,app);
return kid;
}

void free_kid(Kid* kid){
free(kid->cf);
free(kid->apples);
free(kid);
}

void giveApples(Kid* fromKid, Kid* toKid, int apps){
fromKid->apples -= apps;
toKid->apples += apps;
}

void printApples(Kid* kid){
printf("I have %d apols", kid->apples);
}
void main(int apps){
Kid* john = kid_creator(1)
Kid* mary = kid_creator(apps);
Kid* retard = kid_creator(apps, &retarded_creator_subfunction);
/*strange things when apps < 2*/
giveApples(mary, john, 2);
printApples(john);
free_kid(john);
free_kid(mary);
}
>>
>>54826232
So basically, one should just re-invent C++?

I personally don't have a dog in this fight, since its a comparison of two different tools for different things. I think the issue here is that so many programmers won't use the right tool for the job and/or want to re-invent the wheel any chance they get.

I'm a lead developer in a shop that does a lot of system programming (drivers, embedded etc), and I would reject that code. Not because it is wrong, but it is unnecessary. There is a tool that accomplishes that job which is already available, there is no benefit to the alternative way, and a new developer will have to take time to figure it out.

Sure, in this contrived example, its fine, but I don't want to manage a large code base with 5 different developer's versions of a vtable scattered through out the code.
>>
>>54826611

This anon gets it.
>>
>>54826611
>I think the issue here is that so many programmers won't use the right tool for the job and/or want to re-invent the wheel any chance they get.

I posted this >>54826815 but wanted to expand.

This is a general problem in the industry. Especially, but not only, among Pajeets. People cling to their language / platform / framework / paradigm like it's a sports team. And they pitch it like it's the second coming of Jesus Christ.

Use the right damn tool for the job. One of the criteria for "right tool" is something that is known, documented, understood by others. Don't reinvent the wheel because "hurr durr i don't need no ++ in front of muh C" or "functional programming bathes us in its glow and promises to deliver us from problems of state!"

And yes, that means not using an OOP hammer where a screwdriver of a function or two will do the job.
>>
>>54826908
>>54826815
Thanks, and I agree, people reinvent the wheel for a lot of really bad reasons. One of those reasons is this emotional attachment to a language/platform etc which doesn't make sense, if you ask me.

I think that this problem is the hallmark of an inexperienced programmer, Pajeet or not.

Sure, reimplementing certain things can be fun/enlightening, but when it comes to things that will go into production or need to be managed by others, as you noted, the documented and understood tools are almost always the right choice.
>>
I don't think OOP is bad. I think the way most people work with it is. I think Java encourages terrible practices.
>>
>>54827565
Languages don't make bad programs. People do.
>>
>>54827602
Absolutely. A language can encourage some ways of expressing ideas and discourage others though. Good OOP absolutely can be written in Java. Good OOP can also be written in C or Lua or Scheme or Smalltalk. Some of these make it easier than others.
>>
>>54816779
>when
First larger Java project.

What a mess. And it was just a board game.
>>
>>54825424
Both hands went behind his back, that's when he switched.
>>
>>54818430

Everyone asks for python these days.
>>
>>54827868

I think it's how they weed out people who got a compsci masters degree with the usual java + c combo and then never programmed a single line of code without being paid for it since. IE: me.
>>
>>54820505
>Literally poo spelled backwards
Programación
Orientada a
Objetos
>>
here is an example of OOP vs FP
https://gist.github.com/johnazariah/f6f4761f4e542ff8f584560c50e96b31
>>
>>54829273
>https://gist.github.com/johnazariah/f6f4761f4e542ff8f584560c50e96b31
>what is enum
>>
>>54829273
wtf... That better be bait.
>>
>>54816779
>grow up of OOP
Please learn English, Pajeet. To answer your question though, I was about 17ish when I grew out of OOP. I realized programming paradigms are 49% people who don't know what they're talking about arguing about things that don't matter, 30% marketing professionals making up words, and 1% linguists who actually care about making constructed languages useful in day-to-day life.

>>54816920
Functional-programming is retarded autism and you probably were reading procedural-programming code.
>>
>>54821886
Linux kernel does oop in c son
>>
>>54829297
>>54829331
Enums don’t offer a safety guarantee
you need to do it like that for an equivalent to discriminated unions
>>
>>54829297
>>54829331
you can, but then you have no compile-time guarantee of total matching - which is what I needed.
>>
>>54816779

OP My friend!

As an Indian poogramer,
I find it insulting you'd insult the integrity of OOP, or as we say in India, POO. You see my friend, POO is essential in the creation of large scale Microsoft/Bing programs, for how else are we to take the POO to the LOO that is your white consumer faces? I hope you've learned something my friend, as POO is instrumental for both Microsoft's and India's plans.

- Dangai Vidmagandi
Bing Marketing Executive
>>
>>54830330
Anon, my friend,

POO is common not only Microsoft nowadays, more and more projects around the world are made with POO. My friend, Open source projects, closed source projects, event the GNU projects are made with POO. My friend, today's computer technology is POO powered . There is no escape from POO, whites, blacks, assians, they all embraced the POO.

Good day, my friend.
>>
>>54816920
This. Impure C++/Java-style OO was/is a fucking dumb idea that has cost untold billions, but functional is still simpler and more maintainable than Smalltalk.
>>
I left OOP since ADA came along... If nuclear facilities, missile guiding systems and satellites use procedural paradigm why would it be different for any app either desktop, mobile or web?
>>
>>54826611
>So basically, one should just re-invent C++?
Don't forget the segfault hell of doing new implementation every program, but still it would be better than if block every now and then.
>>
>>54816779

OOP is great when you can model something 'real'. OOP became popular when GUIs became possible, and OOP works very well for modeling window relationships.

OOP became shit when Design Patterns became all the rage (i.e. make software engineers into replaceable cogs), combined with enterprise consultant types wanting to pad their invoice as much as possible.

I personally have had excellent results using OOP. I worked for a hardware manufacturer writing software drivers. I created an object-oriented system where I could integrate new hardware devices in a few minutes, where previously it had taken a week or so.

If you have a lot of domain knowledge and can create an elegant system, OOP is glorious. If you have no idea what you're doing, OOP will make a system slightly more fucked up than any other programming paradigm.
>>
>>54818216
>Gamedev community is bashing OOP for the last several years, trying to move to things like EBD.

Wut. I have a good friend who worked at Maxxis, EA, some shop in Vancouver B.C. (I forget the name, it's one of the major game studios), and is now back in California. He's mostly mentioned C++ and C#.
>>
>>54831866
>He's mostly mentioned C++ and C#.
>not writing games in python/ruby/bash
what a noob
>>
>>54831897

He worked on the Sims, doing maintenance. Fun fact: the two main programmers for The Sims hated each other. They wouldn't speak to each other. Everything had to go through an intermediary.

At some point, the requirements changed and they needed to support a second floor on homes. So the data structure for a home contains a variable something like "bool is_first_floor". So, no third+ floors.
>>
>>54831588
You LISTEN here my friend,

Learn to spek Engg-lish, you pis'a shit!! You muther fucka you, I am from New Delhi you bitwch boi fucka, I will fuck yur ass you muda fucka yu. Dont yu tell me abut POO-gramming, do yu see my rank muther fucka? I'am Bing Marketing EXECUTIVE you pis'a shit! Lern to speak English, and take the POO to the LOO yu fucka yu. Fuck yu mother fucka

- Dangai Vidmagandi
Bing Marketing Executive
>>
>no one mentions data oriented programming

watch this talk niggers
https://www.youtube.com/watch?v=rX0ItVEVjHc
>>
>>54818618
If you think Python has a good Object system, you're a retard.

Common Lisp has the greatest Object system.
>>
>>54833684
>Common Lisp has the greatest Object system.
Which no one uses since LISP programmers know better than to fall for the OOP meme.
>>
>>54819377
>undefined behavior
>>
File: haistapaska.png (96 KB, 1055x494) Image search: [Google]
haistapaska.png
96 KB, 1055x494
>>54821736
MITÄ VITTUA

HOMO
>>
>>54832655
this is fascinating, thanks for sharing
>>
>>54819325
JDK 9
>>
>>54818936
>classes can be modified on the fly
>thinking this is a good thing

It might mike the initial project easier for Pajeet. But maintaining it and tracing bugs in the future is going to be a nightmare.
>>
>>54819565
>>54819624

This industry is being ruined by normies.

I used to think it was a waste of time to push hard math on CS majors because most software development doesn't require it. Now I realize CS departments were trying to filter the normies because proper software design and engineering requires a higher IQ.
>>
>>54819446
C calls them "compilation units" and they're generally organized by file.

I always thought javas class method was rather elegant though
>>
On the right hands, OOP can make a code easier to understand and more manageable.
But it have a goto level of possible fuck ups and an army of java hipsters ready to take the fuckups to a godlike level.
>>
File: 316.gif (842 KB, 300x221) Image search: [Google]
316.gif
842 KB, 300x221
>>54816779
>I don't understand it so that must mean it sucks!

I swear summer starts earlier and earlier each year
>>
>>54835541
I understand OOP and I think it sucks.
>>
>>54835573
then you probably don't understand it
>>
>>54835591
What makes you say that?
Why does understanding something automatically make you like it?

The whole (flawed) premise of OOP is the encapsulation of state, as a collection of objects passing messages to each other.
At a large scale (module/namespace level), this actually works pretty well, but is completely shit at a fine-grained level, which OOP encourages.
There are all sorts of arguments as to why it's shit, but it's more than I want to type out in a 4chan post.
This video does a pretty decent job of explaining it: https://www.youtube.com/watch?v=QM1iUe6IofM although it's kind of long.
>>
>>54835541
I do understand it, I wasted a good portion of my life with this bullshit.
The real question is, is there an OOP monkey that has experience with other paradigms? And what I mean by "knows" is not that the monkey read a wikipedia article, but he actually worked actively at least half a year in that paradigm, knows its weaknesses and strength, knows its purposes and so on? That knows abstract algebra at least at a basic level? Know what's a category? Knows at least what's an endomorphism? Knows type theory? Knows what's a combinator? Understands why functions, when first class citizens, are combinators and classes aren't? Knows what's abstraction penalty? Fuck it, I'll be satisfied to find an oop Pajeet that at least knows what's fucking currying. Are there any oop fags like that? Anyone? Not a single one? Only Java juniors whose brains were completely filled with shit in college? That's what I thought.
>>
>>54835637
>At a large scale (module/namespace level), this actually works pretty well, but is completely shit at a fine-grained level


excuse me, what?
>>
>>54835693
Basically "module level" is "Graphics Subsystem" and "fine-grained" is an "addOneToVariable" class.
>>
>>54835660
>muh functional programming

face it, functional syntax is completely unreadable and the reason nobody knows about it is because it's almost completely unused outside of academia
>>
>>54835720
I know that smartass, but I fail to see how "passing data at that level" is bad
>>
>>54835591
Everyone knows OOP. It's not that fucking hard to begin with. It's taught in all colleges, it's in every manual and every mainstream language. You acting like it's somehow a secret knowledge that only the chosen ones can grasp is ridiculous.
The only difference between an OOP apologetic and a normal person is that the normal person knows something besides OOP, they moved on, while you're still trying to ride a dead horse.
>>
File: 1454508487465.jpg (13 KB, 319x320) Image search: [Google]
1454508487465.jpg
13 KB, 319x320
>>54835752
You're acting like most people on /g/ past high school level
>>
>>54835727
>and the reason nobody knows about it is because it's almost completely unused outside of academia
Are you trying to say, that since most pajeets have never heard of anything besides OOP, they're right to call OP the best?
>>
>>54835741
By "passing a message" to another object, you're indirectly modifying that object's state. Now that object you just passed a message to is YOUR state, as you are responsible for modifying it and may be reliant on its internal state as well. If any other object also uses it, it is now shared state, and you have just completely broken the thing that OOP tried to fix.
>>
>>54835772
I'm trying to say that you're average professional corporation want's nothing to do with functional programming and considers OOP a perfect fit for their projects.

>>54835782
>If any other object also uses it, it is now shared state, and you have just completely broken the thing that OOP tried to fix.
>If any other object uses it

what?
>>
>>54829373
what about the other 20%?
>>
>>54835800
>what?
I probably should have given whatever I was referring to names, to make it clearer.
I have 3 objects, A, B and C.
Both A and B know C. They don't know about each other because they don't care about each other.
Since both A and B can call messages to C, they are part of A and B's internal states.
So when A passes a message to C, it modifies the internal state of B, even though A and B are completely unrelated to each other.
C is shared state.
Shared state is shit, and would be completely the same if C was a global variable.
>>
>>54835860
>they are part of A and B's internal states
Fuck
C is part of A and B's internal states*
>>
>>54835800
>I'm trying to say that you're average professional corporation want's nothing to do with functional programming and considers OOP a perfect fit for their projects.

The average corporation didn't want cars either and considered horse carriages the perfect fit for their projects.

tl;dr not an argument
>>
>>54835876
except it isn't?

Just because concurrent programming is tricky doesn't mean OOP is bad
>>
>>54835898
>car analogy

I mean, yeah, maybe Functional programming will be viable... in the future. But it sure as shit ain't os right now
>>
File: 1457704878499.gif (338 KB, 229x220) Image search: [Google]
1457704878499.gif
338 KB, 229x220
>>54823014
gonna need some source on that please
>>
>>54835902
>except it isn't?
Except it fucking is. Try to understand the fucking situation.
A and B both rely on C. So when one modifies C, it affects the other.
>>
>>54835930
Okay, so then you just design C to be able to handle that sort of situation? Or you use 2 instances of C one for A and B?
>>
>>54822799
You're right. OOP is not a good solution for trivial toy problems. I guess that's where FP really shines :^)
>>
>>54835961
Your tiny toy dick isn't a good solution for a womans pussy either, that's where my dick really shines :^)
>>
>>54835960
>OOP falls apart
>Lets pile on more complexity, objects, and state, as well as having to keep several objects synchronised
>>
>>54836026
>I don't know what OOP is

alright then. The "issue" you're describing looks to me to be more of a problem of the logic of the example itself, than any fundamental flaw with OOP
>>
>>54836060
The video I posted in >>54835637 explains why this is an inherent flaw of OOP, at 18:09 through 21:05, but also talks about some more relevant stuff afterwards.
>>
>>54825424
The actor's right hand was his, from the time when it was hidden behind the green screen around 0:45. He switched his left hand in when it went behind his back at 0:58.
>>
File: Capture.jpg (32 KB, 645x363) Image search: [Google]
Capture.jpg
32 KB, 645x363
>>54836154
That didn't explain shit.

>getters/setters are bad because they make my argument fall on its face

get outta here. NO ONE would design an OOP application like pic, this doesn't make any sense
>>
>>54827660
but can good OOP be written in Perl?
>>
>>54835860
>oh, noes he is retarded .jpg
>>
>>54818116
Mike Acton is a notorious oop-hater.
>>
>>54818679
>considered harmful
>>
File: 1384015276159.jpg (70 KB, 445x735) Image search: [Google]
1384015276159.jpg
70 KB, 445x735
>>54816779
It's fine as long as you don't have to use stupid frameworks with a million factories, helpers and adapters to do trivial things that could be done with two lines of code.

As long as you are able to write your own stuff, it's great. You don't have to add all of the bullshit. If you are a web app developer then you are kinda fucked though.
>>
>>54831852
>design patterns became all the rage

You mean when people left a company with unusable code became an issue? Like when Bell was shutdown for 3 days due to a 2 line change in a switch statement and the effects weren't clear?

Your code should be a bunch of cogs. Stop pretending you were smarter by writing 200 public functions in one file. It's like have a filing system with no labels. It's some enigmatic and inane puzzle you've designed based on your own chaotic form of design.
You are meant to be replaceable. Your security should exist in the work you've done and the ideas you've presented as well as work ethic. Not because you've created a Blackbox that everyone cries in horror when it breaks
>>
>>54819377
>
 #define class struct 
>>
>>54835921
Functional programming features are sneaking into modern OO languages and Clojure/F#/Scala jobs pay pretty well.
>>
>>54837448
this
I mean, Java 8, everybody.
>>
>>54823496
the best comment in the thread
>>
>>54837448
right, all 5 of them
>>
>>54824921
whoa man
>>
>>54819156
But then again you never wrote an engine of few million lines of code, so how would you know? UE managed to keep code clean, if you know what you are doing, OOP is just fine. I do believe in something better, but entitty component system in engines is really the way to go and OOP fits.
>>
>>54825247
>THE MOST IMPORTANT PROGRAMMING VIDEO YOU WILL EVER WATCH
>>
>>54837611
>but he is retarded
>>
All of these FP shills would probably be shilling OOP today if FP caught on in the 80s instead of OOP, but there's a good reason why it didn't. FP failed back then because it had serious problems when it comes to producing real programs. It still does.

People with BASIC and assembly language have produced far more impressive programs than anyone who uses a functional language. The most impressive Haskell programs are Haskell compilers.

The other problem is that schools act like Java is the most advanced OO language and say there's nothing left to understand about OOP. Java is deliberately simplified compared to C++ and more advanced statically typed OO languages like Eiffel.

I really think the only reason people even talk about FP is because Java didn't have first-class methods. Java 8 lambdas are just objects. You could do the same thing in Java 1, but it would be more verbose. You could do the same thing in Simula 67. It's just syntax.

I'm not saying Java is useless or inferior compared to other OO languages, but I think schools should teach a cleaner OO language to get the concepts down.

It's not fair to compare the elegance of a language with millions of users to a language designed for research that doesn't have to care about backwards compatibility. If Haskell is already this bad with no users, imagine how it would be if it ever became as popular as Java.
>>
THE TRUE MOST IMPORTANT PROGRAMMING VIDEO YOU WILL EVER WATCH
https://www.youtube.com/watch?v=PGNiXGX2nLU
>>
>>54816779

>OOP Meme

There is a time and a place for pretty much all of the programming paradigms. You shouldn't be complaining about the way OOP works, you should be moaning about the people who use OOP unnecessarily in their projects. There are no 'good and bad' programming paradigms, just good and bad implementations of code in them.
>>
who else /procedural/ here
>>
>>54818116
id Tech 1-3, the most straightforward engines (in implementation and to use) around.

>b-but muh inheritance
Fuck off.
>>
>>54836372
You're right; typical OOP applications are far, far messier than that topology, and that's just for the inheritance hierarchy.
>>
Client/server stuff is good in OOP.
>>
>>54818116
OOP is the bane of game programming, and luminaries like John Carmack and Tim Sweeney have been trying to tell people this for several years now.

To borrow a point from Rich Hickey, if several objects in a scene (actors, gameobjects, whatever) all hold pointers to another single object in the scene, the fact that they all hold the strings simultaneously and can all manipulate it invites disastrous fuckery to happen and you have absolutely ZERO way to determine how it happened after the fact.

If people started making games functionally, you'd have a game state composed of simple persistent data structures and records, each new state would be a deterministic function of the last, and scrubbing through time to find out what went wrong would be trivial.

And yet novice game dev retards are the first to shit on other paradigms and talk about how OOP is ultra-powerful and can represent everything. Sorry, but putting an abstraction on top of the function and the value and making them mutable and nondeterministic makes them both less powerful and dramatically increases the buttfuckery you can inflict upon yourself with them.
>>
>>54838372
No it's not. Clojure, Elixir, and Erlang programmers beg to differ.
>>
>>54838435
>Sorry, but putting an abstraction on top of the function and the value and making them mutable and nondeterministic makes them both less powerful and dramatically increases the buttfuckery you can inflict upon yourself with them.
Famalam, in OO theory, the object is more primitive and "function" and "value" are abstractions. There are no "values" in a computer, not even in ROM. They all have an identity and physical location. Nor are there "functions," just actions performed by the parts of the machine.

Your computer can be described as being made up of objects. The RAM, CPU, keyboard, display, and network connection are all objects made up of objects. The instructions and pointers are objects (electronic signals) with physical locations, processed by objects. The components of the CPU are objects. RAM cells are objects. The transistors are objects. All of your abstractions are also objects. Files are objects. GUI widgets are objects. Everything is an object. Atoms and subatomic particles are objects. It's objects all the way down.
>>
>>54838435
>John Carmack

>I’m still not a huge C++ fan, but anyone that will flat out deny the benefits of OOP for some specific classes of problems like UI programming and some game logic is bordering on being a luddite.
>>
>>54822799
>>54824872
>>54824427
public class Kid {
private int appleCount;
private String name;

public Kid( String name, int appleCount){
this.name = name;
this.appleCount = appleCount;
}

public void giveAppleTo(Kid kid, int numberOfApples){
if(appleCount - numberOfApples > 0){
incrementApples(kid,numberOfApples);
decrementApples(numberOfApples);

}
else{
System.out.println(name + " you dont have that many apples to give!");
}
}

private void incrementApples(Kid kid, int numberOfApples){
kid.appleCount += numberOfApples;
}

private void decrementApples(int numberOfApples){
appleCount = appleCount -numberOfApples;
}

public void printAppleCount(){
System.out.println(appleCount);
}

public static void main(String[] args){
Kid marry = new Kid("marry",5);
Kid jane = new Kid("jane",1);
marry.giveAppleTo(jane, 4);
jane.printAppleCount();
marry.printAppleCount();
}

}

>>
>>54838435
>If people started making games functionally,
http://debug.elm-lang.org/edit/Mario.elm
>>
>>54838688
>up for jump
>>
>>54838644
private void incrementApples(Kid kid, int numberOfApples){
kid.appleCount += numberOfApples;
}


Wouldn't it be more elegant this way?
private void incrementApples(int numberOfApples){
appleCount += numberOfApples;
}


public void giveAppleTo(Kid kid, int numberOfApples){
if(appleCount - numberOfApples > 0){
kid.incrementApples(numberOfApples);
decrementApples(numberOfApples);
}
...


nice code anyway
>>
>>54838851
>private void incrementApples
public ofc
>>
>>54838851
yea thats a better way to do it. I felt that it didnt feel right when I did it lol. Thanks for cleaning it up.
Thread replies: 255
Thread images: 19

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.