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

Spike refactor the app #798

Closed
wants to merge 43 commits into from
Closed

Spike refactor the app #798

wants to merge 43 commits into from

Conversation

chrisroos
Copy link
Contributor

I'm using this spike to explore whether it's worth trying to simplify the app.

In this branch I:

  • Remove some unused code that I came across
  • Introduce some class methods to replace the ManualsPublisherWiring
  • Remove ManualsPublisherWiring and DependencyContainer

I'm pushing up this work in progress branch to get some feedback about the approach.

Copy link
Contributor

@floehopper floehopper left a comment

Choose a reason for hiding this comment

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

In general this looks good to me, but it would be worth running it by someone with more detailed knowledge of the app, e.g. @h-lame, before merging.

@@ -0,0 +1,9 @@
class PublishingApi
def self.instance
GdsApi::PublishingApi.new(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to be consistent about memo-izing the singleton instance as you did for RummagerApi in this commit, i.e. as per the implementation of SingletonDependency#get.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in ece3882.

@@ -1,3 +1,5 @@
require "gds_api/publishing_api"

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you intend to squash this into the previous commit...?

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in ece3882.


class PublishingApiV2
def self.instance
GdsApi::PublishingApiV2.new(
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be 100% surprised if we need publishing_api and publishing_api_v2. I suspect we can drop the former, and rename the latter to publishing_api

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as before.

Addressed in 8592ac5.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be 100% surprised if we need publishing_api and publishing_api_v2. I suspect we can drop the former, and rename the latter to publishing_api

Addressed by opening #809.


class OrganisationsApi
def self.instance
GdsApi::Organisations.new(ORGANISATIONS_API_BASE_PATH)
Copy link
Contributor

Choose a reason for hiding this comment

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

def self.instance
@rummager_api ||= GdsApi::Rummager.new(Plek.new.find("search"))
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

A pattern that other gov.uk apps have been using is a Services module that has class methods on it for each gds-api used by the app. Might be worth pushing this as far as that too. For example: https://github.com/alphagov/policy-publisher/blob/0f2fa349a043ae7acea37e22bbb08b57154fb30e/lib/services.rb

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed by opening #811.

MarkdownAttachmentProcessor.method(:new),
SpecialistDocumentHeaderExtractor.create,
GovspeakToHTMLRenderer.create,
]
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like it might be a bug that this and the ManualDocumentRenderer you deal with in the next few commits are subtly different; this one doesn't do FootnoteSomethingSomething in its pipeline, but the ManualDocumentRenderer does. We should check obviously, but I think we can get rid of this one and replace it's single use with an instance of the ManualDocumentRenderer instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addresses by opening #810.

@h-lame
Copy link
Contributor

h-lame commented Feb 1, 2017

I think what you've done so far looks good. My comments are mostly about where you could push it further next if you plan to keep iterating on this spike. If you think you're done for now though I don't think it would hurt to merge (maybe wait until #799 is merged and deployed though).

@chrisroos
Copy link
Contributor Author

Thanks for looking at this @floehopper and @h-lame.

Do you think it's worth the effort of tidying this branch up and merging it? Does the approach in general leave the code in an improved-enough state to warrant more work?

@chrisroos chrisroos mentioned this pull request Feb 1, 2017
@chrisroos
Copy link
Contributor Author

Note that some of the early commits in this branch (those that remove code) have been moved to PR #801.

The `:manual_builder` and `:manual_document_builder` are the only
entries in `ManualsPublisherWiring.get` whose name ends in `_builder`.
Making this explicit should help me remove the `ManualsPublisherWiring`
in future.
TODO: Consider splitting this so that the first commit adds
`ManualBuilder.create` and the next inlines `:manual_builder`.
Note that `ManualPublishingApiBulkDraftExporter` takes `wiring` as a
parameter. I'm presuming that it's an instance of
`ManualsPublisherWiring`. I'm not worried about investigating too much
further as `ManualPublishingApiBulkDraftExporter` doesn't appear to be
instantiated anywhere anyway!
This does not appear to be used.
@chrisroos
Copy link
Contributor Author

I've rebased this on master and force pushed now that a number of the other PRs have been merged.

@chrisroos
Copy link
Contributor Author

I've rebased this branch on master, addressed some of the concerns raised in the comments and opened PR #808 which supersedes this PR.

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.

4 participants