 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| OOP or functional? |
| Object Oriented Programming |
|
46% |
[ 6 ] |
| Functional Programming |
|
53% |
[ 7 ] |
|
| Total Votes : 13 |
|
| Author |
Message |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Fri Aug 24, 2007 9:46 am Post subject: |
|
|
| Icos wrote: | In mathematics,
1d = points
2d = lines |
In mathematics,
0d = point
1d = line
2d = plane
3d = space.
| Quote: | | You would check the properties of the balls (passing a pointer to the ball structure) to determine shatter risk, not the type, so you don't have to expand that code. |
You're missing my point. I was talking about the ease of expansion of OOP. Continuing with the example: you have implemented a variable to specify the degree of shattering inside a ball structure while an OOP programmer have implemented specific methods for each ball in separate classes. Now, both of you deploys your program. Then, a new kind of ball must be added, one that doesn't bounce, but instead passes right through the floor. You now must go back to your structure, add a variable to check whether the ball would pass through the floor, then update the already large drop() function so that the new variable would do something. The OOP programmer on the other hand, could simply create a new class with a different drop method. This method is clean and short, reducing the chance for mistake and time to code. Also, the OOP programmer would simply add the new class to the program whereas you must recompile your whole coding.
| Quote: | | Well you can do that but it's silly because you're wrapping a perfectly find procedural method with objects for the sake of object orientation. |
Again, the other way could be said without difficulty:
| Quote: | | Well you can do that but it's silly because you're taking a perfectly fine OO method and putting it into a functional method for the sake of making your point. |
Making gravity an object is very acceptable in OOP. Gravity applies a force on objects, which is determined by the mass of the two objects and the distance between them. A gravity object could implement these variables, allowing them to be changed, thus one would be able to create gravity objects for earth and the sun, then calculate the force in between the two gravity objects using a method implemented in the gravity class.
| Quote: | | If you are made to think in that rigid, unnatural sort of way. I could teach people that organizing your source code by virtual spaghetti plates, and develop tools and languages for it! That doesn't mean everyone who doesn't conform is a fool. |
Yes you could. And if it has advantages over the functional way of organizing source code, I'm pretty sure people would learn it.
| Quote: | | What do you have to say about people who develop operating systems? It's not a new way of doing things that supersedes the old way, it's a different way of thinking. More beginning programmers are being pushed through this mold, though, so some part of that is true. |
I mentioned large applications. By my definition of applications, they exclude OS's. Of course, down in the lowest level of computers, OOP just simply cannot exist because it is, after all, a virtual concept. Implementing OOP in places such as OS's would probably bring more trouble than it's worth due to the large amounts of system interactions needed. However, in large applications, where many programmers need to work on the same project, OOP provides the programmers with an easier way of organizing source code.
No, OOP is not a new way of doing things that supersedes the old way in ever aspect. However it does provide convenience to the programmers in the majority of programming environments.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
TheSorc3r3r I post too much
Reputation: 0
Joined: 06 Sep 2006 Posts: 2404
|
Posted: Fri Aug 24, 2007 7:45 pm Post subject: |
|
|
It seems to me like the greatest argument for OOP is organization, which I don't understand.
Why is OOP better in this case?
I want to minimize my program to system tray. I could
a) write two functions, MinimizeToTray() and MaximizeFromTray(), and put them in tray.cpp. Then I put their declarations in tray.h. Other parts of the project can easily use those functions. Very easy to use; just call them!
b) write a class that encapsulates the whole thing, CSystemTray, put its declaration in tray.h and function bodies in tray.cpp. Then others part of the project can use the class. This adds the annoyance of having to deal with objects, worrying about public and private information, making sure everything is encapsulated properly; from my experience, WAY too much work which could be done with 2 simple functions.
_________________
Don't laugh, I'm still learning photoshop! |
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Fri Aug 24, 2007 8:50 pm Post subject: |
|
|
| TheSorc3r3r wrote: | It seems to me like the greatest argument for OOP is organization, which I don't understand.
Why is OOP better in this case?
I want to minimize my program to system tray. I could
a) write two functions, MinimizeToTray() and MaximizeFromTray(), and put them in tray.cpp. Then I put their declarations in tray.h. Other parts of the project can easily use those functions. Very easy to use; just call them!
b) write a class that encapsulates the whole thing, CSystemTray, put its declaration in tray.h and function bodies in tray.cpp. Then others part of the project can use the class. This adds the annoyance of having to deal with objects, worrying about public and private information, making sure everything is encapsulated properly; from my experience, WAY too much work which could be done with 2 simple functions. |
The reason that OOP in this case seems to be unnecessarily cluttered is that the situation is not complex enough for OOP to show its true power. Two methods which controls the window state of some window does not constitute a true OOP class. The methods would be better implemented in a generic Window class. Now, different types of windows may inherit the methods from this Window class. A class serving as the main window would perform what the method name suggests, minimize/maximize to tray. However, a MDI child window may override the method to simply minimize the window to a special region of the parent window.
Using procedural programming to accomplish the same tasks would either involve different procedures and functions for each type of window which would create confusion in the very naming of the procedures such as MinimizeToTray(), MDIChildMinimizeToTray(), MDIParentMinimizeToTray(), etc. OOP would not have this problem as all classes implementing the Window class/interface would have methods with the same name, in this case, MinimizeToTray().
A large function may also be used to check the type of the window to execute specific functions for each. This would lead back to the ball argument earlier.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Sat Aug 25, 2007 1:39 pm Post subject: |
|
|
LOL
0d = point
1d = line
2d = plane
3d = space
Oops, I didn't see DeltaFlyer's post.. Sorry about that
|
|
| Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Sun Aug 26, 2007 9:54 am Post subject: |
|
|
People I know, who's views on the question are relevant:
Person A: "I would bother with OOP if more projects succeeded with it than without it".
Person B: thinks OOP is useful when used lightly - not trying to use every complicated feature of OOP.
Person C: I love OOP, because you can (and he did) make a living off of knowing all the minuscule details.
I, personally, dislike C++ as it is very improvised - it is "C with OOP", rather than "An OOP language". That is, Stroustrup took C and used it as the base for a "proof of concept". When he designed it he was in an environment where it was considered taboo to change any core features.
I like Java's syntax better than C/C++, but I hate using it.
For me, its functional programming all the way. I'm not going to be starting any huge projects with many programmers anytime soon.
~nog_lorp
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
| Back to top |
|
 |
TheSorc3r3r I post too much
Reputation: 0
Joined: 06 Sep 2006 Posts: 2404
|
Posted: Sun Aug 26, 2007 10:35 am Post subject: |
|
|
Well, the big project organization is an important point for me next year; I'm joining the programming section of robotics club. Idk if they're going to use OOP, but I guess I should read up on it..
_________________
Don't laugh, I'm still learning photoshop! |
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Sun Aug 26, 2007 11:12 am Post subject: |
|
|
| TheSorc3r3r wrote: | | Well, the big project organization is an important point for me next year; I'm joining the programming section of robotics club. Idk if they're going to use OOP, but I guess I should read up on it.. | My school's robotics club uses Java as the language, so it's possible your school will as well.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
TheSorc3r3r I post too much
Reputation: 0
Joined: 06 Sep 2006 Posts: 2404
|
Posted: Sun Aug 26, 2007 11:37 am Post subject: |
|
|
They said that their main language was C++.
_________________
Don't laugh, I'm still learning photoshop! |
|
| Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Sun Aug 26, 2007 6:46 pm Post subject: |
|
|
| DeltaFlyer wrote: | | TheSorc3r3r wrote: | | Well, the big project organization is an important point for me next year; I'm joining the programming section of robotics club. Idk if they're going to use OOP, but I guess I should read up on it.. | My school's robotics club uses Java as the language, so it's possible your school will as well. |
My brother does coding for a pretty big robotics department, next time I talk to him I'll ask him what their setup is. I'm pretty sure it is plain C or IC assembler though.
One really important feature of OOP is that it enforces good practices in regards to inter-programmer work. If all you see is the public class information, you cannot rely on implementation. Relying on another programmers implementation is very bad, because it could change at any time, breaking your work. All you are allowed to rely on with OOP are the public features of the class.
~nog_lorp
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|