My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
BestPractices  
Best practices
Updated Aug 31, 2010 by gal.dol...@gmail.com

The PlaceManager is the best way to decouple your code

Guit allow you to store complex data into your places.

But complexity is not always the solution.

i.e:

Direct reference (Bad):

ProductListPresenter implements Place<Void>
ProductListPresenter @Injects ProductViewerPresenter

// Call
productViewerPresenter.show(productId);

Decoupled throw the PlaceManager (Better):

ProductListPresenter implements Place<Void>
ProductViewerPresenter implements Place<Integer> // the product id

// Call
placeManager.go(ProductViewerPresenter.class, productId);

Hide your presenters behind an api

Instead of injecting a presenter into another, inject an interface.

i.e

Injecting presenters (Bad):

class MyComplexPresenter .... {

    public void doSomething() {
        ...
    }
}

class MyAnotherPresenter ... {
    @Inject
    public MyAnotherPresenter(MyComplexPresenter myComplexPresenter) {
        myComplexPresenter.doSomething();
    }
}

Injecting api (Better):

interface MyComplexPresenter {
    void doSomething();
}

class MyComplexPresenterImpl .... implements MyComplexPresenter {

    @Override
    public void doSomething() {
        ...
    }
}

class MyAnotherPresenter ... {
    @Inject
    public MyAnotherPresenter(MyComplexPresenter myComplexPresenter) {
        myComplexPresenter.doSomething();
    }
}
Powered by Google Project Hosting