Skip to main content

Questions tagged [trait]

4 votes
2 answers
308 views

While developing my application I faced an interesting situation: I have multiple DTO's which are almost identical in terms of methods, only properties are different. For example I have AccountDTO ...
Viacheslav Ravdin's user avatar
1 vote
1 answer
237 views

Situation I have some existing functions which expect containers which can be iterated and which have certain value_type. The value_type can be a value or some (smart) pointer. All the value_type have ...
ridilculous's user avatar
6 votes
3 answers
617 views

As a fan of regular types and value semantics, I'm keen on classes becoming more regular and being non-polymorphic. As a fan of non-throwing operations, I'm keen on operations being noexcept. I also ...
Louis Langholtz's user avatar
12 votes
2 answers
5k views

From what I can tell from Scala and Hack- Mixins: Can have state (ie. instance properties) Can only provide concrete methods Can have constructors, that are called in the same order that their ...
bcherny's user avatar
  • 273
8 votes
2 answers
753 views

I recently I started learning Rust and Scala and what struck me was the lack of inheritance model that I'm used to in C++ and Java. Although I can model simple things with structs and traits in Rust,...
sadiq.ali's user avatar
  • 217
8 votes
2 answers
7k views

I need to extend a third party class I cannot modify. The class's dependencies are for the most part injected through the constructor, making them easy to mock. However the class also uses methods ...
TravisCarden's user avatar
20 votes
1 answer
3k views

It seems that in all class-based or prototypal OOP languages, mixins are either an afterthought or a secondary feature. However, to me it looks like traditional inheritance is just a specific case of ...
Den's user avatar
  • 4,887
1 vote
0 answers
514 views

When I am adding dependencies in Scala, I tend to use mixin trait components for those that are inherit to the class itself. For example, DaoGenerator extends Generator However, for trait components ...
user1555300's user avatar

15 30 50 per page