This really took me back to my Java/C++ classes. It's funny how knowledge can lie dormant and forgotten in your brain, but then with the right little push, you remember all this stuff you thought was long gone.
@spitalhelles3380
5 жыл бұрын
funny how you can just access it without calling the memory function of an object of the subclass IT-class of the class lecture first.
@saintjerome8579
2 жыл бұрын
This is the best, clearest explanation for OOP I've ever heard. Of only my high school programming teachers had made it that clear.
@lepidoptera9337
Жыл бұрын
They shouldn't teach you OOP in high school to begin with. Chances are that they are screwing up your mind with all the wrong ideas about what OOP does.
@leonhrad
8 жыл бұрын
How about another video to demonstrate the weak points of Object Oriented Programming?
@betlamed
8 жыл бұрын
+Leo S I think they already have something on paradigms.
@juneguts
8 жыл бұрын
+Leo S So a video with nothing in it?
@edgeeffect
8 жыл бұрын
+AnUntitledAbridger I think I could quite easily find 40,000 engineers, philosophers and scientists who would find your assertion that anything, anywhere has no weak points to be, at best, very naive.
@betlamed
8 жыл бұрын
+AnUntitledAbridger FunctionalWeenie shitstorm in 3...2...1...
@Coolfolder
8 жыл бұрын
+betlamed Oh awesome! I'd love to watch it, do you remember anything about the title of that video?
@NoahSpurrier
2 жыл бұрын
The problem with OOP as implemented is that it’s not supposed to be difficult to wrap your head around; it’s not supposed to be more complicated; it’s not supposed to make programming harder. It’s supposed to help manage complexity; it’s supposed to be easier to understand; it’s supposed to make our jobs easier. We should ask why new programmers are intimidated by it. We should ask why has OOP not lived up to the promises.
@atlantic_love
2 жыл бұрын
For me I'm perplexed with semantics involving object design. Should the logic and user interaction come from within main(), or should my objects also have methods for input from user?
@bkucenski
Жыл бұрын
It has. People care more about patterns and copying and pasting code than making things easier. OO done correctly makes things easier and reduces code.
@ArchAngelSlayer1
8 жыл бұрын
That was the greatest crash message ever. exception: blahblahblah kernelpanic: blahdiblahdiblah help!
@SalmanKhan-pg7dk
8 жыл бұрын
+Salman Khan peshawar
@noxabellus
6 жыл бұрын
All you need to take away from OOP is the idea of associating a function with a type, so that you can call type_instance.function() easily. Everything else is more trouble than its worth. Especially classical inheritance. And I'm saying this as a game dev. If I can make a whole game with has-a relationships rather than is-a's then you certainly can for business applications.
@SeverityOne
3 жыл бұрын
While I'm a great proponent of OOP, with this I have to absolutely concur. Inheritance is useful in a limited set of circumstances. I've yet to meet the first customer who wants me to write an application featuring Dogs and Cats, both derived from the Pet class. Without going into too much detail, I once had to deal with an application that was so incredibly full of is-a relationships, that a piece of code to read in data (exchange rates, although this is not relevant) had so much binding to other classes and libraries, that by trying to isolate just this class and adding the dependencies, I ended up with a class that calculated sunrise and sunset. Now this was from a developer who had some pretty set ideas, and although he was clever, this intransigence meant that the code was essentially impossible to refactor. The guy would write his own implementations of freaking everything, or at the very least a facade, even if a widely adopted standard existed. Like a logging framework.
@Mistermatt-96
8 жыл бұрын
I spent half a year of college doing object oriented programming in c++, this explanation has made things so clear! cheers!
@ElagabalusRex
8 жыл бұрын
I personally prefer using the bank account example that many authors like, because it's easier to explain certain things like inheritance, initialization, and mutators than in the GUI example.
@ihrbekommtmeinenrichtigennamen
8 жыл бұрын
+ElagabalusRex I partially agree. A lot of typical programming class examples don't work out nicely when you try to implement them. Something I notice people often get wrong is a "contains" relationship because it means different things in programming and in reality. A car contains an engine, sure. But this often leads to the conclusion that the car-class should have a property pointing to the engine ("the car-class contains an engine-property"). One may want to implement it that way but whether that actually makes sense in that specific case depends on what the program should do.
@thetradefloor
8 жыл бұрын
I was taught to think about objects as being similar to Pokemon ahah
@85set05
8 жыл бұрын
so if you add a method and you already have for you have to remove one also removing certin methods would require you to visit an old man
@85set05
8 жыл бұрын
***** 151
@huehuehuehuehuehuehuehuehuehue
8 жыл бұрын
Dr. Steve Bagley is my favourite hamster.
@voussoirnet
8 жыл бұрын
+TheUmbrellaCorpX7 State: Level, EXP, attack, defense, speed, and other attributes Methods: Attacking, taking damage, healing, learning new moves Identity: Even if you have multiple of the same pokemon with the same level and the same moves, they are still separate entities and behave individually. That would be my interpretation of his pokemon analogy.
@Niki_0001
8 жыл бұрын
+Voussoir And suddenly I feel enlightened :o I kind of understood objects before, but now I can actually see how useful they can be. Thank you!
@pehash
3 жыл бұрын
I would love a smart guy like this to stream or record a video of a simple game development, like pong for example, and explain everything he does in ample details and simplified in the same time. I would sit there for hours with a huge popcorn bag just listening to the guy.
@edgeeffect
8 жыл бұрын
"I used to be enamoured of object-oriented programming. I'm now finding myself leaning toward believing that it is a plot designed to destroy joy." - Eric Allman "The problem with object-oriented languages is they've got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle." - Joe Armstrong
@code-dredd
8 жыл бұрын
+edgeeffect The first quote really says nothing about OOP, and the 2nd seems to be more about programmers than the method they use to program.
@1yaz
8 жыл бұрын
Seems like the only people who are not for OOP are the people who do not understand it. Not trying to say OOP is always recommended.
@thefauvel7558
8 жыл бұрын
+Yazen Alzaghameem A lot of people aren't for OOP.
@1yaz
8 жыл бұрын
CaesarGamer Explain to me how inheritance is generally bad. Polymorphism + Implementation Independence is bad?
@code-dredd
8 жыл бұрын
+Yazen Alzaghameem Inheritance does not give you the independence you mention (unless you're implementing interfaces). Inheriting from other classes generally violates encapsulation because the child relies on the parent's implementation details.
@justawatchin2
7 жыл бұрын
I'm in the middle of redesigning my first proper Python program (a recordable looper for guitar/keyboard etc.) using classes. I typically have upwards of 20 loops running at once and before this I was making them all be nested dictionaries of variables and (ironically) classes coded by another person. It worked but was a horrible mess, and I only wrote them that way because I didn't understand Python classes enough to test them out. It's taking a bit of time to rewrite the program but it's so so so worth it. Code is so much easier to read and operate and is in some cases half the length.
@TheBedrockCreeper
8 жыл бұрын
Ok, now you need to cover functional programming too! :)
@spikeguy33
8 жыл бұрын
I feel like there is no way I could have understood this video if I didn't already have basic understanding of 'object oriented programming'. I think these videos have to appeal to ~90% of the viewers, but all it did is explain how to program a pong game to a person who already has some idea of how to do it. (This is assuming the video meant to explain 'Object Oriented Programming' to the general public)
@MuradBeybalaev
7 жыл бұрын
>assuming the video meant to explain 'Object Oriented Programming' I think the title suggests otherwise.
@wesofx8148
8 жыл бұрын
OOP really shines when you have Vector objects and Matrix objects that just know how to be multiplied and added together. So easy!
@lm1338
5 жыл бұрын
That's nothing to do with OO, that's operator overloading
@Kylefassbinderful
6 жыл бұрын
I really appreciate how you visually explained Object Oriented Programming. This is the first time I'm starting to grasp it.
@Vekkq
8 жыл бұрын
In many functional programming languages, access to nontrivial data is also restricted to certain functions. However, FP emphases to keep data as simple and open as possible and functions as general as reasonable.
@SonOfMeme
8 жыл бұрын
Really helped me understand OOP! Thanks, Computerphile!
@pinklady7184
7 жыл бұрын
As house is to blueprint, object is to class. Thanks for simplifying that.
@manuelengel3680
5 жыл бұрын
4:56 Best Blue Screen/Kernel Panic ever
@cbwatters
Жыл бұрын
SB's facial expression for objects, @5:09, just excellent 'of Objects'
@nERVEcenter117
8 жыл бұрын
2:28 We could literally stop here, represent the paddles and the ball as maps, and represent their movement on the canvas (new paddles at their new positions) as functions of those maps. Then a game function that uses tail recursion to loop endlessly and call those functions. That's it. No need for OOP, no need to worry about memory at all!
@DFX2KX
8 жыл бұрын
+nERVEcenter117 true, but that doesn't make it a less intuitive example to demonstrate the principle. OOP's upside is when you're interfacing with a game engine that has 1,000-1,500 functions in it, and only a small fraction of those are going to be needed for any one task. You do pay a tidbit in resource load for the convenience, but I haven't met TOO many people who are willing to take the loss.
@nERVEcenter117
8 жыл бұрын
DFX2KX I don't understand how there would be a disadvantage here in functional style. Languages like F# and Clojure have very convenient namespace semantics, including ways to reference just one or a few functions out of a namespace. Browsing such large codebases tends to be easier than OO languages, because you don't need to look at giant object signatures for the one that contains the methods you want, nor do you have to instantiate that object and deal with referencing it. You just call a function.
@atlantic_love
2 жыл бұрын
One of my favorite channels. I'd like to see him talk about how to do OOD (Object Oriented Design). For instance I'm bogged down right now in making my own classes that represent things like Container, Random and Sort. I don't know whether I'm supposed to write my program such as interaction with the user comes from within main(), or if the user interaction should come from within in the objects. I'm using C++ and this is just a hobby of mine.
@Luca-tw9fk
2 жыл бұрын
Agree and would love to a vid on OOD. I mainly program in java but here are my thoughts: to use sort as an example, I'd have a class that handles the sorting algorithms, with a method that accepts and returns a data structure for each. I'd then have a class that handles the set up of the GUI, stores user input in a data structure, and calls the appropriate method on it. I like to keep the amount of code in the main method to a minimum, and tend to initialize all of my objects in a seperate method within the same class that holds the main method
@atlantic_love
2 жыл бұрын
@@Luca-tw9fk in C++ I'm only doing console programming because it's not user friendly to set up C++ compilers to work with gui frameworks. Even I'm console programming I'm doing what you're suggesting:. A class for sorting, with static methods. Seems overkill to create an object that doesn't have any state or is passed around. Do you mean that within one of your classes you instantiate a number of classes?
@lepidoptera9337
Жыл бұрын
@@atlantic_love All of this can be done easily and without any confusion with libraries.
@atlantic_love
Жыл бұрын
@@lepidoptera9337 What language are you talking about? Which libraries?
@lepidoptera9337
Жыл бұрын
@@atlantic_love Any language. A universal sort algorithm is nice, academically speaking... but in practice it doesn't matter. How many hundred different types are you sorting in a single application? And even if you want to sort different types with the same algorithm, then what does it really take? A few function pointers in C. That's it.
@BlueDraEv
8 жыл бұрын
Great simplified explanation!
@sierrabravo7368
8 жыл бұрын
I knew that I should use getters and setters but the way it was explained in the video was really good
@boenrobot
8 жыл бұрын
9:07 - 9:11 THIS! In my experience (primarily in talking to university classmates and in forums...), the only way people REALLY start to get it is when you START the explanation with this, because that IS what it boils down to. To the uninitiated, OOP sounds like "this complicated, yet magical thing that you can't do without", when in reality, it's more like keeping your room tidy - you still have the same toys, it's just that having them all ordered gives you a different feeling... And chicks dig it better (in general)!
@AndresRodriguezGuapacha
8 жыл бұрын
Can you do another video explaining Functional Programming?
@naikrovek
8 жыл бұрын
The thing I've learned about Object Oriented programming over the years, is that the more I do it, the less I find it makes sense. Not only for the program I'm working on at that time, but for any program. It is something that is very attractive to those who do very little programming, because on the surface it makes a lot of sense. When you actually do it, it makes a lot less sense. When you've used OO for a long while, it makes no sense.
@rameynoodles152
8 жыл бұрын
+naikrovek how?
@rameynoodles152
8 жыл бұрын
naikrovek I see what you're saying now dude. Like there a bunch of arbitrary rules that can hinder development and rarely help eliminate bugs. You just gotta not be so strict, and loosen up a little. Object oriented is just that, programming using objects as the fundamental module, so don't get caught up in the beurocracy that comes with the silly rules and it's great.
@DFX2KX
8 жыл бұрын
+naikrovek I've used object oriented (one might even say object dependent) programming and scripting languages for awhile. It's not that it makes less sense, but you find that it gets used where you're not gaining much in using it. I'd have a Mesh object, and a bunch of functions in it to load/save/calculate animations, but there are people who'd have objects for the mesh loader, the mesh saver, the animation routines would be their own class...
@rameynoodles152
8 жыл бұрын
Well, I'd say that they're doing it wrong. The objects should be made to encapsulate data, and have accompanying functions that operate on that data, not objects that are, in themselves, operations on data stored somewhere else.
@antiHUMANDesigns
8 жыл бұрын
DFX2KX Yeah, I do the same, if you're talking about engine architecture. I have a "scene", which contains "entities", and an entity can have a "mesh" (3D vertice data), which can have a "skin", which means textures and shaders. The "mesh" class does everything mesh-related, like loading from files, and the "skin" class loads texture files, and sets up shaders, and so on. The only reason I'd make a "mesh loader" class would be to be able to re-use that bit of code for other things. But on the other hand, I can just copy-paste some functions, instead.
@TheEmptyHoliness
4 жыл бұрын
Did the Inheritance video he mentioned ever get made? Would love to watch that if it hasn’t!
@TechXSoftware
8 жыл бұрын
I program a lot it's easy for me to get my head around it, it actually makes things easier.
@Cypeq
2 жыл бұрын
Brilliant... Such a great way to tech object oriented programming. It's so simple too. Make a fun simple game, not a school or other boring structure.
@JuusoAlasuutari
8 жыл бұрын
Directly referencing an object's data without using its interface? That's a paddlin'.
@pumpkinot9900
3 жыл бұрын
I don’t get it.
@hognosemyan
3 жыл бұрын
@@pumpkinot9900 public int a; return this.a; vs private int a; public int getA() { return this.a; } make everything as private as possible
@rogernevez5187
6 жыл бұрын
8:40 "We write the code not in terms of data manipulation, but in terms of telling this object to move up or down." This could be easily done with *procedural language* + contexts. Still, I don't see why migrate to OOP.
@SeverityOne
3 жыл бұрын
Because a bat has an immutable Y-position. You cannot do that in a procedural language, because every part of the program can access every piece of data. That's why.
@atlantic_love
2 жыл бұрын
@@SeverityOne Yes, you can do it in a procedural language. Using while loops, and separate variable names representing state for each paddle and the ball. You'd then have a function that specifically accesses each of those variables and changes their values. By having distinct variable names you mimic immutability. PaddleA_posX, PaddleB_posX.
@rstriker21
8 жыл бұрын
Such a simple game with not as simple code.
@noahhall2302
8 жыл бұрын
Nah it's p. simple
@MazelTovCocktail
8 жыл бұрын
They really did a lot a ground breaking work to make that game. Pong seems simple now but it was a feat of engineering and science back in the day. Really ingenious stuff.
@AlexanderBollbach
8 жыл бұрын
+youdontknowxpand he said "not as simple code". compared to a ball bouncing back and forth it is "not AS simple".
@Tfin
8 жыл бұрын
+Alexander Bollbach It barely qualified as "code" at all. It's like calling a wiring diagram code.
@AlexanderBollbach
8 жыл бұрын
what qualifies as "code" to you
@kranser
8 жыл бұрын
To make the paddles object orientated, you would need data inside the paddle to store the keys for moving up and down and also operations to allow these key values to be set from outside the object. Also an undraw operation would be helpful.
@stensoft
8 жыл бұрын
+kranser You don't need undraw, you just redraw the board (but you need the board object). The keys should not be handled by the paddles but by some input system (what if you wanted to use joystick or Wii?). Which should have its own object.
@kranser
8 жыл бұрын
+Jan Sten Adámek Thanks for the information. If the input is an object in itself, how can the paddle object be duplicated to make 2 objects (same data structure and operations, but unique reference)? I guess the input object would reference the individual paddle objects by unique reference number, correct?
@stensoft
8 жыл бұрын
kranser Yes, that are the identities he was talking about. The input object will have two references, one for each paddle's identity.
@MikelNaUsaCom
6 жыл бұрын
having a deterministic size for the objects make garbage collection much easier to automate. IE making them strongly typed objects - especially if all your primitives are derived from a single base object.
@MM-sc5ux
8 жыл бұрын
Very helpful video! Could you please explain the MVC paradigm visually the next time?
@edgeeffect
8 жыл бұрын
+Tai Le MVC is hardly a paradigm... it's just one simple case of OOP... a design pattern.
@MM-sc5ux
8 жыл бұрын
say this to my college professors
@dexter9313
8 жыл бұрын
+Tai Le Maybe you didn't listen to your college professors carefully enough, because edgeeffect is right.
@boenrobot
8 жыл бұрын
+Tai Le Many people (not just college professors) use the word "paradigm" as a synonym for "approach", which is the real problem. Both "design patterns" and "programming paradigms" are "approaches to solving problems"... But they aim to solve different categories of problems. Nevertheless, due to a simplified vocabulary, it's easy for anyone to get confused. It's like how in physics there's "technically" a difference between "speed" and "velocity" (I'm not sure what it was, but I remember a few Sixty Symbols videos about the fact it was a thing...), but in every day speech, we use the two words as synonyms.
@juggernaut93
8 жыл бұрын
+boenrobot Velocity is a vector and speed is its modulus IIRC
@jasevl
8 жыл бұрын
I like to think of objects as something like a television. You interface with the TV through a remote and can change channels etc. However you don't need to know all the work the TV is doing internally to display an image and change the channel etc All you need to know are the functions of the remote..
@kristupasantanavicius9093
5 жыл бұрын
This has nothing to do with objects or object oriented programming. This is just engineering. You take a complex process, and you create a simple interface for the said process.
@derstreber2
8 жыл бұрын
yay for data oriented programming
@vorbeGrele
28 күн бұрын
what other types are out there?
@gogopie64
8 жыл бұрын
I feel like this channel needs to have more advanced material. Everything is either a superficial look at stuff being done in the realm of computer science or explanations of super basic concepts. Why can't this channel be more like numberphile where it actually gets into the nitty gritties of things?
@pumpkinot9900
3 жыл бұрын
nou
@abstractapproach634
3 жыл бұрын
Numberphile most cirtianly does not get rigourous with mathematics; maybe it just feels that way because of your skill set? I do agree that computuerphile is shallow as well though. With my ameture understanding of computer science that may show they simplify tghings a little worse here.
@suicidalbanananana
4 жыл бұрын
"Its probably not going to be more then a few hundred lines long" Honestly that sounds like way to much code, even if you'd go completely overboard with OOP
@tomeubank3625
8 жыл бұрын
You neglected to mention an essential property of the ball: its direction of movement, ie, it's a vector. Also, if it were a real ball, it would have mass, momentum, and a surface area with a coefficient of friction, generating a constantly decelerating force that would interact with the downward force of gravity to continuously alter its direction and velocity. And an even more real ball would have rotational inertia, etc. OOP makes it possible to encapsulate all of this data and processing into a single block of code. As you pointed out, OOP may be overkill for Pong, but not for more realistic simulations involving numerous entities with similar properties. For a more immediate example of OOP, the screen image we are reading is generated from literally hundreds of objects each with its own properties and methods.
@OrchidAlloy
8 жыл бұрын
I taught myself how to program basic C++ and sometimes do stuff for fun. Some time ago I made a basic Pong on the Windows CMD. This video will be interesting!
@OrchidAlloy
8 жыл бұрын
Noe Alvarez ~16. Does it matter? I just did it for fun! :) It was a challenge to test the limits of the Windows command console... It works pretty well for what it is. I wanted to further improve it, but got bored. Still, it was a nice, short, amateur project with decent results. Here's a link for the code: dl.dropboxusercontent.com/u/43721327/C%2B%2B/PongOld/Pong.cpp Or, also, the executable: dl.dropboxusercontent.com/u/43721327/C%2B%2B/PongOld/Pong.exe You stat the game with the spacebar. W and S control the left paddle, up and down arrowkeys control the right paddle. You have to press repeatedly to move, instead of holding down.
@noealva
8 жыл бұрын
i didnt know you could do this in the command console. what page did you learn this from? i only code maths and strategy oriented programs.
@noealva
8 жыл бұрын
***** Thanks, I'll check it out.
@realraven2000
8 жыл бұрын
Do one on JSON :) that one makes objects really easy. Coming from C++ originally what I like about JavaScript is that the classes are already instances: pos = { x: 5, y: 7, moveVert: function myMoveVert(n) { this.y += n; } } pos.moveUp = function() { this.moveVert(1); } pos.moveDown = function() { this.moveVert(-1); }
@godfather7339
2 жыл бұрын
I think that's called prototype based programming rather than class based.
I know this wasn't the point of the video, but since both paddles are instances of a single object, how are the controls uniquely defined? Off the top of my head, the most reasonable solution is to create an operation which prompts for contols (which would probably be passed when the object is created). And a supplementary question: It seems like letting "draw" be an operation of the individual object would lead to a lot of visual desync and clutter. Wouldn't it be better to let "draw" be a property of the board so that all objects are updated and drawn simultaneously each frame? In essence, the "draw" operation has to erase the old instance and create the new instance, which usually means the background needs to be re-drawn anyways. I get that you don't always want /all/ of your objects drawn all the time for efficiency, but it would be pretty easy to exclude things based on distance (or any number of other factors).
@DFX2KX
8 жыл бұрын
+VinceOfAllTrades in OOP, when you create an object, you get an instance ID. That instance ID essentially contains the pointers to the individual chunks of RAM it's unique variables are stored in. To give each it's own uniqe controls, you'd just load one 'Paddle' id into a 'var_Left' and the other into a 'Var right' and then have Q and Z do the 'Var Left.moveUp()" and 'var_right.movedown()' respectively. ditto for the other paddle.
@U014B
8 жыл бұрын
Is this what runs the machine that goes "PING!"?
@ghelyar
8 жыл бұрын
I got a youtube error at 4:57, where it talks about crashing and shows a BSOD, and thought it was part of the video.
@marcusrossel4638
8 жыл бұрын
How about videos on Protocol Oriented Programming, after this series concludes?
@aloluk
6 жыл бұрын
By the way, the screen would not be only represented by the computer, because what happens to the ball when it goes off the top/bottom of the screen?
@HadrianDan
6 жыл бұрын
Then in base, of Object Oriented Programming, the shapes or models are the objects or shapes inside shapes are objects of other objects and whatever is then in manipulate are the operations on the objects or something, correct if wrong. Where the object is a program in itself as well and each object has its own identity with own set of rules. A class is a blueprint to all of that also and stuff is and then the computer interprets and then does compile if it makes sense or whatnot.
@YouHolli
8 жыл бұрын
There is one crucial object missing in this example: the board itself.
@vuurniacsquarewave5091
8 жыл бұрын
+YouHolli Why is that needed? The ball would know when it hits a wall once its Y coordinate is less than the upper wall or more than the lower wall.
@SheikahZeo
8 жыл бұрын
+za909returns None of the classes are needed. You give a perfectly good rule for the ball hitting the wall, but it's irrelevant. The questions you're answering when you define a class are who should have to know the rule and who gets to change the rule, not what the rule is.
@YouHolli
8 жыл бұрын
+za909returns The ball is not supposed to know anything about it's surroundings.What if you want to support boards with different shapes or sizes?
@grantcivyt
8 жыл бұрын
+DC I think we agree. In addition to its position, it probably should know its shape as well.
@XLsDiary
8 жыл бұрын
+YouHolli Pong is actually perfect to show strength and weaknesses of OOP at the same time. DrawYourself is easy in OOP. Detecting collisions is ugly. Whom are you going to ask, if every object only knows it's own position and shape?
@AmeshaSpentaArmaiti
8 жыл бұрын
why did it take so long to reach this topic of discussion? it's usually one of the first things CS oriented channels cover.
@HemmligtNavn
8 жыл бұрын
I think the statement at around 11:50 that the rest of the program doesn't need to know anything about the object's behaviour should be prefixed by "for a single threaded program" ....
@ihrbekommtmeinenrichtigennamen
8 жыл бұрын
+Hemmeligt Navn I think that's a bit far-fetched, especially for beginners. It should be documented whether a class (or any element of a program) is thread safe. If it's not thread safe and you use multithreading anyways then all bets are off anyways. If it's thread safe then the behaviour should be basically the same as without multithreading. Every call to the "move up" operation moves the paddle up. Calling that operation twice on one thread or once each on two different threads won't change that.
@RealCadde
8 жыл бұрын
Difficult to get your head around it? I started off with Basic, then QBasic, then i had a long pause from programming (regrettably) and then dabbled some with VB 4, 5, 6. My interest in programming only ever took off for real when i started messing with VB.Net and later i converted to C# and only now have i come to some sort of grasp with non object oriented languages. I must say, object oriented programming is what got me into programming for real to begin with.
@davef21370
6 жыл бұрын
I like to the analogy of Space Invaders and Galaxian. Space Invaders could be programmed using a bunch of arrays, x-y values and speed. Galaxian needed a simple AI for the groups to break off and swoop down. That would be far easier using OO.
@ChristopherGaul
8 жыл бұрын
Good explanation though it leaves out one of the main reasons for Object Oriented Programing, to allow software mills to turn programmers into modular, expendable, commodities. aka objects.
@AlqGo
8 жыл бұрын
Aye! To reuse code and, therefore, to cut down costs.
@ChristopherGaul
8 жыл бұрын
antiHUMANDesigns First, I mostly agree with you. However, one other issue I have is that OOP is also used by software sweatshops to allow more parallelism in the coding. That is dumping of different sections and even objects to different coders or teams. I personally question the performance and quality of code that results from this practice. Either they don't spend time developing coding _and_ documenting coding standards. In which case they spend the time later making it work and inter-operate. Or they _do_ have the standards, which also act as a restraint on the programmers, keeping them from coding the best, most task optimal, least bloated code possible.
@antiHUMANDesigns
8 жыл бұрын
Christopher Gaul Yes, those are valid concerns. But is none OOP really going to guarantee taht none of this happens? And can you feasibly do the same things and in about the same time without OOP? Of course, I have no experience working with a large team, so I don't know what naturally happens, other than "rumors" I hear about it, which I must assume is slightly based on confirmation bias, or "circling the hits, but not the misses". Even though I don't have the experience of large teams, I still like the idea that you can have one team separately working on one "module", while another one works on some other, and as long as they agree on an interfacce, it'll work. Without this possibility, I just don't see how you can be as efficient/productive. If you have to actually care about *how* other people wrote their implementation, then it's going to be slow *and* overwhelming. Abstraction fixes this. Of course, perhaps abstraction isn't strictly exclusive to OOP, I'm not expert on the terminology, but it would seem like abstraction is an OOP style idea.
@UltimaWeaponz
8 жыл бұрын
+Christopher Gaul I disagree. I've been working as a developer for a couple years now and what you say about turning programmers into modular and expendable people is exactly what you want. You want the code to be self documented. You want any experienced programmer to be able to read and understand the code, and expand upon it. Sure, it might not be the most optimised code in the world, but it develops fast and if tested properly, works. I think OOP was the major breakthrough that has allowed the fast evolution of the digital world. Also, as a developer, I don't want my work to be something only I can understand, which is what happens in my spaghetti code imperative languages. I want to be able to move to other projects, companies, and have my work last and be improved by others. I think you have never actually been a developer to say those things.
@mlhbro
7 жыл бұрын
Yes, you're so right. The only purpose of code reuse is to cut down costs. What a genius take. I mean, seriously, is there ANY programmer who, when they realize a repeated section of code needs a change, absolutely adores having to go back and make the changes in several places? What programmer has ever wanted to perform this sort of busywork?
@ojamamask
8 жыл бұрын
please explain declarative programming
@abeplus7352
5 жыл бұрын
So much hate for OOP. I actually really like the style of thinking behind oop . Just the fact that you can write a class once and not have to think about the details behind what each method does. It just does what you want it do as an entity. plus it really helps in organizing your code instead of having each method like a block of 100 lines of code , each method can be less than 20 let's say because you have entities and helper methods that'll take care of most things for you. It might not be perfect for all use cases , but for most of the things I've made solutions for it's been helpful. Plus unit testing is like a piece of cake when you have classes. From what I noticed people who hate it , generally are either wanna be pseudo coders who use python to write scripts , functional programmers ( kudos to you and I respect your opinion) , or C/Assembler programs who think that any form of abstraction is nonperformant and slow.
@SteamsNightcore
8 жыл бұрын
We had to program a version of object oriented pong in my computer class using java. It was good fun, but very difficult, so when I saw this video, I had to watch.
@Maver1ck101
7 жыл бұрын
Forgive me for saying this, but Prof. Bagley reminds me of Bob from the Tekken fighting game franchise.
@runecreed2265
8 жыл бұрын
Something that puzzles me with this is that for the game of Pong for example - the draw methods associated with Objects specify 'how' this object is supposed to be drawn, since the actual drawing happens outside of the object, by means of the encapsulating program (in this game, the screen/main class); Am I right in assuming that there should be a draw() method in the encapsulating environment that invokes each individual's object's draw method? Public void Screen() { public static void main() { Ball theball = new Ball(x,y,size,...) Paddle paddle1 = new Paddle(x,y,....) Paddle paddle2 = new Paddle(x,y,...) draw(); } draw(){ theball.draw(); Paddle1.draw(); paddle2.draw(); } } Does this make sense? [yeah the draw should be in an updating method that constantly runs, of course]
@JB940
8 жыл бұрын
Yes and no. You could have a board have an array of objects, with a function that draws them all ( like you described but more expandable), but there could also be another class that keeps a board, and an array of objects, and does object.draw(board), then the board does not need to know of the objects
@runecreed2265
8 жыл бұрын
+Jordy Brinks But don't you want the board to be responsible for drawing the pieces onto it? Take for example a chessboard with cell objects that form the grid - the cells themselves are valid X/Y locations that may be occupied by pieces (also objects). How would you organize the drawing of these elements? How I'd do it is have a main Board Object with a draw method that draws all cells - and each individual cell has a draw that may (if need be) call the draw method of a piece that occupies it (boolean probably), which then drops the X/Y position from that cell into the draw method of the piece. In essence what I'm struggling with is the drawing itself - should you encapsulate only the 'way of drawing it' rather than 'where to draw it' for each object's draw method; and have the 'where' be specified by some mainframe that assigns locations - possibly via a constructor?
@JB940
8 жыл бұрын
Kevin Cleijne they're both valid, and both have merits. It makes sense to have a piece know if it's location. It makes sense to have a piece know it's "pixels". It makes sense the board instead keeps track of positions, and draws the shapes. It all boils down to the same actually. You could say a chessboard cell is an object, and the way you describe the board would be the encompassing class making the piece draw on the cell -> IE the piece gets a cell object and draws itself on it. Or you could say the board draws the object instead. It depends on the perspective. In this video you could say the objects draw themselves onto the board, or you could look at it from the "class that makes this happen" as the main perspective and say it is drawing the objects.
@runecreed2265
8 жыл бұрын
+Jordy Brinks Yeah, in essence it's the same. I just wonder if it wouldn't be best to have an overseer class taking care of some behavior. Should the Ball be aware of it's collisions, or should the overseeing class handle those events instead? The ball shouldn't really know what it collided with since that breaks encapsulation right? Instead I'd want an overseeing class that takes care of collisions, some entity that knows all positions of all elements that are being drawn. It only makes sense then to have that entity take care of the places where objects are drawn.
@reallyWyrd
8 жыл бұрын
Greater abstraction leads to greater complexity -- more memory consumption and / or more processor time spent running through all the layers of abstraction.
@raykent3211
8 жыл бұрын
which is exactly why we should write in binary machine code. Pardon the sarcasm, I'm not wanting to be really nasty.
@DFX2KX
8 жыл бұрын
+I. Wyrd the trick is using the least amount of abstraction that you can while still having a modular project. done correctly, it's practically unnoticeable on anything made after the 90's. Taken to extremes, however, and we get Unity.....
@verifiedpurchase3486
8 жыл бұрын
+Computerphile The jump clips in the endroll are not linked to the videos they show.
@david2sdad
6 жыл бұрын
What is your get opinion of putting get in front of all accessors. This practice comes from Java Beans, but makes the grammar very strange. All of your nouns (and adjectives) turn into verbs: “Get would you like fries with that?“, “What is your get height?”, “if get name equals "root" then …”
@GogiRegion
6 жыл бұрын
I always hear people talking about how hard objects and classes are to people, but I always thought it was just super intuitive. Maybe I just found a good Java starting article (the first programming language I ever used classes in was Java, which is bassically forced object oriented programming [anyone who has ever used Java knows exactly what I mean]), but it always seemed really easy to me. IDK.
@silkwesir1444
6 жыл бұрын
2:35 of course, this is not what this video is about, but I would be interested in a video about that subject. the way it is shown there, to just adjust the position linearly while the key is pressed, is a kind of naive approach which won't work out as a proper replacement for the paddle controllers where you could turn the knobs and determine yourself how far and how fast you turn it. however, now you want to make a Pong game that is playable and fun with key presses, which only can be ON or OFF, nothing inbetween. usually, the way it is attempted to "solve" this, is by adding some kind of acceleration, so if you only tap the key quickly, it moves just a little bit to allow for fine movement, however the longer you hold it down, the faster it will go. however, what kind of function to use for this acceleration? there are many possibilities. i think this really is an "unsolvable" problem, meaning there is no "proper" way to solve it, but a lot of ways one can go about it which might be "good enough". is there one that is the best? are there differing opinions?
@ToniT800
8 жыл бұрын
But how does the ball object interact with paddle object? Do they share common variables?
@aiman4036
8 жыл бұрын
+Toni T800 The design Dr. Steve came up with was very minimal. But how it'd be done is via adding another operation (they're in fact technically referred to as methods, not operations) for the pad class; e.g: "handle_collision". In your code, you usually then do: pad1.handle_collision(ball) pad2.handle_collision(ball) The handle_collision method will reach out to see the ball's position and size, and see if the ball intersects with the box its position and size makes. If true, the operation will reverse the x-speed there.
@TheUglyGnome
8 жыл бұрын
+Toni T800 Definitely not shared variables. One way to do this: There's object 'Pong' which is in charge of gameplay 1. 'Pong' asks paddle, if it collides with ball 2. Paddle asks ball it's position 3. Paddle now knows if it collided and tells result to Pong 4. If collision happened, Pong tells ball to change it's direction
@minxythemerciless
8 жыл бұрын
Bad example to choose. Pong - or at least pong clones - were done with hard-wired TTL logic with a few up-down counters and a clock. It was so simple a copy could be made in a shortish evening on the kitchen table. Nary a computer in sight.
@zebroidalWorld
8 жыл бұрын
Could the volume of these videos be ANY lower?
@rob45311
8 жыл бұрын
I
@gownerjones2
8 жыл бұрын
My teachers and peers always praise OOP and hail it as the "only right way" to code, the moment you take off your training wheels, you'll be doing OOP. But I can't be the only one who doesn't like this, right? It seems like it limits one's abilities more than it aids them.
@yyny0
8 жыл бұрын
I agree. Most of these people don't even know what Functional programming is...
@localatticus4483
8 жыл бұрын
+HOLyPumpgun | Gaming | I don't quite like it, no. I use "OO" languages (I have yet to find a pure OO language, if that says anything about OO) but that's only because I'm extremely used to them. I'm actually designing/writing my own programming language that's procedural, though it MIGHT contain some less OO class kinda things.
@gownerjones2
8 жыл бұрын
Kai Kyouretsu Well hat sure sounds interesting. You have a name for it yet?
@jakejakeboom
8 жыл бұрын
take a look at a functional language like clojure, f#, or Scala. there's definitely a steep learning curve to functional languages coming from an OOP background but I promise it's worth learning FP.
@localatticus4483
8 жыл бұрын
HOLyPumpgun | Gaming | calling it Score
@SB-hs4yn
8 жыл бұрын
If you want to learn more about OOP, i'd suggest going with a language such as Java, or C#. C++ is fine, but it's not exactly beginner friendly (Considering you are a beginner).
@astronot1997
8 жыл бұрын
Scratch is the best choice for beginners
@astronot1997
8 жыл бұрын
sloan boyce Yeap
@raykent3211
8 жыл бұрын
+Bahadır Onur Güdürü I've only seen one example of scratch, involving a cartoon cat, so I don't know how flexible it is. Would you recommend it for a beginner who wants to make a robot respond to a whistle, for example?
@astronot1997
8 жыл бұрын
Ray Kent I have made a two-player 2D soyuz docking simulator and a basketball game which uses a physics algoritm also made by me. Without any programming experience I made those in 3-4 hours. I am not sure about what it can do, I am not that experienced but I am sure that no-other program can provide you that easyness. I have read somewhere that an arduino can be programmed by Scratch but again I am not sure. So if you want to make games, yes it's useful but if you want to do other programming things it is not apropriate.
@raykent3211
8 жыл бұрын
Bahadır Onur Güdürü fantastic! Well done, I'll look into it.
@peteBS147
8 жыл бұрын
Thank you Dr Steve, your video was clear and very helpful. However, there is one thing that is confusing me? Given that both the paddle and the ball have an X,Y position, does the:- paddle look out for whether it has hit the ball or the ball look out for whether it has hit the paddle? Perhaps they are equally valid? Many thanks, Pete
@asz1029
7 жыл бұрын
I would say the container object (which was forgotten in the video, and has 'Width', 'Height', and 'ContainedObjects') should look out for any two objects which are contained in it colliding either with each other or the container's wall.
@mikicerise6250
2 жыл бұрын
If the ball is below the paddle when you try to move the paddle down, wouldn't the paddle and ball need some logic to avoid one being drawn over the other? Where would that logic go?
@kametrixomtikara8726
8 жыл бұрын
Much better than the first video on OOP haha
@minijimi
8 жыл бұрын
Thanks for putting it into words.
@TheMrTape
8 жыл бұрын
If you don't have a proper overview and handle of your program, that's the problem, so don't solve it by using OOP; that will obfuscate the overview further and thereby lessen the ease of modifications and complex code writing. OOP breeds carelessness, half-assed code, and worse comprehension of the underlying logic (making assuming facts and solving problems according to that understanding much more difficult/impossible). If you use the same constant several times, define the constant and share it; not doing so is amateurish and counterproductive to begin with. If you have too many variables to keep track of all the names, give the names a prefix fitting their purpose, eg. DB_EntriesNum or GFX_DisplayWidth (notice usage of capitals for easier readability, might tickle your lowercase variables OCD a little; also notice the very specific and non-cryptic naming so you don't have to go bonkers with comments). Finally, always/rigorously use functions instead of repeating the same code over and over within separate code segments. Simply make sure that you only have to change/modify specific constants/functionality in one place (unless it becomes counter productive, like defining a constant for two adjacent obvious usages of the same number), then you remove the problem that otherwise forces the burden of OOP onto you (less control, less overview, less potential, less production efficiency, less comprehension, less skill development).
@Eeroke
8 жыл бұрын
+TheMrTape Hear, hear. OOP is a burden unless it's something truly big and complex like an operating system kernel, a game enfine or a desktop environment. In other words, if there's black box, with a lot of internal state with various relations, then it's worth it, not in an application with internal state equivalent to an elevator controller.
@normannormiemates4844
8 жыл бұрын
+Tanooki100 so what languages are there for these simpler apps? They all seem to be object orientated
@Muzer0
8 жыл бұрын
+TheMrTape Completely disagree. OOP massively improves type safety, and in fact I find makes it significantly easier to comprehend programs. You provide some vague statements at the beginning and end of your post without explaining any of them. How about actually giving an example of how OOP would breed carelessness, or forces you to have less control or less overview. OOP gives you MORE overview, as it's much easier to see how the basic elements of the program interact with each other. And yes, I do have plenty of experience in both OOP and non-OOP languages. I enjoy programming in C, but I would never make a big end-user desktop application in it. I would in C++, if the low-level access and performance of C++ were desirable.
@SephirothITM
8 жыл бұрын
+TheMrTape In my experience, Object Orientation pays for itself in terms of ease of maintenance. As a program grows, the time wasted by interference between pieces of code that are conceptually unrelated increases and OOP is the best tool to prevent this from being a problem. In fact, I can go a step further and state that object orientation becomes worthwhile for any project that is being developed my multiple people; as simple, well defined interfaces between objects allows two programmers to work completely independently and still create a working product. So, essentially all commercial/academic applications should be written using OOP. The ability to write a program in modules that can be exchanged with one another seamlessly through abstraction is one of the most appealing aspects of object orientation in my opinion; Getting away from having to learn a program before you can improve it is another.
@Eeroke
8 жыл бұрын
+T Riddle All the languages. You just try to refrain defining a horde of your own objects and their hierarchy "just in case", unless a truly object like subset starts to emerge in your variables and code. Following YAGNI -principle. I generally follow principle that small rewrite once a paradigm is emerging is a lesser evil than adhering to a paradigm that's ill-suited or unnecessary. There's nothing bad in using objects written by others. Done right, they are a fine abstraction for libraries. Even old school languages such as C do OOP on this level all the time. The difference is that in old school languages one generally doesn't think of inheritance before it truly becomes necessary to.
@isaacc7
8 жыл бұрын
It sounds like OOP has advantages because it allows a kind of modularity in the program itself. On the other hand, it seems like it could be more verbose and maybe not the most efficient way of running a program. I'd think that OOP on really limited hardware might be too slow. Do you think they used OOP on that original pong console?
@stensoft
8 жыл бұрын
+isaacc7 Well, it all depends on how strongly the programming language enforces the rules (or in other words: how easily you can break them). E.g. C++ does not check the rules when the programme is running which allows it to have almost no overhead so if you programmed the game in C++, it can run on the original console. By contrast, Java checks the rules all the time which has quite a lot of overhead so it won't be possible to run it on such limited hardware. On the other hand, if you make an error in C++, because the rules are not enforced, it may do very weird things which makes it quite hard to figure out what happened. In Java, the programme will crash just as your code tried to break the rules so it's much easier to debug.
@raykent3211
8 жыл бұрын
+Mike Meyer ooh, someone mentioned arduino! I love it. in context, you understand, cos I can program the chip (uno) at assembler level, but it's a really pragmatic combination, and, as you say, a bit classic C and a bit OO. Avoiding the megabrain scariness of c++.
@raykent3211
8 жыл бұрын
***** I forgot to ask... what kind of project?
@raykent3211
8 жыл бұрын
***** I really don't want to pester you, I assume that if it's an electric motor drone then the energy requirement of the processor is negligeable. I'd be fascinated to hear more, if you have got the time.
@DFX2KX
8 жыл бұрын
+Mike Meyer There's not that much C++ in the Aurdino libs, and plenty of sketch writers avoid classes entirely just to squeeze a tiny bit more out of the abysmally small RAMspace.
@bjzaba
8 жыл бұрын
I'm pretty glad that web front-end development is moving away from OOP to stuff like React and Elm... encapsulated state is pretty nasty to reason about in large scale codebases.
How OOP is related to APIs? On the surface they seem to be very much related concepts, with main difference being scale?
@boenrobot
8 жыл бұрын
+Vaidas Šukauskas In simple (if not over-simplistic) terms, the word "API" refers to the actual "thing" that everyone sees out of your program/library from the outside ("outside" often being "their program/library"), whereas OOP is one way in which this thing could work on the inside.In slightly more technical terms, an API could be just a set of functions (which is not OOP), whereas OOP is how structures like "classes" and similar ones work (and that's another way to create an API).
@DFX2KX
8 жыл бұрын
+boenrobot and now and again, you'll have APIs that take a bit from both collums, which is arguably more confusing then it needs to be....
@rockets4kids
8 жыл бұрын
Ironically, the original Pong arcade game was implemented entirely using logic gates. No CPU or software was used in the implementation.
@SyedRizvii
8 жыл бұрын
a little demo code in C or Java or any suitable language would be much appreciated. It would help in consolidating the concept. Great video though! cheers.
@glitchsmasher
8 жыл бұрын
Wouldn't the ball have either a Velocity variable that also stores the balls direction? Or even a separate direction variable alongside speed?
@wesofx8148
8 жыл бұрын
It would probably have a velocity vector. A speed variable could be used as a factor for the velocity, or you'd simply just increase the size of the time-steps to make the ball and paddles move faster
@glitchsmasher
8 жыл бұрын
+Willy Goat Speed with direction? That's velocity. You just said my point.
@wesofx8148
8 жыл бұрын
glitchsmasher By speed I mean a speed factor. If you multiply the velocity vector by the speed factor, you can increasing the speed of the ball over time by increasing the speed factor over time. In pong, it's common for the game to get faster and faster.
@wesofx8148
8 жыл бұрын
glitchsmasher Speed * Direction = Velocity So maybe we mean the same thing
@CatnamedMittens
8 жыл бұрын
I missed Steve Bagley.
@sawilliams
5 жыл бұрын
Don’t forget the “stage “ object, that manages all the objects on the screen aka stage.
@mohammadshahabrafiq
Жыл бұрын
Excellent video.
@xan-kunclark-davis3747
8 жыл бұрын
PONG was completely analog! If they had used "OOD", it would have taken another two decades beforde they could build one ;-)
@tgckpgAtgmail
8 жыл бұрын
Can you do an introduction about AOP? Wikipedia said it is patented by Xerox. And there isn't much information or resources out there.
@logancapes
5 жыл бұрын
geez, what kind of razor does dr bagley use? skin so smooth i thought he was computer generated. 6:54
@srinagrao1
8 жыл бұрын
why does the paddle go up at 2:47 ?
@andrewmorris483
8 жыл бұрын
They need to do one in the BSOD. I wonder why it isn't green or red for example. Also the origin of it
@slap_my_hand
8 жыл бұрын
You also need an angle variable for the ball.
@il2xbox
8 жыл бұрын
+StarTrek123456 Not necessarily, all you need is integer values for x and y positions, and the x and y components of velocity. Then moving the object around the screen or finding out where an object is is very easy, you don't need an angle.
@slap_my_hand
8 жыл бұрын
il2xbox If you don't have an angle variable, the ball could only move at 45 drgrees or some other specific angle.
@il2xbox
8 жыл бұрын
StarTrek123456 No, you can change the x and y components of the velocity to change the angle
@il2xbox
8 жыл бұрын
StarTrek123456 That works, but in my opinion it's easier to just use the x and y components of the velocity rather than storing the angle because then you have to use Math.sin() and Math.cos() to convert it to x and y anyway, which probably slows down the program. But with any programming problem there are always different ways to do the same thing, usually they're all perfectly valid. For a simple game like Pong it doesn't really matter anyway.
@grahammurray8707
6 жыл бұрын
BTW pong was an arcade game and we encountered it in the UK first as ping for obvious reasons.
@srinidhiskanda754
7 жыл бұрын
thank you oop vs functional which is better in what situation
@lepidoptera9337
Жыл бұрын
Why in the world would you use "Pong" as an example?
@0colorad0
4 жыл бұрын
"So many different terms; objects sending messages to other objects... And, well, not much else happening. In fact, that's the only thing"
@noctavel
6 жыл бұрын
what about inheritance?
@Roxor128
8 жыл бұрын
Like most tools, OOP has its occasions when it's the right tool for the job, and others where it doesn't really fit. Some parts of your program might be good candidates for it, others, not really. If it's right for that part, then use it. If not, use some other approach. Games are an example of where you might use both object oriented and procedural programming. The sound and graphics systems will be procedural, while the myriad of things in the game world will be objects.
@DFX2KX
8 жыл бұрын
+Roxor128 yeah. The engine interface will usually be class based. or the proedural stuff will be buried in the 'private' functions of the renderer object, with only the command functions to tell it what task it should be doing exposed. Game logic itself is a decent candidate: it's pretty common in level editors for triggers and the like.
Пікірлер: 533