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)

1
vote
3answers
411 views

Self-Evaluation: How do I know if I actually have a “good grasp” of OOP? [duplicate]

If I skip the back story and any thoughts I have on this topic, there's really only one question left to ask: How can I find out if I have a "good grasp" on OOP? (I am specifically using PHP, but ...
5
votes
2answers
2k views

Why are inheritance, encapsulation and polymorphism not the pillars of OOP? [closed]

One day I went to a Stack Overflow chat and saw a phrase, that was stating that inheritance, incapsulation and polymorphism are the pillars of OOP (in the sense that they are fundamental, a ...
1
vote
3answers
166 views

Protected variable & protected method in the era of TDD [closed]

I understand protected method is good for unit testing since you can easily mock by the class by overriding the protected method for the sake of testing. However, protected variable is just a global ...
1
vote
2answers
1k views

Is this proper OO design for C++?

I recently took a software processes course and this is my first time attempting OO design on my own. I am trying to follow OO design principles and C++ conventions. I attempted and gave up on MVC for ...
28
votes
8answers
5k views

Is splitting up a function into several inner functions an anti-pattern? [duplicate]

Imagine a long and complicated process, which is started by calling function foo(). There are several consecutive steps in this process, each of them depending on result of the previous step. The ...
9
votes
4answers
2k views

Why define a Java object using interface (e.g. Map) rather than implementation (HashMap)

In most Java code, I see people declare Java objects like this: Map<String, String> hashMap = new HashMap<>(); List<String> list = new ArrayList<>(); instead of: ...
14
votes
10answers
4k views

Why are inheritance and polymorphism so widely used?

The more I learn about different programming paradigms, such as functional programming, the more I begin to question the wisdom of OOP concepts like inheritance and polymorphism. I first learned ...
1
vote
1answer
407 views

Differences between Dynamic Dispatch and Dynamic Binding

I've been looking on Google for a clear diffrentiation with examples but couldn't find any. I'm trying to understand the differences between Dynamic Dispatch and Dynamic Binding in Object Oriented ...
0
votes
3answers
365 views

PHP class data implementation

I'm studying OOP PHP and have watched two tutorials that implement user login\registration system as an example. But implementation varies. Which way will be more correct one to work with data such as ...
5
votes
1answer
351 views

Decoupling when constructors have non-contractual parameters

By non-contractual parameters, I mean parameters that are not interfaces or service dependencies, something like class Person(string name). I am writing a webpage scraping application, and so far ...
1
vote
3answers
194 views

Extending a struct. Using helper classes rather than composition

I have a struct which I want to add static methods to. Yes, you guessed right I'm talking about Datetime. It's a pretty typical requirement to add MyCustomParse. It happens to return Datetime?, so ...
8
votes
9answers
6k views

Use constructor or setter method?

I am working on a UI code where I have an Action class, something like this - public class MyAction extends Action { public MyAction() { setText("My Action Text"); ...
0
votes
3answers
304 views

How do you make a service stateless?

When doing Domain Driven Design it is advised that services should be stateless. There are several kinds of services when doing DDD: Application services. Domain services. Infrastructure services. ...
4
votes
2answers
878 views

How to replace inheritance with composition in this case?

I've recently read several articles about the advantages of the composition over inheritance. Their authors said that you can always replace inheritance with composition (to be precise, they say they ...
2
votes
2answers
159 views

Should an Animal be abstract or allow for instantiation to represent a “general” instance? [closed]

After a short discussion in the comments here I have come to wonder whether or not a baseclass like Animal in the traditional OOP example should be marked as abstract or not. Personally I believe it ...
5
votes
2answers
417 views

How are OOP “objects” and “classes” organized in memory in terms of assembly language?

How are objects organized in memory? For instance, I know that a function is a piece of code in memory, that expects parameters via the stack and/or the registers and handles it's own stack frame. ...
4
votes
2answers
267 views

What are the key differences between Java's and Python's OOP support? [closed]

The only language I've ever used is Java. I like it a lot but decided it's time to learn another language :) . I'm interested in learning Python. It seems like a good choice because it's partly ...
0
votes
3answers
263 views

Does the pattern of passing in one object instead of many parameters to a constructor have a name?

If you have a constructor that takes a lot of parameters, like this: public OrgUnitsHalRepresentation(List<OrgUnitSummaryHalRepresentation> orgUnitSummaryHalRepresentationList, int count, ...
2
votes
4answers
835 views

Why would the switch from C# to scala make sense in order to take advantage of scala's functional capabilities? [closed]

What is the benefit of using functional program for large scale software projects? I have heard it is pretty performance equivalent to regular OOP. I also have heard that it is more "mathematically ...
0
votes
3answers
74 views

Structuring an application that reads from a .properties file

I have a Java app with three classes: Foo, Bar and Baz. All three depend on a bunch of what are currently constants defined in each class in order to determine how to run. On top of that, Baz ...
27
votes
3answers
16k 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 ...
7
votes
4answers
475 views

“Immutable” interfaces

I am confused about the notion of immutability. Consider the following structure of a simplistic calculator: Here are the interfaces: interface IOperationalInterface { int Sum(int a, int b); } ...
0
votes
1answer
147 views

Does lots of Instance Variables within my class suggest flawed Design?

Ok so I am setting out to consolidate some learning I have been doing. What I am going to do is create a small game relating to a game I enjoy called Persona. For reference a persona you can think of ...
9
votes
4answers
2k views

What is meant by “OOP hides the state”? [closed]

In one of many anti-OOP rants on cat-v.org I found a passage by Joe Armstrong raising several objections against the OOP model, one of which was the following: Objection 4 – Objects have private ...
1
vote
1answer
116 views

Inheriting from Abstract class vs Enum Types for custom exceptions

I am creating an interface and would like the implementer(s) of this interface to throw exceptions in the case that something goes wrong. Let's call the implementer a plugin. I have a director which ...
1
vote
1answer
109 views

Domain-specific Interfaces

Are there any real benefits of using interfaces over abstract classes in a domain model? Does anyone have any experience using interfaces in a domain model in a real project? From a technical ...
0
votes
1answer
89 views

Pattern that prevents events to trigger themselves

I am working at the client-side part of a web application, that is responsible for getting answers from users for specific questions and storing and restoring them from the database (or cookies) and I ...
61
votes
22answers
12k views

Why is OOP difficult?

When I started using an object-oriented language (Java), I pretty much just went "Cool" and started coding. I've never really thought about it until only recently after having read lots of questions ...
3
votes
1answer
789 views

does this model-pattern have a name?

A few years back, I wrote this answer to a question from which the following idea emerged. I call these "Type Descriptors", as I have never been able to find this pattern documented or formally ...
0
votes
1answer
93 views

OOD: class hierarchy with method arguments forming another hierarchy

I'd like to find out how do you guys handle the following situation: you have a class hierarchy, call it H1, with some polymorphic method that is supposed to accept an argument which type forms ...
2
votes
2answers
770 views

What is the recommended approach for helper functions in JavaScript?

What is the recommended approach for helper functions? I would like to choose one technique, and run with it to create my new "class". Here are the design options I have pondered: Option 1: Helper ...
0
votes
4answers
208 views

Should each method have a seperate JUnit test class?

I am writing JUnit unit tests for my classes. Is it better to have a separate class for each method, or have just one test class for every actual class?
2
votes
3answers
322 views

How does one think about object oriented design and Aspect oriented Design for solution

I have worked on few projects in which both AOP and Object oriented paradigm were used. But, AOP usage was limited to logging only. I think AOP is a much more powerful technique. My question, to those ...
2
votes
1answer
198 views

Java and rest OOP languages - when to use super or this keywords

I have been programming java for like a year or more, and i have always used the this and super keywords. And yesterday my mate read one source of mine, and told me not to over use it unless you are ...
7
votes
3answers
655 views

How exactly to use the MVC design pattern

I have read the documentation on the apple's developer website which refer following guidelines A view class shouldn't depend on a model class (although this may be unavoidable with some custom ...
1
vote
1answer
199 views

Which is the more testable C function implementation?

I write code in C. I have been striving to write more testable code but I am a little confused on deciding between writing pure functions that are really good for testing but require smaller functions ...
7
votes
4answers
3k views

Multiple Same Object Instantiation

What exactly happens in Java when you instantiate the same object multiple times? For example: Test test = new Test(); then later on I will call it again, Test test = new Test(); again or inside a ...
1
vote
2answers
124 views

Should an abstract class always abstract its methods to an interface?

I had learned sometime ago that abstract classes should always abstract their functions to an interface. So instead of having something like this - abstract class a{ public int i; public int ...
2
votes
5answers
342 views

Classic inheritance problem?

I keep seeing the following pattern when people learn about OOP: Problem: How do I put objects of different but related types into a container? Solution: Inherit from a common base class. New ...
23
votes
1answer
509 views

How are mixins or traits better than plain multiple inheritance?

C++ has plain multiple inheritance, many language designs forbid it as dangerous. But some languages like Ruby and PHP use strange syntax to do the same thing and call it mixins or traits. I heard ...
3
votes
3answers
495 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
12
votes
3answers
1k views

General thought process for “How would you build this website/app” interview questions

I've collected a bunch of interview questions like "Describe how you would design a photo album application", "Describe how you would design this particular feature of this particular website" (e.g. ...
27
votes
7answers
4k 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 ...
-1
votes
1answer
335 views

Implementing IEnumerator without using 'yield return' in c#

I'm new to C# programming, I was experimenting with iterators concept in C#. Here, I'm trying to display all the terms in a list, for that I'm trying different ways to obtain the results. In the below ...
2
votes
3answers
396 views

What is a good design for a method that can return several logically different results?

The question title is probably too abstract, so let me provide a particular example of what I have in mind: There is a webservice that encapsulates a process of changing passwords for users of a ...
2
votes
2answers
139 views

Calling same method on different object - Recursion?

I have an object that contains a reference to another object of the same type. Example in PHP: class A { protected $child; public function __construct(A $child = null) { ...
3
votes
3answers
483 views

Why shouldn't an object reference have access to a static member in C#

Context of my question: I am reading C#. Trying to understand Static keyword. I understand that when Static is applied to a member of a class, it can only be modified by the class and not the class ...
1
vote
2answers
183 views

Sanity check for design pattern used with an intricate calculation model

I am working on a project that generates technical brochures in batch. The 3rd party API that is being used expects POCOs with property names that match field names used in each of the brochure ...
3
votes
2answers
303 views

Have there been studies on the effectiveness of OOP in managing software complexity?

OOP is often regarded as an effective strategy of managing complexity in software, as opposed to non-OOP procedural programming. Have there been any studies testing this notion? Is it proven that OOP ...
4
votes
1answer
77 views

Keep or discard tests that use methods now private [duplicate]

When writing object-oriented code from scratch, I try to follow these steps: Write a test that fails. Write a function that makes the test pass. When enough tests and functions are complete, ...