Questions tagged [object-oriented]
A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner
3,393
questions
2
votes
1
answer
220
views
Mapping complex objects to other similar complex objects
I am working on two applications that serve the same purpose. The first application is more feature rich and its types are more complex, but uses old technologies and will be retired. It will ...
5
votes
4
answers
2k
views
If class B extends A, can we say that B depends on A?
Let's say we have 2 (Java) classes:
class A {}
class B extends A {}
To me, saying B extends A and B is dependent on A are both true (but not equivalent) in this situation. My colleague, OTOH, says ...
0
votes
0
answers
82
views
Best way in C# to share class implementation patterns between abstract base classes [closed]
I could also ask this question for Java, D or C++. I remember, I found this to be an artificial limitation in Java already 10 years ago. I am currently working with C# and appreciate advices here.
It'...
6
votes
4
answers
1k
views
How to avoid init methods when 2 objects need the reference of each other?
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know init is a code smell and should be avoided, and one of the solutions is to use a builder to hold the state first ...
3
votes
3
answers
236
views
Handle hierarchical relationships between large number of enums
I am working on a C# project and I have a somewhat large number of labels (~100) that have some sort of relationships between one another. Here is a minimal dummy example that illustrates this:
...
-2
votes
1
answer
114
views
Defining functions inside vs outside a class
Say I have a class with a function do_thing that is comprised of multiple steps, which themselves segregate into functions (first_process and second_process). At what point would this be considered ...
2
votes
1
answer
125
views
Refactoring Processor classes
I am writing some python 3 bioinformatics software and was wondering about the best way to write it in an OOP format. I am pretty sure a lot of my classes are violating the SRP principle, but I'm not ...
2
votes
6
answers
337
views
Do private members/methods inherently violate the open-closed principle?
Doesnt private members and methods inherently violate the open-closed principle?
Given that private, protected and public modifiers are supported.
I came across this many times in codebases where ...
25
votes
15
answers
18k
views
How far can you push Object Oriented Programming?
A getter is a failure to design an object. It violates encapsulation which is a core principle of object oriented programing.
Now please tell me, how do you design a libraries hash table collection ...
15
votes
9
answers
5k
views
In OOP, what counts as a "getter"
Note: I'm not looking for opinions on whether the authors of the article below are right or wrong. Mainly I'm looking for the exact definition of what they mean by getters, especially since I know ...
0
votes
2
answers
121
views
What is a good architecture / design pattern for giving multiple shared attributes in different combinations?
I have a need for many different objects to have various combinations of attributes. For a demonstrative example, a flaming dog would have a dog attribute, a flame attribute, and a tail attribute, ...
13
votes
6
answers
10k
views
Why use a special "Name" class (instead of just a string) for representing object names in C++?
Suppose we have an Instance class in a C++ program, which has a GUID/UUID, name, parents, children, and other properties which can be saved to or loaded from an XML file.
The intuitive approach for ...
1
vote
1
answer
137
views
How to implement DMG (Game boy) cpu's register using OOP patterns/principles to max code reusability?
I-m looking to learn better use of OOP principles/patterns so I decided to start implementing at least the basics of a GB emulator (technical part is widely covered on diff sites).
So I started with ...
29
votes
14
answers
10k
views
Avoiding throw because we are not sure the exceptions will always be caught
I'm a junior in my company, and one of the coding rules they have is:
"a constructor object must never fail" (i.e., never throw). So what if I give them an invalid parameter? Then, the ...
3
votes
4
answers
220
views
Does interface segregation principle apply to configuration data holders?
If you have a class representing your applicative config file.
Instead of injecting that config class everywhere, would it be good application of interface segregation principle to expose several ...