oop Questions

4

I need to have some strongly-typed global variables. As mentioned here: Extending TypeScript Global object in node.js, in order to add fields to the global variable I need to add a .d.ts file that...
Mooch asked 18/1, 2017 at 10:32

5

Solved

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 that 'this' is of type any, but we ar...
Glarum asked 19/5, 2019 at 2:44

13

Solved

I am asking a quite simple question, but I am bit confused in this. Suppose I have a class Parent: public class Parent { int name; } And have another class Child: public class Child extends Pare...
Battista asked 28/8, 2012 at 12:49

5

Solved

I recently started creating classes with powershell 5. While I was following this awesome guide https://xainey.github.io/2016/powershell-classes-and-concepts/#methods I was wondering if it is pos...
Hilde asked 5/12, 2016 at 15:17

5

Solved

I am writing Perl classes to remove redundancies from scripts and since Perl has a lot of ways to make classes I keep having trouble making the classes properly. So does anyone have a best practice...
Radiotelegraphy asked 24/6, 2009 at 9:27

8

Solved

Recently we had a discussion regarding Data and Behavior separation in classes. The concept of separation of Data and Behaviour is implemented by placing the Domain Model and its behavior into sepe...
Medarda asked 9/7, 2012 at 6:22

3

Solved

I have the following code: def __static_func(name): print 'Name = ' + name class A: def __init__(self, name): self.name = name def fun(self): __static_func(self.name) a = A('foo') a.fun() ...
Tearful asked 17/10, 2018 at 11:17

8

Solved

I am looking for ways / best practices on testing methods defined in an abstract base class. One thing I can think of directly is performing the test on all concrete subclasses of the base class, b...
Brie asked 18/3, 2012 at 9:37

11

Solved

Is there any way to determine in Javascript if an object was created using object-literal notation or using a constructor method? It seems to me that you just access it's parent object, but if the...
Ansate asked 23/7, 2009 at 18:15

30

Solved

Since I started learning F# and OCaml last year, I've read a huge number of articles which insist that design patterns (especially in Java) are workarounds for the missing features in imperative la...
Huang asked 29/11, 2008 at 20:8

40

Solved

Inversion of Control (IoC) can be quite confusing when it is first encountered. What is it? Which problem does it solve? When is it appropriate to use and when not?

5

Solved

I have a general problem with this use case: I have a class A. This class has a non-abstract method doStuffCallback() which could be overridden but it's not necessary for every subclass. But: I wan...
Metathesis asked 4/10, 2015 at 18:48

5

Solved

I have an abstract class: public abstract class ExampleBase : IExampleBase { protected ExampleBase() { this.SetupData(); } protected abstract Dictionary<int, Adress> RelevantData { ge...
Gnathion asked 20/4, 2015 at 13:18

6

Is there an equivalent in Golang to raising a NotImplementedException in Python when you define an interface with methods that you don't want to implement yet? Is this idiomatic Golang? For exampl...
Coerce asked 14/12, 2016 at 16:11

4

Solved

I have a class User which is a subclass of class PFUser: class User: PFUser { var isManager = false } In one of my methods I receive a PFUser object and I want to cast it to a User object func...
Quintillion asked 10/1, 2015 at 10:44

9

Solved

Java is not allowing inheritance from multiple classes (still it allows inheritance from multiple interfaces.), I know it is very much inline with classic diamond problem. But my questions is why j...
Sirocco asked 11/8, 2009 at 19:36

3

Solved

I am reading the "Deep Learning for Coders with fastai & PyTorch" book. I'm still a bit confused as to what the Embedding module does. It seems like a short and simple network, except...
Marentic asked 25/12, 2020 at 4:2

4

Solved

I'm trying to understand some code which is using this class below: class Base(object): def __init__(self, **kwargs): self.client = kwargs.get('client') self.request = kwargs.get('request') .....
Ricker asked 6/2, 2020 at 22:33

7

Solved

I have a class that is containing 10 methods. I always need to use one of those methods. Now I want to know, which approach is better? class cls{ public function func1(){} public function func2...
Priority asked 14/11, 2015 at 6:57

36

Why prefer composition instead of inheritance? What trade-offs are there for each approach? And the converse question: when should I choose inheritance instead of composition?

15

Solved

In the section about inheritance in the MDN article Introduction to Object Oriented Javascript, I noticed they set the prototype.constructor: // correct the constructor pointer because it points t...
Hydrastinine asked 10/12, 2011 at 2:12

2

Solved

class Main def say_hello puts "Hello" end private def say_hi puts "hi" end end class SubMain < Main def say_hello puts "Testing #{say_hi}" end end te...
Swain asked 18/5, 2015 at 1:14

4

Suppose we are designing a UserServiceImpl class which does CRUD (Create, Read, Update, and Delete) operations. In my view Create, Read, Update, and Delete are four reasons for a class to change. D...
Diazotize asked 15/4, 2010 at 7:53

1

How do tools like dataclasses and pydantic create the __init__() functions for the classes they create? I know I can use these tools but I want to learn how to use the python metaprogramming to par...
Mikesell asked 19/2 at 9:12

2

Solved

I have an ExpandoObject and want to make a getter for it that will return a property by name at runtime, where the name is specified in a string instead of hardcoded. For example, I CAN do this: ...
Dealer asked 2/10, 2013 at 14:28

© 2022 - 2024 — McMap. All rights reserved.