qi4j

Post on 11-Nov-2014

772 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

a lighting talk that i did for Qi4j

TRANSCRIPT

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

top related