Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am having a very strange question, although I am learning OOPS through C++ since last few months. That why there is a need of a construct like class?
There is no need for classes in object-oriented programming. There are lots of languages which do just fine without them: Self, Io, Ioke, Seph, Slate, NewtonScript and ECMAScript have only objects, no classes. Other languages have mixins. Yet other languages have traits. Some languages have classes and mixins, some classes and traits.
The only thing you really need for object-orientation is some way to perform procedural abstraction. That's it. Lambda Calculus is a perfectly fine OO language, in fact, since it has only procedural (well, actually functional) abstraction and nothing else, one might argue that Lambda Calculus is the purest OO language of all.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I read about OOP and Function programming. And I found both have pros and cons.
Such as:
OOP: have side effect, and sometimes it is very usefull
Function: easy to code and think. But don't have side effect and loop.
And I wonder if I can using both OOP and Function paradigm in one project. Is it be recommended in practice?
There's nothing preventing both paradigms from being used together. Arguments on each side sometimes can be misleading as people tend to focus on languages and their features as opposed to the paradigms themselves. OOP doesn't need to have state/side effects, and functional programming doesn't always make things easier or faster. The good engineer will use the right tools for the right task, which means getting a good understanding of both.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
How Composition is a lesser principle level, than Inheritance? One always has to consider Composition over Inheritance, but there is no mention of Composition in the four major OOP principles. What is the reason behind this? Are they not at the same level?
Composition is a lower-level and a much older concept than inheritance; it comes from the analysis-synthesis approach which basically states that things are either composed of other things or trivial (atomic). It was first introduced back in ancient Greece as a general approach to understanding things.
Composition is not specific to OOP, e.g. in plain C, which is far from being OO, structs are authored using composition, likewise in functional programming functions are composed of other functions, though the nature of composition is totally different in these two examples.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm almost new to programming and I came to this question that:
why should object carry code along with data? isn't packing data enough?
For example:
Instead of having 5 employee objects that each has a getDataOfBirth() method (consuming more memory), have a single method in global space and have 5 object with only attributes(smaller objects).
Am I getting something wrong? Is my question even considered general and possible to be occurred in every newbie's mind?
The linguistic aspect of it:
This is an idea that OOP skeptics have been talking about for a long time, but it's more of a matter of preference I would say. If you are new to programming and already are thinking about these things, then maybe functional programming would make a lot of sense to you.
The memory aspect of it:
The functions are typically not stored inside the objects, so OO objects that have a lot of functions do typically not carry those functions around. This is however an implementation detail but most OOP languages should be thought of like that.
Especially in the case of natively compiled languages like C++, the code and the data will be separated into different memory areas altogether and will not really mix. That is also a bit of an implementation detail but all mainstream operating systems, as far as I know, will allocate memory with code separated from data. The functions of a class will be allocated in one area and the data of the objects in another, and normally all objects of the same class will use the same functions.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Every programming/scripting language that I have heard of is an Object Oriented Programming (O.O.P) language. What are some examples of languages that aren't considered an O.O.P language.
OOP is a paradigm, not language. Some languages like Javascript or PHP can use OOP, but don't need to (they are multiparadigmatic).
Some languages like C# or Java have to use objects, but that doesn't mean the programs need to be Object-Oriented. In that case it is considered bad design, though. There are even antipatterns that describe screwed OOP, although C# supports coding sugar like lambdas or linq that is not OOP.
Some people try to emulate their favorite paradigm in languages that don't support it well. For example, jQuery tries to use functional (or monadic) paradigm and some say it is not a good idea (although the library is very popular).
I recommend this article to get grasp of most popular paradigms and their difference to OOP.
Assembly, C, BASIC, Fortran, Forth, Pascal, Brainf**k, Malbolge, and dozens upon dozens more.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
What are the best practices for separating data in different classes? Not just objective c, but programming in general.
For example, if someone was making a game like angry birds, how one manage classes?
Would you have a separate class for just the projectiles (in angry birds case, the birds) and have different classes for the targets, music and images, etc?
There is no simple answer to this. You first need to really understand, deep in your soul, how object-oriented programming works and what it represents. Then you need to make your own decisions based on that understanding and your understanding of the problem at hand.
I've seen many "cookbook" applications of OO and MVC and the like that are terrible, even though the writers dotted all the i's and crossed all the t's and their college professors would have given them an A+ on the project.
But in general I'd probably have a common superclass (with several subclasses) for entities that represent visible, movable objects, but probably not use that for music, eg.
not even data but your functional approach must be modular. create as many smaller components in terms of classes and define their behavior as methods and set the interaction between them through the Game Manager/Logic control system that you design for your game...
Best of luck..!!