Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 29020

A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

5 votes

Criteria for a language to be considered "object oriented"

According to Rumbaugh et al., "Object-Oriented Modelling and Design", objects are characterized by the following features: Identity: data is quantized into discrete, distinguishable entities, called …
Giorgio's user avatar
  • 19.8k
1 vote

If immutable objects are good, why do people keep creating mutable objects?

I think using mutable objects stems from imperative thinking: you compute a result by changing the content of mutable variables step by step (computation by side effect). If you think functionally, y …
10 votes

Is functional programming a superset of object oriented?

I find the following intuition useful to compare OOP and FP. Rather than considering FP as a superset of OOP, think of OOP and FP as two alternative ways of looking at a similar underlying computatio …
Giorgio's user avatar
  • 19.8k
1 vote

Can objects be implemented in terms of higher order functions?

You can think of an object as a closure that closes over the member variables of the object and, each time it is invoked with a method name, it returns a method implementation. You can then apply the …
Giorgio's user avatar
  • 19.8k
1 vote
Accepted

Collection of objects that can decide to split themselves in half

Disclaimer This solution is not object-oriented, but maybe still interesting. TL;DR Going with your first idea (have Update return a list of Organisms), in Haskell you can define a type Organism, …
Giorgio's user avatar
  • 19.8k
1 vote
Accepted

How do you manage cross-class dependencies on destruction/design (more of a C++ question)

One solution could be to use smart pointers (for example, in Qt you have the class QPointer) instead of references: as soon as an object is destroyed, a smart pointer that was pointing to it will be s …
Giorgio's user avatar
  • 19.8k
10 votes
4 answers
3k views

How are entities with an identity and a mutable persistent state modelled in a functional pr...

In an answer to this question (written by Pete) there are some considerations about OOP versus FP. In particular, it is suggested that FP languages are not very suitable for modelling (persistent) obj …
Giorgio's user avatar
  • 19.8k
8 votes
3 answers
955 views

Do any object-oriented programming languages support "collective constructors"?

I was recently considering that sometimes several objects depend on each other (e.g. if they contain cyclic references) and therefore it would be useful to create them as part of one atomic operation …
Giorgio's user avatar
  • 19.8k
5 votes
1 answer
1k views

Can methods in an OOP language be considered as some kind of closure?

Consider a method m of a class A in an object-oriented language like Java or C++. In the body of the method m it is possible to reference the member variables of the object on which the method is inv …
Giorgio's user avatar
  • 19.8k
6 votes

What makes C so popular in the age of OOP?

I cite two points from another answer, because they capture exactly the reasons why I still use C from time to time (it is not my main language of choice, though): C is simple. It lacks the expressi …
4 votes
Accepted

Learning OO for a C Programmer

I also learnt object-oriented programming coming from procedural programming (Pascal and C) so I can understand the difficulty of the switch: you have to start thinking differently, and you already ha …
Giorgio's user avatar
  • 19.8k
3 votes

Is OOP hard because it is not natural?

EDITED First of all I would like to say that I never found OOP hard, or harder than other programming paradigms. Programming is inherently hard because it tries to solve problems from the real world …
5 votes

Are first-class functions a substitute for the Strategy pattern?

It is not true that an anonymous function can only hold state that ceases to exist when the function finishes execution. Take the following example in Common Lisp: (defun number-strings (ss) (let …
Giorgio's user avatar
  • 19.8k
2 votes

How to refactor an OO program into a functional one?

You would probably have to turn all your code inside out since OOP and FP have two opposite approaches to organizing code. OOP organizes code around types (classes): different classes can implement t …
Giorgio's user avatar
  • 19.8k
6 votes

Does functional programming increase the 'representational gap' between problems and solutions?

I would like to stress an aspect that I find important and that has not been covered in the other answers. First of all, I think that the representational gap between problems and solutions can be mo …
Giorgio's user avatar
  • 19.8k

15 30 50 per page