Collect: FormEntryActivity Refactor - 'currentView' access is dangerously inconsistent.

Created on 30 Aug 2017  路  10Comments  路  Source: getodk/collect

There are 20 different places where the cast ((ODKView) currentView) occurs in FormEntryActivity. Some of these have an instanceof check before, some have a null check before, some have both, and some have neither.

This variable is only ever set to the result of createView. There are paths through createView that return non ODKView objects and null.

I propose hiding the currentView access behind an @Nullable getter, checking for the correct type, and returning null if the currentView is not ODKView. At the call site, we can replace the direct attribute access with null check calls to this method.

help wanted refactor

Most helpful comment

Thank you Mr. @opendatakit-bot. 馃ぃ馃ぃ

All 10 comments

I agree we should refactor this part of code and btw it would be greate if we can change that name...
ODKView why? Does it sound strange to anyone else? Maybe SurveyView or FormView?

@jknightco the proposed change sounds great.

@grzesiek2010 I'm not necessarily opposed to that but I think it's a separate question!

Hello @grzesiek2010 @lognaturel I will like to look into this issue.

Fantastic, thanks @icemc! For issues that don't need discussion you can simply comment opendatakit-bot claim and it will be yours. 馃槉

opendatakit-bot claim

Ahhh, I'm sorry. You need the @ in front of the bot name to get its attention.

yeah forgot about that too

@opendatakit-bot claim

Welcome to Open Data Kit, @icemc! We just sent you an invite to collaborate on this repository at https://github.com/opendatakit/collect/invitations. Please accept this invite in order to claim this issue and begin a fun and rewarding experience contributing to Open Data Kit!

Here are some tips to get you off to a good start:

  • Please read the README.md and CONTRIBUTING.md in this repo. Those two documents have much of what you need to get started.
  • Join the ODK developer Slack to get help, chat about this issue, and meet the other developers.
  • Sign up and introduce yourself on the ODK community forum to meet the broader ODK community.

See you on the other side (that is, the pull request side)!

Thank you Mr. @opendatakit-bot. 馃ぃ馃ぃ

Was this page helpful?
0 / 5 - 0 ratings