Category "oop"

Does exposing some methods of a class through an Interface break any SOLID design principle? [closed]

I understand interface segregation and single responsibility principles guide against a class implementing methods or property it doesn't need

How to make sure a subclass has the same initialiser as the baseclass?

Basically, I am trying to define a subclass of string which conforms with the RFC UUID scheme. An object of this class can only exist if it conforms to the 8-4-

How to use the second parent class methods which is inheriting from an interface in python?

I am trying to implement an interface and this interface is taken by two concrete classes say class First and class Second, I have another class that takes thes

JavaScript object assignment: unexpected behaviour

Suppose we have two objects: var a = { foo: { bar: 1 } } var b = { foo: { bar: 2 } } If I set the object b to a (a = b), I expect that a takes the value of b

Convert Reference to Parent to Reference to Child

I have an ArrayList of an object type, let's call it 'Parent'. I need to use a method (.method1()) that is only available in its child, another object called 'C

Virtual Method not calling derived class method (only calling base class) C++

My base class detect() and collect() methods are the only ones being called. I'm trying to get the derived class methods of these to be printed instead. I belie

Unable to Write json variable c# getting an error

I get an error when I try to serialize or update a json file. I just want to update the value of "balance" inside a json file and I got the idea here... I can't

How to initialize a python class variable outside of functions?

I have a python function: class MyClass: my_class_variable: str = Optional[None] @classmethod def initialize(cls): cls.my_class_variable = cls.s

I can't think of a condition to increase the decrement in Gradually Decreasing Carousel app

Decrementing Carousel is a container, accepting int elements. DecrementingCarousel has a maximum capacity, specified via the constructor. When created, Decremen

Employee Salary Calculation

Task Description I have this problem statement: Create a class Employee with the following private member variables. int employeeId String employeeName double

Domain-Driven Design: Is a Subdomain a class?

Let's consider that we use OOP. Is a Subdomain a class? And Bounded Context is a set of classes that are used together for the only purpose(ideally)? Can on sub

How do I prevent the input of a number like 2.2.2 in my calculator?

I have been working on a simple JS calculator using an OOP approach. I am struggling to create a fix that prevents the input of extra decimals. For example, a u

How do I prevent the input of a number like 2.2.2 in my calculator?

I have been working on a simple JS calculator using an OOP approach. I am struggling to create a fix that prevents the input of extra decimals. For example, a u

enforcement for abstract properties in python3

I have this abstract class class Kuku(ABC): def __init__(self): self.a = 4 @property @abstractmethod def kaka(self): pass

Call Private methods outside class definition

I'm trying to use a Gem that provides me with a DSL i need to apply on some of my classes. But using it directly makes my class definitions not as clean as i wa

Typescript error: An outer value of 'this' is shadowed by this container

I had an error in a Typescript class method declaration, but I don't understand how the error message relates back to the bug. The message seems to be saying

Must be of the type array, null given,

I keep getting the following error and I'm not to sure why: Catchable fatal error: Argument 3 passed to System\Loader::action() must be of the type array, nul

integrating clean architecture with ORM

I'm trying to develop a monolithic Django application with Uncle Bob's clean architecture. The problem is I don't want to miss the powerful abilities of Django

How can subprocess be used in a class and tested in python

I have an executable that has many options and I wish to create classes. e.g. the exec has options that can copy rows of a file, rename parts of a file, compres

LateBinding with dynamic memory

I have Base and Derive class at the below which related to polymorphism (Latebinding) : class Base { .... }; class Derive:public Base { .... }; int main() {