React.js: Wrapping one component into another

Many template languages have “slots” or “yield” statements, that allow to do some sort of inversion of control to wrap one template inside of another. Angular has “transclude” option. Rails has yield statement. If React.js had yield statement, it would look like this: var Wrapper = React.createClass({ render: function() { return ( <div className=”wrapper”> before … Read more

What is the difference between association, aggregation and composition?

What is the difference between association, aggregation, and composition? Please explain in terms of implementation. 20 s 20 For two objects, Foo and Bar the relationships can be defined Association – I have a relationship with an object. Foo uses Bar public class Foo { private Bar bar; }; NB: See Fowler’s definition – the … Read more

Difference between Inheritance and Composition

They are absolutely different. Inheritance is an “is-a” relationship. Composition is a “has-a”. You do composition by having an instance of another class C as a field of your class, instead of extending C. A good example where composition would’ve been a lot better than inheritance is java.util.Stack, which currently extends java.util.Vector. This is now … Read more