A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner
43
votes
14answers
6k views
When are Getters and Setters Justified
Getters and setters are often criticized as being not proper OO. On the other hand most OO code I've seen has extensive getters and setters.
When are getters and setters justified? Do you try to ...
51
votes
14answers
11k views
Where does this concept of “favor composition over inheritance” come from?
In the last few months, the mantra "favor composition over inheritance" seems to have sprung up out of nowhere and become almost some sort of meme within the programming community. And every time I ...
20
votes
3answers
11k views
Programming SOLID Principles
Over time I could understand two parts of SOLID – the “S” and “O”.
“O” – I learned Open Closed Principle with the help of Inheritance and Strategy Pattern.
“S” – I learned Single Responsibility ...
53
votes
4answers
4k views
Functional Programming vs. OOP
I've heard a lot of talk about using functional languages such as Haskell as of late. What are some of the big differences, pros and cons of functional programming vs. object-oriented programming?
24
votes
11answers
3k views
What is Object Oriented Programming ill-suited for?
In Martin Fowler's book Refactoring, Fowler speaks of how when developers learn something new, they don't consider when it's inappropriate for the job:
Ten years ago it was like that with objects. ...
32
votes
9answers
2k views
Code Smell: Inheritance Abuse
It's been generally accepted in the OO community that one should "favor composition over inheritance". On the other hand, inheritance does provide both polymorphism and a straightforward, terse way of ...
36
votes
2answers
2k views
Are there any OO-principles that are practically applicable for Javascript?
Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by:
Writing the functions to be used as classes by yourself
Use a nifty class system ...
43
votes
14answers
7k views
What makes C so popular in the age of OOP?
I code a lot in both C and C++, but did not expect C to be the second most popular language, slightly behind Java.
TIOBE Programming Community Index
I'm curious as to why, in this age of OOP, C is ...
8
votes
4answers
662 views
How much design to do first?
I have never worked with a professional software development team. As such, analyzing and thinking about each and every aspect of my software does not come naturally to me.
Whenever I strike an idea ...
37
votes
11answers
5k views
Advantages of object-oriented programming
Note: this question is an edited excerpt from a blog posting I wrote a few months ago. After placing a link to the blog in a comment on Programmers.SE someone requested that I post a question here so ...
18
votes
11answers
3k views
What's the BEST way to really understand OOP? [closed]
What's the BEST way to really understand OOP? Any video's/Screencasts that you would recommend?
25
votes
8answers
8k views
Is ORM an Anti-Pattern? [closed]
I had a very stimulating and interessting discussion with a colleague about ORM and its pros and cons. In my opinion, an ORM is useful only in the rarest cases. At least in my experience.
But I don't ...
39
votes
2answers
2k views
So what *did* Alan Kay really mean by the term “object-oriented”?
Reportedly, Alan Kay is the inventor of the term "object oriented". And he is often quoted as having said that what we call OO today is not what he meant.
For example, I just found this on Google:
...
10
votes
7answers
1k views
What can go wrong if the Liskov substitution principle is violated?
I was following this highly voted question on possible violation of Liskov Substitution principle. I know what the Liskov Substitution principle is, but what is still not clear in my mind is what ...
9
votes
1answer
384 views
How to verify the Liskov substitution principle in an inheritance hierarchy?
Inspired by this answer:
Liskov Substitution Principle
requires
that
Preconditions cannot be strengthened in a subtype.
Postconditions cannot be weakened in a subtype.
Invariants ...
11
votes
3answers
3k views
Clarify the Open/Close Principle
As I have had it explained, the open/close principle states that once written code should not be modified (aside from bug fixes). But if my business rules change shouldn't I modify the code ...
5
votes
3answers
1k views
OOP oriented PHP app source code samples and advice
The day I have been dreading has arrived. I never felt OOP or good software design was important(I knew they were important, but I thought I could manage without them.). However having read otherwise ...
10
votes
3answers
938 views
“Too object-oriented”
I come from a strong OO background, and I have recently started working in an organization which, although the code is written in Java, has a lot less emphasis on good OO design than what I am used ...
2
votes
4answers
1k views
When or why should one use getters/setters for class properties instead of simply making them public properties?
I program primarily in ColdFusion but this is a general OOP question.
Is there any benefit to using:
getProp() {
return prop;
}
setProp(val) {
prop = val;
}
As opposed to simply
obj = ...
66
votes
20answers
4k views
Is OOP hard because it is not natural?
One can often hear that OOP naturally corresponds to the way people think about the world. But I would strongly disagree with this statement: We (or at least I) conceptualize the world in terms of ...
15
votes
11answers
2k views
What made object oriented programming successful? [closed]
What is that feature according to you that has made object oriented programming so much successful ?
Message Passing
Inheritance
Polymorphism
Encapsulation
Or some other feature that you may like ...
28
votes
11answers
6k views
What's the benefit of object-oriented programming over procedural programming?
I'm trying to understand the difference between procedural languages like C and object-oriented languages like C++. I've never used C++, but I've been discussing with my friends on how to ...
29
votes
8answers
1k views
Clarify the Single Responsibility Principle
The Single Responsibility Principle states that a class should do one and only one thing. Some cases are pretty clear cut. Others, though, are difficult because what looks like "one thing" when ...
20
votes
8answers
3k views
What is the ideal length of a method?
In object-oriented programming, there is no exact rule on the maximum length of a method , but I still found these two qutes somewhat contradicting each other, so I would like to hear what you think.
...
18
votes
5answers
1k views
How do I prove or disprove “god” objects are wrong?
Problem Summary:
Long story short, I inherited a code base and an development team I am not allowed to replace and the use of God Objects is a big issue. Going forward, I want to have us re-factor ...
16
votes
11answers
2k views
is OOP the dominant programming model in real world?
Objects Never? Well, Hardly Ever
In the VIEWPOINT section of Communications of The ACM, I found an
interesting article entitled "Objects Never? Well, Hardly Ever".
It’s a radically different ...
25
votes
17answers
4k views
How can I feel more confident about my programming skills? [closed]
Programming isn't alien to me. I first starting doing markup (HTML, now please don't laugh at me) when I was 12 and a little bit of BASIC when I was 13 (I knew much about Flowcharts, Pseudocodes at ...
13
votes
5answers
1k views
How to make the transition to functional programming?
Lately, I have been very intrigued with F# which I have been working a bit with. Coming mostly from Java and C#, I like how concise and easily understandable it is. However, I believe that my ...
31
votes
20answers
4k views
Does Object Oriented Programming Really Model The Real World? [closed]
I've seen it commonly repeated the object oriented programming is based on modelling the real world, but is it?
It seems to me that is not true of anything outside of the business layer. My GUI ...
16
votes
5answers
2k views
Is objected oriented programming paradigm outdated since it is anti-modular and anti-parallel?
I have read the controversial article Teaching FP to freshmen posted by Robert Harper who is a professor in CMU. He claimed that CMU would no longer teach object oriented programming in the ...
19
votes
6answers
2k views
Does learning a functional language make a better OOP programmer?
As a Java/C#/C++ programmer I hear a lot of talk about functional languages, but have never found a need to learn one. I've also heard that the higher level of thinking introduced in functional ...
11
votes
1answer
2k views
What did they call Object-Oriented Programming before Alan Kay invented the term?
Alan Kay claims that "I made up the term "object-oriented", and I can tell you I did not have C++ in mind." What he had in mind, of course, was Smalltalk. But he did not make up object-oriented ...
6
votes
6answers
537 views
What are the practical ways to implement the SRP?
Simply what are the practical techniques people use to check if a class violates the single responsibility principle?
I know that a class should have only one reason to change, but that sentence is ...
13
votes
3answers
708 views
Pure virtual or abstract, what's in a name?
While discussing a question about virtual functions on Stack Overflow, I wondered whether there was any official naming for pure (abstract) and non-pure virtual functions.
I always relied on ...
21
votes
11answers
1k views
Is pure oop necessary
Please don't direct me to this post: http://stackoverflow.com/questions/1551/how-to-think-in-oo.
I have read it and still have no answer.
I have programmed c++ for years and was taught that ...
12
votes
6answers
768 views
Method chaining vs encapsulation
There is the classic OOP problem of method chaining vs "single-access-point" methods:
main.getA().getB().getC().transmogrify(x, y)
vs
main.getA().transmogrifyMyC(x, y)
The first seems to have ...
10
votes
8answers
2k views
What is the point of an interface? [duplicate]
Possible Duplicate:
When to use abstract classes instead of interfaces and extension methods in C#?
What other reasons are there to write interfaces rather than abstract classes?
This ...
8
votes
7answers
2k views
Structured programming versus OO programming
I am making a presentation that shows the differences between structural and object oriented programming and I want to illustrate why people need OOP with an example where applying OOP concepts will ...
4
votes
4answers
588 views
Why are public and private accessors considered good practice? [duplicate]
Possible Duplicate:
When are Getters and Setters Justified
Why exactly is having public and private accessors like these:
private string foo;
public string Foo
{
get
{
...
25
votes
13answers
3k views
Why are objects passed by reference?
A young co-worker who was studying OO has asked me why every object is passed by reference, which is the opposite of primitive types or structs. It is a common characteristic of languages such as Java ...
6
votes
4answers
786 views
How does thinking on design patterns and OOP practices change in dynamic and weakly-typed languages?
There is a fairly helpful question already along these lines ("Non-OOP Design Patterns?"), but I am more curious about a transitional point of view for someone just getting started with dynamic and ...
5
votes
3answers
256 views
Suggest an Introductory OO Text for a (smart) non-programmer? [duplicate]
I have a colleague who has basic* programming skills and who wants to get a working knowledge of object-oriented programming concepts, with particular emphasis on C# (to 3.0 at least). He's generally ...
4
votes
1answer
294 views
Is wrapping a third party code the only solution to unit test its consumers?
I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of Zend_Mail class which is in Zend framework.
Now ...
4
votes
7answers
4k views
When is C a better choice than C++? [closed]
I can't imagine that there's any reason not to use the OOP features of C++. It's is just as fast as C, and - what's more important to me - it's transparent, just as C. (I mean "transparent" that I ...
2
votes
4answers
1k views
PHP, structural or OOP based language? [closed]
I would like to discuss why is PHP called a structural language? what are the OO concepts that cannot be implemented using PHP?
0
votes
3answers
1k views
How to apply good Object Oriented Design principles in Embedded Systems [closed]
I am a firmware engineer moved from Electrical background to Embedded Systems. I was till now programming in C and never bothered to apply OO principles in my design. Recently I was forced to ...
12
votes
8answers
975 views
How can I explain object-oriented programming to someone who's only coded in Fortran 77?
My mother did her college thesis in Fortran, and now (over a decade later) needs to learn c++ for fluids simulations. She is able to understand all of the procedural programming, but no matter how ...
7
votes
5answers
752 views
Abstract DAL - Use Interface with Internal Class?
We have a business logic layer (BLL) that is tightly coupled to our data access layer (DAL). We make calls like this:
using (FooData data = new FooData())
{
data.DoSomething();
}
It's important ...
2
votes
1answer
346 views
Composition vs. Inheritance
Here's what is given:
public interface Request {}
// there are 20 subclasses of Request
public class CreateUserRequest implements Request {
@NotEmpty
public String userName;
}
// request ...
39
votes
1answer
5k views
Should package names be singular or plural?
Often, in libraries especially, packages contains classes that are organized around a single concept. Examples: xml, sql, user, config, db. I think we all feel pretty naturally that these packages ...