Questions tagged [oop]
Object-oriented programming is a programming paradigm using "objects": an encapsulation consisting of data fields and methods together with their interactions.
62,313
questions
0
votes
0
answers
6
views
How to extend methods from two classes in Object Oriented (Java)Typescript?
I currently have two classes with the same methods. I would like to have a class that inherits both of them, but in which methods are extended to perform the operations in both methods.
Here is an ...
-1
votes
0
answers
4
views
What is the correct way not to mix up similar variables of the same type in function?
Let's imagine some sort of the function, which receives argument ARG of some complex type. Inside this function we pass that argument to other function, which returns the value VAL of the same type (...
-2
votes
0
answers
21
views
Why "Favor composition over inheritance" and not "Favor aggreggation over inheritance"?
I have read many different articles on "Favor composition over inheritance" over the years and despite reading so many, actually finding clear concise code examples has been difficult.
I ...
1
vote
1
answer
17
views
Does the Dependency Inversion Principle apply within application layers
I keep reading code examples that suggest that the Dependency Inversion Principle is achieved by using interfaces for a classes dependencies. That in itself is confusing me, as the more I read about ...
1
vote
1
answer
34
views
Are interfaces required for the Dependency Inversion Principle?
I have read many examples about Dependency Inversion from classic SOLID in different coding languages.
// A is dependent on B
class A {
property;
constructor() {
this.property = (new B())....
0
votes
3
answers
28
views
Overriding a variable assigned to an evaluated method in the parent class using a child class
I am new to object oriented programming. I have a parent class in whose constructor I have a variable (bmi in the below example) that requires a method (bod_mass_idx) of the same class to be evaluated ...
-2
votes
0
answers
41
views
Object Oriented JavaScript: relationship between objects [closed]
I have made some progress with the syntax of objects in JavaScript but I am not clear about their use in the overall context of an application such as a shopping cart. I have read quite a lot on MDN's ...
0
votes
1
answer
40
views
How do I run a python file from another python file [duplicate]
I am trying to run a python file from another python but when, when it comes to calling a method in another python file it just reruns the current python file.
I tried this code. I put the import ...
-4
votes
0
answers
20
views
What would be idiomatic way to implement Abstract class in golang? [duplicate]
We have a code sample which is along the following lines
type Foo interface {
DoSome() error
}
type AbstractFoo struct {
Foo
X
Y
}
type ConcreteFoo struct {
.....
}
This looks all ...
-3
votes
0
answers
21
views
How to Structure an Optimization Program Like Pyomo Using Only Functions Instead of Classes? [closed]
Pyomo is a popular Python library for formulating and solving optimization problems. It uses an object-oriented approach where variables, objective functions, and constraints are defined as attributes ...
0
votes
1
answer
42
views
How would I reference a variable only in an inherited class?
So for a game I'm developing I'm using a inheritance based finite state system for enemy and boss AI. However I'm coming across a few issues with its implementation.
The base state class is inherited ...
0
votes
0
answers
14
views
What is the rationale behind "extension by overriding" method of inheritance, as seen in Odoo's http.Controller?
Question:
With regards to OOP inheritance, what is the rationale/use case for extension by overriding as opposed to the standard extension by inheritance?
Regarding OOP, as far as I have learnt, ...
-1
votes
2
answers
71
views
Understanding the Need for .map When Working with Optional and Interface Types in Spring Boot
I'm studying clean architecture building a simple Spring Boot application.
Some of my classes are:
public class EClient implements Serializable, EClientInterface {...}
public interface ...
-1
votes
0
answers
29
views
how to call same method from parent and child class using child class object when the argument is same but the implementation is different in child [closed]
class Demo1{
void m1(int a) {
System.out.println(a);
}
}
class Demo2 extends Demo1{
void m1(int a) {
System.out.println(a+a);
}
void m1(int ...
-3
votes
2
answers
77
views
Calling object without creating it, in CPP Oops
In the code below unfortunately I didn't create/name any object and when compiling I didn't get any error and also was able to access member function. How I need to this behaviour is this something ...