Am I thinking right OO way?

Started by
66 comments, last by oleksiy 13 years, 1 month ago
My advice is that go with the solution seems right to you. Later if you run into trouble, don't be afraid to refactor and admit that you are wrong. Everyone does mistakes, some people learn from theirs.

Also, I would do it with composition :) Player and AI have a score to keep and different ways of controlling the paddle. Paddle doesn't care about scores. It's there to bounce balls and chew bubblegum and this game is all out of bubble gum.
Advertisement
Now, I'm not generally one to care what someone else does or recommends, but what you are advocating for flies directly in the face of the Liskov Substitution Principle, and of the Single Responsibility Principle. Smarter folks than you or I came up with these principles, and they have withstood and been vetted by still smarter folks over the years. "Here, its easy like this." is simply not reason enough to cast all that aside.


Did [color="#1C2837"]Liskov invent classes? Or just tell you how you "should" use them? She interprets and assumes the purpose for a language's functionality for you. She says "this is the one and only way to use classes". My point is, I don't care how smart some one was when developing these principles. Control without reason is pointless. If I, or anyone else, does not choose to follow a principle we deem pointless, then who are you to argue? To each their own. In fact, a better way to handle all of this was, instead of stating that I was wrong because I don't subscribe to a programming principle you follow, instead you could have proposed it as an alternative. But in your narrow sight, you assume that what you were taught was the one and only way to program. In an industry that is built on creativity, why would you be so rigid?

As far as your example goes... it still doesn't come anywhere near to my example. Why the hell would the Paddle class have a score? My method isn't devoid of reason <.> You don't describe a base class with crap that doesn't belong in it. Score doesn't describe paddle. Now, if the score was incremented every time the ball hit the paddle for some reason, then maybe I'd put score in paddle. But it doesn't... I don't get how you assume this is how my method works...

"This is not the case with "Paddle" and deriving "Player" and "Enemy" from it -- both player and enemy contain elements or behaviors which are entirely outside the purview of what it is to be a paddle. Furthermore, they both would contain identical (duplicate) properties, such as score, which clearly do *not* belong in the base class -- another indicator that your version of things falls on its face."

[color="#1C2837"]Uh, score would be in the enemy and player class, not the base class. And you're still under the assumption that the player ISN'T a paddle. That's an argument I'm not going to have with you. You'll just have to admit that there are different ways of viewing objects when programming. I see a player as being what it also controls, you don't. You facilitate control by providing an interface for the user instead of making him the object.

To each their own sir. :P
Wow. Nice discussion.

Deltron Zero and Automator.


Science is wrong, biatches!
ok

[quote name='slynk' timestamp='1299046959' post='4780864']
Science is wrong, biatches!
ok
[/quote]

<.< How is a principle that is an opinionated way to use classes considered "science"? If someone wants to use classes as a means of code organization who's to say they are wrong? Again, if it doesn't degrade performance, if it doesn't result in bugs, if it doesn't make your code intensely ugly then what's the point? It's like if someone says "You HAVE to use ALL CAPS when naming a constant or you're WRONG". Who cares? I'm going to code in a way that makes sense to me, in a way that gets the job done, in a way that's efficient. You can follow your principals if you'd like; I have my own ^^
Look, people have explained the long-established OOP principles of inheritance and composition, what the purpose of each is, and the higher level reasoning enabled by following those formal systems... i.e. the established science (which is: composition is for code re-use, inheritance is for "is-a").
On the other hand, you've basically declared all advice to this effect from computer science and all software engineering knowledge as simple "opinion" that should be disregarded in favour of ad-hoc design.

You're free to hold the opinion that inheritance is great for code re-use, but remember this thread was about OO. You're basically arguing outside of OO, and saying that OO isn't necessary - just do what works, which is fine sometimes -- but it's obviously completely irrelevant when the discussion is within the context of OO.

Hence: Ok.
I didn't say all OOP principals were opinions. I said they fall into two categories: Serves a purpose and Opinionated bullshit. There are a lot that I follow. ^^ You are the one that can't leave it as a difference of opinion. You're the type of person that drives away creative people from the forums because they question the standards imposed upon them. I mean really, how do we advance in anything without questioning whether those before us where right or not? How long did we think the earth was flat? There are always going to be rigid people like you that take everything that's thrown at them for face value but there are also those of us who will scrutinize until either A) coming to the same conclusion or B) learning that there is an alternative.

I really don't get why people have to shove their beliefs down other's throats. I have not been given a solid reason to subscribe to this principal, there for I do not. I don't blindly follow anything. So some people that don't follow this principal end up having extra code here and there, does that mean everyone does? No. I don't. I purposefully avoid duplicating code. I see no point in redefining the same function twice. So how do you propose that my method is any less valid than yours? You can't. Both can be right. But if you insist on arguing with me until I say that there is only one way to do things, I hereby exhaust my efforts to convince you to stop being narrow minded. It was a nice chat, but I didn't mean to appear to be trolling. I apologize to the OP if this has littered his thread with info he'd rather not read through. Hopefully it'll be something of interest to him though. ^^
You're the type of person that drives away creative people from the forums because they question the standards imposed upon them[/quote]No, I drive away trolls from the forums by pointing out that their story is indeed cool, bro.

ok.

I mean really, how do we advance in anything without questioning whether those before us where right or not? How long did we think the earth was flat? There are always going to be rigid people like you that take everything that's thrown at them for face value but there are also those of us who will scrutinize until either A) coming to the same conclusion or B) learning that there is an alternative.[/quote]I used to write bad OO code that used inheritance to achieve code re-use, like you're promoting. However, then I scrutinised it and came to the conclusion that this actually leads to less re-usable code in the long term, along with leaky abstractions and fragile designs. Then, I realised that there was tonnes of decades old literature describing in objective detail this grand discovery that I'd just made for myself, and found formal systems for proving this hunch to be useful.
I have not been given a solid reason to subscribe to this principal, there for I do not.[/quote]Actually, you've been given several, but you ignored them.
So how do you propose that my method is any less valid than yours?[/quote]As I already said, if you look at your design within certain formal rules you can objectively test this. If you want to use the seat of your pants, that's fine, but you lose the ability to be objective - that's your choice.
I really don't get why people have to shove their beliefs down other's throats.[/quote]So why are you having a long argument shoving your bad designs down our throats?
I hereby exhaust my efforts to convince you to stop being narrow minded[/quote]Come back when you've studied the things you're denouncing.
Erm, nobody tried to shove his beliefs down your throat. All I see is simply a: "I think this is better, think about it" Yet you are the one who gets all jumpy about it.
One more Idea of mine: I can create also Game class to represent game itself; main loop, updating, timers, rendering an etc. It is good idea?

Deltron Zero and Automator.

This topic is closed to new replies.

Advertisement