object oriented – Is “pass through” boilerplate code the trade off for improved encapsulation and composition?

I see this most when people add a layer which might be best practice, but they dont have enough logic to fill it out.

eg in a MVC design

   GetThings() { return myService.GetThings(); }
   GetThings() { return myRepository.GetThings(); }
   GetThings() { return myOffTheShelfDAL.Get<Thing>("select * from thing"); }

So yeah, best practice says all these layers are good, maybe you will fill them out some day, maybe you are just doing them from muscle memory and its not taken any more time. You cant say its bad per-se. But is the same app had had been written with…

   GetThings() { return myOffTheShelfDAL.Get<Thing>("select * from thing"); }

No-one would be saying “Oh! you need a service layer and a repository!!”

geometry – What is the rule for given composition of transformations?

I can’t figure out the rule for the composition of the transformation done to get the image $∆B”C”D”$. At first I tried translating $D”$ so that it aligned to $D$ and reflected it to get the rule $r_{x=-3}circ T_{(0,-2)}$. But this rule doesn’t map $C$ and $B$ to $C”$ and $B”$. Any ideas how to figure out the rule?

enter image description here

cv.complex variables – Is an entire function $mathbb{C}^ntomathbb{C}$ a composition of polynomials, univariate entire functions and integrals?

Let $S$ be a set of entire functions $mathbb{C}^ntomathbb{C}$.

To enlarge it we can take polynomial combinations of its elements, compose them with entire functions $mathbb{C}tomathbb{C}$ and apply $int_0^z$ as a functional.

Can every entire function $mathbb{C}^ntomathbb{C}$ be reached from $S={pi_1, dots, pi_n}$ in finitely many steps?

Composition over inheritance when dealing with relationships

Note: I am not sure of the correct terminology for what I am describing, so if you have suggestions for a better title please feel free to edit it.

Composition over inheritance is generally a good rule to follow, but there are some cases where inheritance is a must, like in the following case:

Node a = ...
Node b = ...
List<Node> path = GraphUtil.shortestPath(a,b);

Here we have a hypothetical graph library that provides some nice functionality for us, but we would like to augment it with some extra properties, like color or something. If we use inheritance, our code can be like this:

MyNode a = ...
MyNode b = ...
List<MyNode> path = (List<MyNode>)GraphUtil.shortestPath(a,b);
// highlight the path:
for (MyNode n : path) { path.setColor("green"); }

This is still not totally amazing due to a runtime cast, but it gets the job done.

However, if we were to use composition, this won’t work at all. We would need some kind of external map in order to achieve this (in C++ maybe some pointer hackery).

The question is: are there any existing strategies to achieve this behavior via composition?

Of course the obvious answer is “just use inheritance”, but if the Node class is made by a factory or is otherwise inconvenient to inherit from, what are the alternatives? Obviously a map is one option, but that is very inconvenient and messy, and not to mention slow.

Constraint composition in haskell – Stack Overflow

I was trying to use the Data.Constraint package to do some constraint programming but I am hitting a wall. Is there an implementation for compHasLens in the following example?

import qualified Control.Category   as C
import           Data.Constraint

-- | A very simple lens to handle the infinite type problem.
data a :>:  b =
  { getL :: a -> b,modL :: (b -> b) -> a -> a }

instance C.Category (:>:) where
  a . b = Lens' { getL = getL a . getL b,modL = modL b . modL a  }
  id = Lens' { getL = id,modL = id }

class HasLens a b where
  defLens :: a :>: b

composeHasLens :: Dict (HasLens a b) -> Dict (HasLens b c) -> Dict (HasLens a c)
composeHasLens Dict Dict = error "Is there an implementation for this?"

The semantics might be a bit strange:

instance HasLens A B
instance HasLens B C
instance HasLens A C

lAB :: Dict (HasLens A B)
lAB = Dict
lBC :: Dict (HasLens B C)
lBC = Dict
-- | The one from the instance
lens :: A :>: C
lens = defLens
-- | The composition.
lens' :: A :>: C
lens' = case composeHasLens lAB lBC  of
  Dict -> defLens

But if I understand correctly GHC accepts constraints as arguments it seems like it should possible in principle at least?

ag.algebraic geometry – Composition of holomorphic maps and normal bundle

Let $X$, $Y$ and $Z$ be smooth manifolds and

be two composable embeddings. One can consider the normal bundles $N_{X/Y}to X$ and $N_{Y/Z} to Y$ and the normal bundle $N_{X/Z} to X$ of the composition.

We know:

$N_{X/Z} cong N_{X/Y} oplus f^*N_{Y/Z}$ in this smooth setting, but the proof (as far as I know) uses splittings. To what extent does this work in the holomorphic category? Specifically, does this work for diagonal maps $Delta: X rightarrow X times X$ and their iterative compositions? ($Delta: X times X xrightarrow{id times Delta} X times X times X$ etc.)

group theory – Show that if f is invertible, then the composition of iteration of functions $f^{i_0} circ f^{i_1} = f^{{i_0}+{i_1}}$.

I just started studying dynamical systems, and one of the exercises is to show that if $f:Xrightarrow X$ is an invertible function, that is, there exists a function $g:Xrightarrow X$, such that for any $x_0 in X$ we have $fcirc g = x_0$ and $gcirc f = x_0$, then for any $i_0, i_1 in Z$, we have $f^{i_0} circ f^{i_1} = f^{{i_0}+{i_1}}$. I appreciate any help.

c# – Implement IDisposable correctly using object composition principle

Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication and hide verbose “official” implementation?



Delegate the dispose logic to a dedicated class:

public class DisposeManager
    public Action Managed { get; set; }
    public Action Unmanaged { get; set; }

    protected virtual void Dispose(bool disposing)
        // only dispose once
        if (disposed)

        if (disposing)


        disposed = true; 

    public void DisposeObject(object o)
        Dispose(disposing: true);

    public void FinalizeObject()
        Dispose(disposing: false);

    private bool disposed;

Implement IDisposable in user class in the following way:

public class DisposeUser: IDisposable
    public DisposeManager DisposeManager { get; } = new DisposeManager();

    public DisposeUser()
        // using lambda
        DisposeManager.Managed = () =>
            // (...)

        // or using member method
        DisposeManager.Unmanaged = DisposeUnmanaged;


    public void Dispose()

    protected void DisposeUnmanaged()
        // (...)


  • much simpler to implement for user classes
  • more explicit (managed, unmanaged)
  • use composition
  • remove the needs for multiple base classes all implementing the dispose pattern and creating code duplication


  • Is it ever a good idea or more of a programmer fancy “improvement” idea ?
  • I’ve made a decent number of research on the dispose pattern and implementation but never found someone suggesting such idea, any reason why?
  • Any potential problems around hard refs, especially with Action capturing members, etc. that would prevent the actual user class to be collected correctly?
  • Other thought?