Questions tagged [mixins]
A mixin is a way to enhance an object with properties or methods from another object.
30
questions
32
votes
5answers
5k views
Chess game for my students
I teach programming, and I currently teach my class about inheritance, abstract classes, and mixins.
I wrote this code as an example, and I want to be sure it is as good as possible before I release ...
1
vote
1answer
43 views
Proper naming for objects which have a position and bounds on a plane
I have an interface which is for an object which has bounds in a 2D plane.
...
3
votes
0answers
111 views
Boilerplate-free mixin pattern for a TypeScript charting library
The TypeScript handbook provides a mixin pattern but it requires a bunch of boilerplate, doesn't work for getters/setters and doesn't support defining default values (or any constructor work) in the ...
2
votes
2answers
584 views
SASS mixin for a font-awesome before/after usage
In my SASS I use font-awesome declarations all over the place. I'm in love with it. I've created a SASS mixin for the usage:
I started with the following:
...
2
votes
1answer
289 views
SASS/SCSS mixin for button states
I have created several mixins for a button to attempt to reduce duplication and contribute to the overall improvement of performance. I am looking for guidance on how to tighten this up so it is as ...
2
votes
1answer
250 views
Less CSS Mixin for positioning with options for corresponding top, left, right, bottom values
I've created a Mixin in Less CSS. It can do the following things:
Set the position-rule of an element.
Place the element in one of the corners (e.g. top left, bottom right etc.)
Alternatively it can ...
7
votes
1answer
215 views
Create six hash tables - 2 hashing schemes x 3 collision handling schemes
I was asked to solve the following task:
Given two methods for hashing (division and multiplication) and three
methods for collision handling (chaining, open addressing w/ quadratic
probing, ...
1
vote
1answer
115 views
Applying a set of styles both with a media query and with nested rules
I am working on an application which responds to different screen resolutions. At a certain minimum DPI, we want to apply a set of styles. We also want to apply that same set of styles if the class <...
2
votes
0answers
98 views
Copy-on-write in Ruby
I need to return private collection and
avoid calling code modifying them
avoiding copying overhead if possible
So I thought of returning copy-on-write arrays, hashes, and sets.
I couldn't find any ...
1
vote
0answers
29 views
Sass-Mixin for to attach a text-shadow animation upon HTML-elements
I've make these mixins by using SCSS-Sass. Any hints and tipps concerning improvements are welcomed.
...
2
votes
1answer
61 views
SASS mixin to define modifier classes for various screen sizes
I wish to make a mixin to produce the following result of modifier classes:
...
1
vote
1answer
141 views
JavaScript inheritance with super calls and mixins
I needed JavaScript inheritance that offered calling of overridden methods (super calls).
Furthermore I needed a possibiliy to add behaviour to instances (mixins).
Mixins should not only be full ...
2
votes
0answers
66 views
ActiveAdmin menu-generating mixin
I've written an ActiveAdmin mixin, such that you can include it and call simple_menu_for Foo, to reduce duplicate code when working with simple models. Here is the ...
3
votes
1answer
66 views
Implicit type class for updating maps
With the help of SO I got my code working, but I think it still could be improved, in particular I do not like using asInstanceOf. Is there some way how to avoid it?...
2
votes
0answers
190 views
Mixin implementation helper
While implementing things like repositories we often can see that reading and writing parts can be done totally independently. The same time client side will win from the single reference (who wants ...
8
votes
1answer
375 views
A Mixin Comparator class
Idea:
In C++, often a straightforward implementation of comparison operators is needed. In C++11, they can be conveniently implemented using std::tie. The following ...
4
votes
2answers
88 views
Simple Translation Gem
I have a small gem that I've been maintaining. This gem provides a simple way to do translation using an alternative Google API.
I've been working with Java last year and recently did some ...
4
votes
0answers
78 views
Creating companion classes that are `inherited` onto any sub-classes
The idea for the code I have written came about due to the acts_as_versioned gem which automatically nests a Version class onto ...
1
vote
0answers
38 views
IUnitTest, INonCopyable, and IMapKey mixins
I am creating a boiler-plate namespace that will allow me to ensure proper coding practices are followed and avoid gotchas.
Looking over my code below; can you see any "no-no's" or gotchas? Can you ...
2
votes
2answers
182 views
Simulating MixIns with Java
I am using the following technique for simulating mixins (or Traits) using Java and would like to know whether this is reasonable or just confusing to future developers. Also, I believe a good naming ...
3
votes
0answers
119 views
Extracting dynamic behaviors of state machines to modules
This is my initial class. (I am not trying to reinvent state-flows again, just practicing)
As you can see straight forward, it dynamically generates methods like .recommend,.recommend!, ....
3
votes
1answer
572 views
More elegant Sass @mixin to create pseudo-element shapes
I picked up Sass last week, and I'm already diving into expressions. I have a @mixin that creates a CSS border triangle using the following call: ...
4
votes
1answer
211 views
Utility library and Underscore mixin - 1
This code is similar to Underscore. I've added in some functions to fill in different use cases.
For example, one can use someKey to iterate through ...
8
votes
2answers
5k views
Policy-based, variadic logger class in C++
I've been exploring design based around some of the more advanced C++11 features lately, and some of them are turning out to be rather useful for some projects I'm working on. One is this policy-based,...
2
votes
0answers
130 views
Modification of the headline line-height in the Compass vertical rhythm module
One thing nagged me about the compass vertical rhythm module; in the case the headline is too long and it occupies more than one line the line-height between the two lines looks way too massive and ...
2
votes
1answer
87 views
JavaScript mixins, extending and super methods
I've read a lot of stuff about mixins, inheritance and such, and in the end I came up with this solution for extending a class with multiple mixins. I haven't seen this anywhere else...
Is this a ...
0
votes
1answer
434 views
JavaScript mixins - extending and super methods [closed]
I've read a lot of stuff about mixins, inheritance and such, and in the end I came up with this solution for extending a class with multiple mixins. I haven't seen this anywhere else...
...
2
votes
0answers
263 views
10
votes
1answer
396 views
Mixin and template-heavy code for a Silverlight clone
I've made a mock version of Silverlight in D2. It is meant to output HTML, but since I don't know HTML yet, its current output is in. HTML is not the reason I'm here, though. The goal of my project ...
5
votes
1answer
4k views
Multiple inheritance Mixin class
I've written a simple class that somewhat simulates multiple inheritance using mixins. It allows you to extend the functionality of multiple classes and manage any conflicts between them, should they ...