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

learn more… | top users | synonyms (3)

27
votes
1answer
5k views

Multiple Interfaces in Java - Good or bad [closed]

I'm coming out of an interview just now and the interviewer asked me if a Java interface can "extend" more than one interfaces. I was thinking multiple inheritance is disallowed in java so got that ...
25
votes
11answers
5k 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. ...
25
votes
5answers
1k views

Many small classes vs. logical (but) intricate inheritance

I'm wondering what is better in terms of good OOP desing, clean code, flexibility and avoiding code smells in the future. Image situation, where you have a lot of very similar objects you need to ...
25
votes
12answers
2k views

Why should a class be anything other than “abstract” or “final/sealed”?

After 10+ years of java/c# programming, I find myself creating either: abstract classes: contract not meant to be instantiated as-is. final/sealed classes: implementation not meant to serve as base ...
25
votes
8answers
4k views

Why have private static methods?

I just wanted to clear up a question I have. What is the point of having a private static method as opposed to a normal method with private visibility? I would have thought an advantage to having a ...
25
votes
13answers
4k 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 ...
25
votes
6answers
3k views

Explanation on how “Tell, Don't Ask” is considered good OO

This blogpost was posted on Hacker News with several upvotes. Coming from C++, most of these examples seem to go against what I've been taught. Such as example #2: Bad: def ...
24
votes
5answers
3k views

Why is it bad to write something in language X as if you're writing a program in language Y in terms of using a shared coding paradigm [closed]

A while ago, I asked a question on SO about something written in C++, but instead of getting an answer to the problem at hand, the comments went all crazy on my coding style, even when I indicated ...
24
votes
7answers
2k views

Complete immutability and Object Oriented Programming

In most OOP languages, objects are generally mutable with a limited set of exceptions (like e.g. tuples and strings in python). In most functional languages, data is immutable. Both mutable and ...
24
votes
5answers
2k views

Pass ID or Object?

When providing a business logic method to get a domain entity, should the parameter accept an object or an ID? For example, should we do this: public Foo GetItem(int id) {} or this: public Foo ...
24
votes
9answers
1k views

Why most “well-known” imperative/OO languages allow unchecked access to types that can represent a 'nothing' value?

I have been reading about the (un)convenience of having null instead of (for example) Maybe. After reading this article, I am convinced that it would be much better to use Maybe (or something ...
24
votes
6answers
11k views

How can I apply OOP concepts to building a simple, but real-world, web app?

I've been trying now for a long time to wrap my head around OOP. I see its advantages. I've read many, many tutorials and watched an equal amount of videos on the subject. I get the animal/cat/dog ...
23
votes
1answer
1k views

Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?

In a blog post on F# for fun and profit, it says: In a functional design, it is very important to separate behavior from data. The data types are simple and "dumb". And then separately, you ...
23
votes
3answers
3k views

Rich Domain Models — how, exactly, does behavior fit in?

In the debate of Rich vs. Anemic domain models, the internet is full of philosophical advice but short on authoritative examples. The objective of this question is to find definitive guidelines and ...
22
votes
9answers
3k views

Are abstract classes / methods obsolete?

I used to create a lot of abstract classes / methods. Then I started using interfaces. Now I am not sure if interfaces aren't making abstract classes obsolete. You need a fully abstract class? ...
22
votes
10answers
2k views

How many are too many interfaces on a class?

I would probably consider it a code smell or even an anti-pattern to have a class that implements 23 interfaces. If it is indeed an anti-pattern, what would you call it? Or is it simply just not ...
22
votes
6answers
2k views

Is functional programming a superset of object oriented?

The more functional programming I do, the more I feel like it adds an extra layer of abstraction that seems like how an onion's layer is- all encompassing of the previous layers. I don't know if this ...
22
votes
7answers
1k views

Pattern for a class that does only one thing

Let's say I have a procedure that does stuff: void doStuff(initalParams) { ... } Now I discover that "doing stuff" is quite a compex operation. The procedure becomes large, I split it up into ...
22
votes
8answers
2k views

What is the real responsibility of a class?

I keep wondering if it is legitimate to use verbs that are based on nouns in OOP. I came across this brilliant article, though I still disagree with the point it makes. To explain the problem a bit ...
22
votes
10answers
2k views

How would Functional Programming proponents answer this statement in Code Complete?

On page 839 of the second edition, Steve McConnell is discussing all the ways that programmers can "conquer complexity" in big programs. His tips culminate with this statement: "Object-oriented ...
22
votes
4answers
1k views

Why Java doesn't make use of encapsulation with some classes?

My question is related with System.in and System.out classes (there might be others like those in the Standard library). Why is that? Isn't that a bad practice in OOP? Shouldn't it be used like: ...
22
votes
5answers
2k views

How do I prove or disprove “god” objects are wrong?

Problem Summary: Long story short, I inherited a code base and a 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 ...
21
votes
12answers
2k views

Is developing games the best way to learn programming?

I heard recently an instructor mentinon that developing games was the best way to learn programming. Besides the fact that everything had to be created in code, he said you really get to fully ...
21
votes
6answers
3k views

LSP vs OCP / Liskov Substitution VS Open Close

I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more). the open/closed principle states "software ...
21
votes
11answers
1k views

Is information hiding more than a convention?

In Java, C# and many other strongly-typed, statically checked languages, we are used to write code like this: public void m1() { ... } protected void m2() { ... } private void m2() { ... } void m2() ...
21
votes
16answers
2k views

How large non-OO code bases are managed?

I always see abstraction is a very useful feature the OO provides for managing the code-base. But how are large non-OO code bases are managed? Or do those just become a "Big Ball of Mud" eventually? ...
21
votes
11answers
1k views

How large is ok for a Class?

I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming. The point is ...
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 ...
21
votes
5answers
1k views

Do unit tests sometimes break encapsulation? [duplicate]

I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it." While sometimes that's the case and we have a hiding concept inside our ...
21
votes
6answers
2k views

Functional programming compared to OOP with classes

I have been interested in some of the concepts of functional programming lately. I have used OOP for some time now. I can see how I would build a fairly complex app in OOP. Each object would know how ...
20
votes
9answers
3k views

Should the methods of a class call its own getters and setters?

Where I work I see lots of classes that do things like this: public class ClassThatCallsItsOwnGettersAndSetters { private String field; public String getField() { return field; ...
20
votes
2answers
3k views

What are the advantages of prototype-based OOP over class-based OOP?

When I first started programming Javascript after primarily dealing with OOP in context of class-based languages, I was left confused as to why prototype-based OOP would ever be preferred to ...
20
votes
5answers
965 views

How to avoid giant glue methods?

In my current job, I've been tasked with cleaning up old code a few times. Often the code is a labyrinth and the data behind it is even more tangled. I find myself combing out things into nice, ...
19
votes
11answers
2k views

I've learned so much about OO programming I have no idea how to write procedural code. What's a good way to learn?

When I learned to program, I learned Object Oriented Programming very early on. For a while, I blundered around with my beautiful hammer, trying to use it for everything, partially because I had no ...
19
votes
11answers
5k 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?
19
votes
5answers
2k 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 ...
19
votes
4answers
1k views

How to drastically improve code coverage?

I'm tasked with getting a legacy application under unit test. First some background about the application: It's a 600k LOC Java RCP code base with these major problems massive code duplication no ...
19
votes
4answers
1k views

How do purely functional languages handle modularity?

I come from an object oriented background where I've learned that classes are or at least can be used to make a layer of abstraction that allows for easy recycling of code which can then either be ...
19
votes
6answers
890 views

Should an object know its own ID?

obj.id seems fairly common and also seems to fall within the range of something an object could know about itself. I find myself asking why should my object know its own id? It doesn't seem to have a ...
19
votes
4answers
2k views

How should I add functionality to an object that already exists?

I have an interface that has a certain amount of well-defined functionality. Let's say: interface BakeryInterface { public function createCookies(); public function createIceCream(); } This ...
18
votes
15answers
3k views

Is Object Oriented Programming a solution to complexity?

Do you think Object Oriented Programming is a solution to complexity. Why? This topic may be a bit controversial but my intentions to know the answer of Why from the experts here !
18
votes
9answers
3k views

Is there any reason to use “plain old data” classes?

In legacy code I occasionally see classes that are nothing but wrappers for data. something like: class Bottle { int height; int diameter; Cap capType; getters/setters, maybe a ...
18
votes
2answers
2k views

How to improve upon Bloch's Builder Pattern, to make it more appropriate for use in classes that may be extended and sub-extended many times over?

I have been greatly influenced by Joshua Bloch's Effective Java book (2nd edition), probably more so than with any programming book I've read. In particular, his Builder Pattern (item 2) has had the ...
17
votes
5answers
3k 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 ...
17
votes
9answers
1k views

Does OO, TDD, and Refactoring to Smaller Functions affect Speed of Code?

In Computer Science field, I have noticed a notable shift in thinking when it comes to programming. The advice as it stands now is write smaller, more testable code refactor existing code into ...
17
votes
4answers
12k views

what is message passing in OO?

I've been studying OO programming, primarily in C++, C# and Java. I thought I had a good grasp on it with my understanding of encapsulation, inheritance and polymorphism (as well as reading a lot of ...
17
votes
8answers
2k 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 ...
17
votes
7answers
1k views

Does functional programming ignore the benefits gained from the “On the Criteria To Be Used in Decomposing Systems into Modules” (data hiding)?

There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles ...
17
votes
5answers
702 views

Is loose coupling w/o use cases an anti-pattern?

Loose coupling is, to some developers, the holy grail of well-engineered software. It's certainly a good thing when it makes code more flexible in the face of changes that are likely to occur in the ...
17
votes
12answers
996 views

SOLID vs. Avoiding Premature Abstraction

I understand what SOLID is supposed to accomplish and use it regularly in situations where modularity is important and its goals are clearly useful. However, two things prevent me from applying it ...