qi4j
DESCRIPTION
a lighting talk that i did for Qi4jTRANSCRIPT
QI4j
What is
● Framework● Composite Oriented Programming● DDD● Aop● DI
Principles
OOP is Class Oriented
Behavior Depends on Context
Decoupling is Virtue
Business Rules matters more
Solution
Fragments
Composite
HelloWorld
public interface HelloWorld extends HelloWorldBehaviour, HelloWorldState {
}
Behaviour
@Mixins( HelloWorldBehaviourMixin.class )
public interface HelloWorldBehaviour
{
String say();
}
Impl
public class HelloWorldBehaviourMixin
implements HelloWorldBehaviour
{
@This HelloWorldState state;
public String say()
{
return state.getPhrase() + " " + state.getName();
}
}
State
@Mixins( HelloWorldStateMixin.class )
public interface HelloWorldState
{
void setPhrase(@NotEmpty String phrase )
throws IllegalArgumentException;
String getPhrase();
void setName( @NotEmpty String name )
throws IllegalArgumentException;
String getName();
}
Running
TransientBuilderFactory factory = assembler.transientBuilderFactory();
HelloWorld olaMundo = factory.newTransient( HelloWorldComposite.class );
olaMundo.setName("Jeff");
olaMundo.setPhrase("adoro mac");
System.out.println( olaMundo.say() );