Casting Generic base object to derived type

What is the correct way to cast a base class that is using generics back to its derived type? I have the following object implemented. Note that the "Save" method is calling the "WriteSettings" method here (takes in a BaseSettings object) public...
more »

2017-09-15 21:09 (1) Answers

Swift protocol specializing generic protocol

Is it possible to have a protocol that specializes a generic protocol? I want something like this: protocol Protocol: RawRepresentable { typealias RawValue = Int ... } This does compile, but when I try to access the init or rawValue from a Pro...
more »

2017-09-14 18:09 (1) Answers

Swift generic inheritance

I have one base view controller and some child view controllers. I am having difficulty to pass the view model created in children view controller (CommentViewController) to it's parent view controller (FeedBaseViewController) to access. class BaseV...
more »

2017-09-08 10:09 (1) Answers

Kotlin override fun with subtype

Im having trouble inheriting an interface containing a method/fun of a base type, that i would like to override as a subtype in the class implementing it. So far i have the interface interface IModel { fun convert(dataModel: BaseDataModel) } ...
more »

2017-09-07 22:09 (2) Answers

Inheritance and Polymorphism in REST API Modeling

I have an object hierarchy that I want to expose through a REST API, and I want to discuss best practices. I have seen this question asked before (e.g. here at the end, here, here, and especially here), but never really any conclusions arrived at. ...
more »

2017-09-07 01:09 (1) Answers

python 3 class inheritance issue

class A(object): def __init__(self): self.a = 1 class B(A): def __init__(self): A.__init__(self) self.a = 2 self.b = 3 class C(object): def __init__(self): self.a = 4 self.c = 5 class D(...
more »

2017-09-05 22:09 (1) Answers

Syntax: derived type, nested generics

I want to have a dictionary that maps from one generic type K<T> to another generic type V<T>. Note that type T should be the same in both cases. So I thought I would create a derived class from Dictionary<K,V> with one more type ar...
more »

2017-09-04 13:09 (2) Answers

Creating a factory method returning generic

I have an abstract class defined this way: class BaseCoordinator<ResultType> Other classes inherit from this one eg. final class AppCoordinator: BaseCoordinator<Void> final class AuthFlowCoordinator: BaseCoordinator<AuthFlowCoordin...
more »

2017-08-29 13:08 (2) Answers

Java Builder pattern with inheritance

I want to implement a builder pattern with static inner classes for lets say classes A with fields (a1, a2, a3), B with fields (b1, b2) and C with fields (c1), whereas all share fields (s1, s2) from super class SuperClass: public class A extends Sup...
more »

2017-08-28 20:08 (1) Answers