Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryProfilerDecorator to replace QueryData #17

Merged
merged 1 commit into from
Nov 14, 2013

Conversation

mwjames
Copy link
Contributor

@mwjames mwjames commented Nov 11, 2013

Should probably be moved into SMW\Query\Profiler ns but this something tha can be done in a follow-up after Travis

@ghost ghost assigned JeroenDeDauw Nov 11, 2013
@JeroenDeDauw
Copy link
Member

Is this a resubmit of something on Gerrit?

@mwjames
Copy link
Contributor Author

mwjames commented Nov 11, 2013

This only exists on the github.com/SemanticMediaWiki/SemanticMediaWiki repo (I wanted to see how a larger change is handled in github.com/Travis without Gerrit).

@JeroenDeDauw
Copy link
Member

In that case, can you provide a brief high level description of this change?

@mwjames
Copy link
Contributor Author

mwjames commented Nov 12, 2013

Summary

The change does the exact same thing as [1](this is also why the #ask, #show tests didn't need any alteration besides the constructor) but it injects a Subobject instead of a Title object (which makes it independent from a MW data object) but more importantly it now uses a Decorator [2] for construction meaning that an additional profiling item such as duration would add a new component instead of changing the content of the original class and with it leaving existing tests untouched or unharmed.

Splitting the class lowers the SRP violation from [1] due to the elimination of multi-object injection that persisted before making it possible for a decorator component to handle only a specific object (QueryFormat, QueryDescription etc.).

Maybe createProfileEntry() is a better name than addProfilingData() for the QueryProfiler interface.

Follow-up

  • Delete SMW\QueryData class
  • Recycle QueryDataTest as it is actually an integration test using the QueryProcessor the create a Query object
  • Move classes into SMW\Query\Profiler namespace

[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/includes/query/QueryData.php

[2] new NullProfiler( ... ), new DescriptionProfiler( ... ), new FormatProfiler( ... )

PS: I somewhat like the review in Gerrit better, the review process in Github seems a bit off especially for larger changes.

*
* @return string|null
*/
protected function disabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though unchanged in this commit, this is a bad method name.

@JeroenDeDauw
Copy link
Member

I don't see any real issues with this, feel free to merge

## Summary
The change does the exact same thing as [1] (this is also why the #ask,
#show tests didn't need any alteration besides the constructor) but it
injects a Subobject instead of a Title object (which makes it independent
from a MW data object) but more importantly it now uses a Decorator [2]
for construction meaning that an additional profiling item such as
duration would add a new component instead of changing the content of
the original class and with it leaving existing tests untouched.

Splitting the class lowers the SRP violation from [1] due to the
elimination of multi-object injection that persisted before
making it possible for a decorator component to handle only a specific
object (QueryFormat, QueryDescription etc.).

## Follow-up
* Move classes into SMW\Query\Profiler namespace
mwjames added a commit that referenced this pull request Nov 14, 2013
QueryProfilerDecorator to replace QueryData
@mwjames mwjames merged commit 99c39e4 into master Nov 14, 2013
@mwjames mwjames deleted the query-profiler-decorator branch November 14, 2013 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants