Skip to content
This repository was archived by the owner on Mar 18, 2018. It is now read-only.
This repository was archived by the owner on Mar 18, 2018. It is now read-only.

Replace constructor with StepBuilder pattern #12

@rafakob

Description

@rafakob

Consider replacing constructor for required fields with StepBuilderPattern. Constructor has two cons:

  • if you got a lot of extras, you need to keep track their order
  • if you change field position in activity, constructor arguments will also be changed, eg:
@Extra String s;
@Extra int i;
startActivity(new DetailActivityIntentBuilder(myString, myInt).build());

Switch position in code:

@Extra int i;
@Extra String s;
// constructor will be changed to: DetailActivityIntentBuilder(int i, String s). 
// You'd have to switch your parameters. And what if their the same type? You're not gonna get compile error.
startActivity(new DetailActivityIntentBuilder(myString, myInt).build());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions