{"comment":{"url":"https://api.github.com/repos/firedrakeproject/ufl/comments/18352309","html_url":"https://github.com/firedrakeproject/ufl/commit/ceb71df8908e1354f059c41d4632735be2cbfd1e#commitcomment-18352309","id":18352309,"user":{"login":"wence-","id":1126981,"avatar_url":"https://avatars.githubusercontent.com/u/1126981?v=3","gravatar_id":"","url":"https://api.github.com/users/wence-","html_url":"https://github.com/wence-","followers_url":"https://api.github.com/users/wence-/followers","following_url":"https://api.github.com/users/wence-/following{/other_user}","gists_url":"https://api.github.com/users/wence-/gists{/gist_id}","starred_url":"https://api.github.com/users/wence-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wence-/subscriptions","organizations_url":"https://api.github.com/users/wence-/orgs","repos_url":"https://api.github.com/users/wence-/repos","events_url":"https://api.github.com/users/wence-/events{/privacy}","received_events_url":"https://api.github.com/users/wence-/received_events","type":"User","site_admin":false},"position":32,"line":32,"path":"ufl/finiteelement/custompullback.py","commit_id":"ceb71df8908e1354f059c41d4632735be2cbfd1e","created_at":"2016-07-22T09:28:03Z","updated_at":"2016-07-22T09:28:03Z","body":"I note this design pattern (the [decorator pattern](https://en.wikipedia.org/wiki/Decorator_pattern)) of a class wrapping an object *instance* to provide new functionality appears quite a number of times in the UFL finite element classes: `CustomPullback`, `BrokenElement`, `TraceElement`, `FacetElement`, `InteriorElement`, `HDivElement`, `HCurlElement`, and sort of `RestrictedElement`.  Maybe we should consider a generic implementation like the following:\r\n\r\n```python\r\nclass ElementDecorator(object):\r\n    def __new__(cls, decorated):\r\n        typ = type(cls.__name__, (cls, decorated.__class__), decorated.__dict__)\r\n        return object.__new__(typ)\r\n```\r\n\r\nNow all the wrapper elements just inherit from `ElementDecorator` and implement the needed extra methods/information.  No need to implement this `__getattr__` stuff, or copy properties across adhoc.\r\n\r\nThoughts?"}}
{"actor":{"display_login":"wence-"}}