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,432 questions
0
votes
2
answers
99
views
How to reduce the number of class instances passed to the __init__() method of a Python class?
I have a Python class called FunctionsManager; its __init__() method is the following:
class FunctionsManager:
def __init__(self, instance_class1, instance_class2, ..., instance_classN):
...
2
votes
1
answer
141
views
Is it okay to mix OOP and modular approaches when building a backend with TypeScript/JavaScript?
I’m designing a backend in TypeScript (could also apply to JavaScript), and I’m wondering about the architectural approach.
Is it better to stick to a single paradigm (e.g., fully object-oriented or ...
1
vote
1
answer
237
views
OO design - Process that relies on the current state of objects
We have a CAD software extension, where you can draw products like walls, doors, windows, etc., and you can export the drawing as an order, which contains the parts and costs.
As part of this export, ...
2
votes
3
answers
621
views
Convenience inheritance
Sometimes, you inherit from a class that defines the semantics of your type (Shape – Ellipse – Circle). Other times, you inherit simply because it's convenient to do so.
A superclass may have ...
-1
votes
1
answer
131
views
How to organize struct-based "methods" in C similar to object-oriented style? [closed]
So I was coding in C for a while now, getting used to language syntax and different styles.
Implemented a couple of simple data structures, algorithms and tried my skills in making Minesweeper clone.
...
5
votes
3
answers
654
views
How to get rid of Mappers and make objects build themselves?
I am having a really hard time deciding where to instantiate my entities in the refactoring I am making. The project was built with DDD and it's layered: it has the infra, domain and app layers. In ...
3
votes
6
answers
597
views
Is OOP really beneficial for enterprise-scale business software compared to procedural languages like ABAP or COBOL?
I'm currently drafting a Python coding standard for internal enterprise use, primarily targeting business applications that involve heavy data access, reporting, and transactional logic.
In this ...
0
votes
2
answers
368
views
Global State, How To Do IT?
im kind of a newbie so take me easy
i face a problem every time i make a project
specially Client projects, which is Global State i always struggle to do it
for example, here is the structure of one ...
4
votes
2
answers
2k
views
Should I expose an instance's state with methods?
I've read somewhere about a pattern that is as follows: if it'll change the state of the instance, the method should be named with a verb and return void; and if the method just returns something (...
0
votes
2
answers
154
views
Is it better to pass a specific “context” object to handlers rather than the entire domain object?
I’m designing a system where various “handlers” apply business rules to an object. Initially I had each handler receive the full domain object:
// A large domain object with many properties and ...
1
vote
1
answer
116
views
When does encapsulating a primitive field into its own class make sense? [duplicate]
Let's say I have the following Java code:
public record Person(String firtName, String lastName, int age) {}
Can it makes sense to have instead:
public record Person(FirstName firtName, LastName ...
3
votes
2
answers
240
views
How to structuring a read/write submodule in OOP Python
I am developing a python package that needs to be able to read/write from/to multiple formats. E.g. foo format and bar format. I am trying to contain the functions relating to each format in a single ...
3
votes
7
answers
540
views
Do I need to create an interface for every service class to follow good design principles?
I'm working on a custom Magento 2 module in my internship, and I'm trying to follow SOLID principles in my code.
Right now, my controller actions handle everything: getting request data, processing it,...
2
votes
2
answers
223
views
Best way to add asynchronous execution for already implemented synchronous process
I have a complex process implemented in Java Spring microservice.
Currently this process is triggered on user request and it is synchronously executed.
This often results in a gateway timeout.
...
6
votes
7
answers
713
views
Why do "protected variables" tend to violate open closed principle?
According to Why is Clean Code suggesting avoiding protected variables?, I know there are tons of reasons to avoid protected variables.
However, there is a reason at the currently highest voted answer ...