qi4j

18
QI4j

Upload: alexandre-poletto

Post on 11-Nov-2014

772 views

Category:

Technology


0 download

DESCRIPTION

a lighting talk that i did for Qi4j

TRANSCRIPT

Page 1: Qi4j

QI4j

Page 2: Qi4j

What is

● Framework● Composite Oriented Programming● DDD● Aop● DI

Page 3: Qi4j

Principles

Page 4: Qi4j

OOP is Class Oriented

Page 5: Qi4j

Behavior Depends on Context

Page 6: Qi4j
Page 7: Qi4j
Page 8: Qi4j

Decoupling is Virtue

Page 9: Qi4j

Business Rules matters more

Page 10: Qi4j

Solution

Page 11: Qi4j

Fragments

Page 12: Qi4j

Composite

Page 13: Qi4j

HelloWorld

public interface HelloWorld extends HelloWorldBehaviour, HelloWorldState {

}

Page 14: Qi4j

Behaviour

@Mixins( HelloWorldBehaviourMixin.class )

public interface HelloWorldBehaviour

{

String say();

}

Page 15: Qi4j

Impl

public class HelloWorldBehaviourMixin

implements HelloWorldBehaviour

{

@This HelloWorldState state;

public String say()

{

return state.getPhrase() + " " + state.getName();

}

}

Page 16: Qi4j

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();

}

Page 17: Qi4j

Running

TransientBuilderFactory factory = assembler.transientBuilderFactory();

HelloWorld olaMundo = factory.newTransient( HelloWorldComposite.class );

olaMundo.setName("Jeff");

olaMundo.setPhrase("adoro mac");

System.out.println( olaMundo.say() );

Page 18: Qi4j