My app has a Place for every EntityProxy type.

BasePlace has getProxyType() method that is called in
MyActivityMapper.getActivity(place).
Based on the proxy type returned, getActivity() method looks up an
activity factory and calls factory.createActivity(place, config)

All I have to do is to create an factory for every activity and
configure the lookup table.
If I forget to create a factory for a new activity, an assert will
warn me about that.

This might not be the best approach (may be there is a way to replace
my factories with Gin, but I haven't investigated this yet), but I
don't have any instaceof's in the ActivityMapper.

If someone uses other approaches, please share, it would be very
informative.


On Jan 3, 11:40 am, zixzigma <zixzi...@gmail.com> wrote:
> are you suggesting this is nothing to worry about ?
>
> in the case of Expenses app, there are only three entities: Expenses,
> Reports, Employees
> (and number of places and fine-grained activities mapper, is relative
> to the number of entities)
>
> however, in a larger app , there might be 50 entities.
> and when using 4-5 ActivityMappers (for different display regions),
> it will get difficult to manage.
>
> #1 - One approach is checking all our 50 entities(or places) in one
> giant if/else block.
> (50 if/else statement)
>
> #2- However, I believe we can group together our fine-grained
> activities-mapper,
> by using a base class for each group, and delegating the "instance of"
> checks,
> to a more specific activities mapper. this is better than using one
> giant if/else in ActivityMapper,
> but somehow these selections gets scattered.
>
> My Concern is this:
>
> I have read that frequent usage of "instance of" is a sign of code
> smell.[*]
> and also have read that if we have to resort to conditional instanceof
> checks, it is better to keep it in one place
> for the smell not getting spread !
>
> the approach #2, delegating the "instanceof checks" to a more specific
> mapper, will result in the code smell to spread.
>
> and code inspection tools also flag these "instanceof", it gives the
> impression of poor application design.
> this is what I'm very worried about : (
>
> [*]Java quality assurance by detecting code 
> smellshttp://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.80.2066&rep=...

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to