Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
111 views

I’m building a modular REST API using Node.js + Express + TypeScript. My controllers are defined as classes. In my route files, I currently create a new controller instance, like this: import { Router ...
dok's user avatar
  • 291
0 votes
2 answers
185 views

I have a Python class called FunctionsManager; its __init__() method is the following: class FunctionsManager: def __init__(self, instance_class1, instance_class2, ..., instance_classN): ...
User051209's user avatar
2 votes
1 answer
256 views

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 ...
dok's user avatar
  • 291
1 vote
1 answer
251 views

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, ...
Divan's user avatar
  • 369
2 votes
3 answers
636 views

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 ...
Sergey Zolotarev's user avatar
-1 votes
1 answer
137 views

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. ...
MightyBeast's user avatar
5 votes
3 answers
664 views

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 ...
Bernardo Benini Fantin's user avatar
3 votes
6 answers
602 views

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 ...
agolta's user avatar
  • 77
0 votes
2 answers
376 views

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 ...
PythoonNoob9000's user avatar
4 votes
2 answers
2k views

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 (...
Bernardo Benini Fantin's user avatar
0 votes
2 answers
156 views

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 ...
nicke7117's user avatar
1 vote
1 answer
119 views

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 ...
Nyamiou The Galeanthrope's user avatar
3 votes
2 answers
264 views

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 ...
Luce's user avatar
  • 139
3 votes
7 answers
555 views

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,...
Ruben Eekhof's user avatar
2 votes
2 answers
242 views

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. ...
DimitrijeCiric's user avatar
6 votes
7 answers
720 views

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 ...
wcminipgasker2023's user avatar
8 votes
5 answers
4k views

According to Instanceof code smell, I know using "instanceof" is a code smell, so suppose there is a game with some Tools: Tool.java: public interface Tool{ public void printInfo(); } ...
wcminipgasker2023's user avatar
2 votes
1 answer
233 views

Suppose that I want to implement the following scenario. There is a board and each board has a set of peripherals like leds, temp sensors, gpio and so on. Each of them implements the according C++ ...
bielu000's user avatar
  • 351
3 votes
1 answer
241 views

So, I have a class hierarchy that looks like this: It is an embedded project, so the entire code will be run over and over. I have several algorithm classes, that compute some result given some inputs....
Rares Dima's user avatar
4 votes
1 answer
297 views

Edit: @Ben Cottrell's comment said this was similar to a question about spaghetti code. While both questions involve large codebases, mine addresses a specific technical pattern: manual memory ...
Arno's user avatar
  • 151
13 votes
13 answers
3k views

Suppose the code's inside some FullName class And suppose I want only capitalized name elements (let's ignore the fact that in some cultures, name elements may start with a lower-case letter) Should I ...
Sergey Zolotarev's user avatar
1 vote
3 answers
507 views

As we know, there are (at least) four ways to instantiate a class object in C#. But I've never quite understood why some ways are better than others. First of all, you can explicitly declare the ...
Cade Bryant's user avatar
0 votes
0 answers
107 views

I'm designing a library for CANopen protocol. The basic CANopen frames are PDO and SDO, where PDO is like UDP (fire and forget) and SDO is like HTTP (request and response). A CANopen device is a PDO ...
Jackoo's user avatar
  • 119
2 votes
1 answer
200 views

I have an interface defined as follows: interface MyInterface { public function setMyMethod(int $a); public function getMyMethod(): int; } And I have a class that widens the parameter type: ...
Joao M's user avatar
  • 131
2 votes
3 answers
324 views

I have a Slide class with subclasses referring to the different types of slides (IntroSlide, SummarySlide, etc.): abstract class Slide { String slideType; final String title; final String ...
Hello's user avatar
  • 47
17 votes
5 answers
3k views

I'm unsure whether parameter names should describe their object types or if shorter, more concise names are preferable. Consider the following two method signatures: public void PrintPoint(...
Abcd's user avatar
  • 297
3 votes
3 answers
1k views

I read about three-tier architecture and I have a question: I read that in business logic (that is, what is in logic tier) there should be POJO classes, but in most Spring manuals these classes are ...
dude34810's user avatar
2 votes
4 answers
477 views

I recently came across some code: val, ok := i.(SomeInterface) if ok { val.Method() } The above is Go, and attempts to cast to an interface and then runs the method for that interface against the ...
DubDub's user avatar
  • 645
2 votes
3 answers
433 views

I try to brush up on my technical interview skills as I plan to seek a better offer I don't recall being ever asked that really, but I still want to clear up any confusion. What is association, ...
Sergey Zolotarev's user avatar
0 votes
3 answers
491 views

Say I'm building my own backend framework (really I'm just learning) and I have a simple class: class User { String email String passwordHash Date birthdate Int getAge() { ...
Mahi's user avatar
  • 406
4 votes
5 answers
498 views

I'm working on an application and have encountered two different approaches for organizing business logic. There's a general consensus that application rules should be handled in higher layers, so I ...
Azuos's user avatar
  • 49
0 votes
1 answer
140 views

I'm creating my own drawing library in C++ to provide shared rendering code for my projects. Since the library is designed to be used as a component of other projects, the renderer's representation of ...
Bunabyte's user avatar
  • 643
-5 votes
3 answers
262 views

I'm working on a Java programming assignment. In this assignment, there's an immutable class Book and a mutable class BookCopy. You can have multiple BookCopy of the same Book. Now here comes the ...
Ray's user avatar
  • 109
1 vote
1 answer
359 views

I'm developing an api in Fast API using sqlalchemy to manage my ORM classes and operations with the database. I'm dealing with some design decisions to have my classes as little coupled as possible ...
Alejo Villores's user avatar
0 votes
1 answer
102 views

I have a question on where to put the logic in the following hypothetical: There's this class that, at it's basis, has an int[]. There's a method that takes the int[]s of two of these classes and ...
Yorimyorimyorim's user avatar
2 votes
3 answers
271 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare most abstract type when possible, for example, suppose I'm using an UI ...
wcminipgasker2023's user avatar
1 vote
2 answers
299 views

A Group is formally defined as a set of Element's, over which a single operator mul is defined. There are different kinds of Groups, and each kind requires a different set of parameters. Operator mul ...
Mahyar's user avatar
  • 21
3 votes
5 answers
811 views

According to Why should I use dependency injection?, "dependency injection" has some advantages, for example: "Non dependency injection" version: public class Client{ private ...
wcminipgasker2023's user avatar
0 votes
0 answers
221 views

For example, suppose I have a mobile app that uses some user data, the DTO: class UserData{ public: Address address; bool isVerified=false; }; class Address{ }; The UserData may be loaded from ...
wcminipgasker2023's user avatar
5 votes
11 answers
2k views

According to When is primitive obsession not a code smell? and answer in https://softwareengineering.stackexchange.com/a/365205, I know one of the advantages of avoiding primitive obsession is "...
wcminipgasker2023's user avatar
12 votes
5 answers
4k views

According to https://softwareengineering.stackexchange.com/a/200092, as I know, "preserve whole object" is a refactor method that passes the whole object instead of required parameters only, ...
wcminipgasker2023's user avatar
1 vote
3 answers
268 views

According to Invariant rule in Liskov Substitution Principle, I know one of the form of violation of "Liskov Substitution Principle" is violating "invariants can't be weakened in a ...
wcminipgasker2023's user avatar
7 votes
8 answers
5k views

According to Should we avoid custom objects as parameters?, I know I can group related parameters to improve readability of the function, eg: Original version: public void showSchedule(long startDate,...
wcminipgasker2023's user avatar
1 vote
1 answer
379 views

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 ...
vicch's user avatar
  • 127
5 votes
4 answers
2k views

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 ...
TheJavaGuy-Ivan Milosavljević's user avatar
6 votes
4 answers
1k views

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 ...
wcminipgasker2023's user avatar
3 votes
3 answers
310 views

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: ...
evolved_antenna's user avatar
-2 votes
1 answer
522 views

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 ...
Tim Kirkwood's user avatar
2 votes
1 answer
158 views

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 ...
Tim Kirkwood's user avatar
2 votes
6 answers
422 views

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 ...
Code Spirit's user avatar

1
2 3 4 5
69