Skip to main content
Filter by
Sorted by
Tagged with
9 votes
2 answers
757 views

This is potentially an XY problem, but from my understanding of the SRP (Single Responsibility Principle) if you have an Order object, the properties should live on the Order, but methods like ...
Ryan D.'s user avatar
  • 149
0 votes
4 answers
160 views

This is more like an exercise. I have several conditions that affect 2 nested for clauses: for(...)//1st { for(...)//2nd { ... } } and since there are various possibilities (each one ...
Patrick's user avatar
  • 2,623
-3 votes
1 answer
114 views

I'm not super experienced with C#, and this is a bit of a puzzle. Consider the following code: #nullable enable using System.Collections.Generic; // Biology.dll public abstract class Animal { ...
suszterpatt's user avatar
  • 8,327
0 votes
1 answer
107 views

I am working on a project in C++. I am writing several unit tests, and I have functions exposed publicly so I can access them in my unit test target executables, but I really don't want them exposed. ...
JAYD3V's user avatar
  • 12.6k
3 votes
1 answer
149 views

I'm learning Object-Oriented Programming in C++ and trying to understand polymorphism with base class pointers. I created a base class Animal and a derived class Dog, both with a speak() method. I ...
Hassan Ali's user avatar
3 votes
2 answers
115 views

I want the user to be able to pass the struct along and instantiate it without a constructor function, but not be able to modify the structure's fields without using the setter methods provided in the ...
GrimOutlook's user avatar
2 votes
1 answer
126 views

typedef struct { WindowData data; bool vsync; } Window; typedef struct { Window window; GLFWwindow *native_window; } WindowsWindow; Window *windowCreate(const WindowProperties props,...
Aidan's user avatar
  • 87
0 votes
1 answer
126 views

public class Guitar { private String SerialNumber ; private double Price; private String Model; private Type Type; private Builder Builder; private Wood BackWood; private ...
KAAMIRLI's user avatar
1 vote
1 answer
53 views

I'm trying to create a parent class A with a private field #abc and a subclass B that overrides this field. However, when I call methods from the parent class that access the private field, it still ...
pery mimon's user avatar
  • 8,459
-7 votes
1 answer
115 views

This is a question for an assignment for Uni. For this assignment we have to respect encapsulation and inheritance in Java. The important classes to know right now are: Cliente Class import java.util....
MiguelPereira3530's user avatar
-4 votes
1 answer
104 views

Note to SO. If I ask this question to AI I get a very similar output as the accepted reply. Without out all the questions about how I asked the question. Just sayin. I am using this class for ...
WouldRatherBuildAMotor's user avatar
1 vote
0 answers
101 views

Consider this piece of C++ code: template <typename T> struct Base { // data members ... // conversion constructors: template <typename U> Base(const Base<U>& ...
lobelk's user avatar
  • 531
0 votes
1 answer
119 views

There is a requirement in the AUTOSAR NVM module that says: [SWS_NvM_00135] The Administrative block shall be invisible for the application and is used exclusively by the NvM module for security and ...
Ehsan R's user avatar
  • 63
2 votes
2 answers
130 views

The encapsulation principle says : "You should hide the attributes of your class and only make them accessible via methods. This guarantees the validity of class invariants." I'm totally ...
xerox0213's user avatar
0 votes
1 answer
187 views

I am trying to encapsulate a third-party library by writing a wrapper over it and using only required APIs as per my need. To achieve this, I have created this wrapper project as a standalone project ...
booyaakaashaa's user avatar
3 votes
1 answer
101 views

I have written the util class to be used with Flow<> in kotlin. The goal of the class is to simplify error handling and make possible to instantly finish the flow by calling breakFlow() method. ...
K0cur's user avatar
  • 120
0 votes
1 answer
29 views

Suppose a code consists of several parts/functions. How to manage a code and collaborate with programmers with some parts of the code invisible but executable to collaborators? To be more specific ...
feynman's user avatar
  • 101
2 votes
3 answers
258 views

I learnt typescript in a hurry and still a newbie. Coming from a functional background I am used to seperate object data from its methods. For example let us consider a simple data object that i ...
Coo LHibou's user avatar
0 votes
0 answers
32 views

I have a C# project Wrapper.csproj that will act as a wrapper around the Nuget package Azure.Storage.Blobs. Another project Hello.csproj will now reference Wrapper.csproj, so it can use the methods I ...
sgabler-solytic's user avatar
1 vote
1 answer
112 views

I have this folder structure Day12 | Account.java | AccountMain.java Account.java Contains package Day12; public class Account { int id; String name; double balance; public int ...
MeLoveCats's user avatar
-2 votes
2 answers
68 views

I am basically writing static methods that perform work on a list of strings but I can't quite determine if it would be better to create instance variable and do all the work internally. In case my ...
zaxunobi's user avatar
  • 962
0 votes
1 answer
76 views

Let's say I have a class that requires an encapsulated variable for conditional protection. class person { private: int height_; public: explicit person(int height) { this->...
Bard's user avatar
  • 35
-1 votes
1 answer
65 views

I have searched about this topic everywhere that what's the difference between abstraction and encapsulation , even one of the most voted stack overflow question , but at the end it seems confusing ...
RISHABH SHANDILYA's user avatar
1 vote
0 answers
91 views

I am tackling quite a problem in the React app that I have not yet come to fully understand. What happens is that I have less files which I process with webpack and the styles/main.less is loaded in ...
bakrall's user avatar
  • 702
0 votes
2 answers
358 views

Here is a hypothetical example: I have a market.service.ts with 2 functions called buy() and sell() which are each 100 lines of code export class ShopService { public async buy() { // 100 lines ...
Rahimi0151's user avatar
0 votes
4 answers
252 views

When designing an aggregate and entities, it would be good to provide the consumer with only the public properties and methods of the aggregate. But it happens that in order to change some property, ...
Alexandr Kubit's user avatar
-1 votes
1 answer
108 views

I am building a CLI chess project (my first non-school project). I have a Board class in my GameLogic package which contains a 2D array with Piece objects to represent the board. I also have a ...
Tyler's user avatar
  • 11
1 vote
0 answers
14 views

I read this: https://stackoverflow.com/questions/46209696/how-to-use-2d-arrays-inside-a-c-struct I did something like that in order to protect the internals of a "graph_t" structure. is ...
faruk yıldırım's user avatar
0 votes
1 answer
216 views

Exercise 21.4: A variation of the dual representation is to implement objects using proxies (the section called “Tracking table accesses”). Each object is represented by an empty proxy table. An ...
kos's user avatar
  • 45
0 votes
1 answer
58 views

I have a raw C# class that is marked as [Serializable]. The fields are all public since the object is being saved to a file with Newtonsoft JSON.NET. [Serializable] public class ...
Janesh Parnami's user avatar
0 votes
0 answers
33 views

I have several classes, each of which should be able to retrieve an existing instance of itself (using an ID) when possible, rather than creating a new instance. For encapsulation and convenience, I ...
David's user avatar
  • 347
-2 votes
1 answer
358 views

Recently, I came across a blog post regarding the encapsulation of queries in EF Core. This approach is somewhat different from the repository pattern which is much more familiar to me. In repository ...
Zombies are Real's user avatar
0 votes
3 answers
167 views

I have a logic that need to reactively run some function if a this.variableName is changed inside or outside the class the problem is with this logic, getter doesn't work, and I get undefined. not ...
user avatar
0 votes
1 answer
169 views

OCaml allows to mark type as private in the signature. And it makes sense. The object of type declared as private can be created only inside the module and be read outside. module X : sig type t = ...
Valentyn Zakharenko's user avatar
3 votes
1 answer
82 views

Ocaml provides three kinds of encapsulation for types: abstract - when we can do nothing with an object of abstract type outside the module (can't read, create, update) public - when we can do ...
Valentyn Zakharenko's user avatar
0 votes
1 answer
117 views

I have an Object class that allows objects to be linked together. A -> B -> C (one way linking) When a link is formed between two objects by calling Link(IObject other), I want to set ...
wforl's user avatar
  • 889
1 vote
3 answers
89 views

Let's say I have the class User with the attributes name, email etc.. In my code, I still want to be able to update that information, but I don't want anyone being able to reach the setters methods ...
Dervieux Benoît's user avatar
0 votes
0 answers
33 views

I have a python class that manages initilization, read, and writes to a sql database: class Database { def __init__(self, path2db): # path2db is created within this constructor self....
roulette01's user avatar
  • 2,502
1 vote
1 answer
35 views

I have 3 classes with a merge operation that does identical operations with different arguments. Here's the skeleton code of what I currently do: class FirstClass: def __init__(self): # define ...
roulette01's user avatar
  • 2,502
0 votes
1 answer
22 views

im been learning coding but im kinda stuck at oop. It is hard to comprehend its concept for me. Especially when it comes to encapsuling. Do you know any source that can help me for full understanding ...
professorchemist's user avatar
0 votes
1 answer
96 views

I have been rcently been advised to use MediatR in my API Controllers for encapsulation purposes. I just want to know how does it know which handler to communicate with and when? I checked the ...
Relax's user avatar
  • 3
-1 votes
1 answer
71 views

class Person(): def __init__(self,name:str,height :float) -> None: #initialize self.__name=name self.height=height @property def name(self) -> str: ...
Armaan Sahoo's user avatar
1 vote
0 answers
317 views

Given a pointer to an array of N elements of char, I want to create an object which will encapsulate the array (it's address, length and type) giving me a read-only interface to it. I have been using ...
Agnel Kurian's user avatar
  • 59.9k
0 votes
1 answer
100 views

I am reading the book of CPP-Concurrency-In-Action-2ed-2019. In chapter 9.1.2, the author gives a simple example to show how to design a wrapper of type-erasure function: #include <memory> #...
f1msch's user avatar
  • 665
0 votes
0 answers
90 views

I'm working with OpenTelemetry and trying to encapsulate the logic by internal library which means prevent using OpenTelemetry public API and spread logic between the projects, means there is only one ...
AleksP's user avatar
  • 1,406
0 votes
1 answer
395 views

I am making an Angular app + Tailwind that is one large horizontal page that allows the user to scroll from left to right using scroll-snap-type. When i try to cleanup my code and create reusable ...
Yannick's user avatar
  • 33
0 votes
1 answer
47 views

I'm working on a C++ project where I have a type hierarchy involving types A and B. I would like to achieve encapsulation such that type A is only visible within the context of type B and remains ...
ElJaviLuki's user avatar
0 votes
1 answer
109 views

I am trying to include the sources of BetterLog lib as a separate file, while keeping its referencing in the same as when added "as a library". How should I wrap it properly? I've tried ...
Vitalii Vasylenko's user avatar
-1 votes
1 answer
74 views

I created a player with: Player player = new Player(hand, 5000, "Player_1"); When printing class it prints "null 0 null" Why are the variables not being saved? Thanks! Player class:...
Derrick Perry's user avatar
0 votes
2 answers
161 views

I am doing a course on python classes as a hobby and the topic is encapsulation and class values. I am trying to understand getters and setters. I've read tens of different explanations and I feel I ...
vinter5's user avatar
  • 57

1
2 3 4 5
42