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

Add a functional programming example #182

Merged
merged 8 commits into from
Feb 21, 2024
Merged

Add a functional programming example #182

merged 8 commits into from
Feb 21, 2024

Conversation

twalmsley
Copy link
Collaborator

This example is an attempt at writing code in a style that results in a more readable program flow. The test method clearly shows the steps in the use case, even if there looks to be a lot of code. The hope is that the fine-grained functions can be made reusable in other contexts so that composing new use cases from existing functions may become easier.

@twalmsley twalmsley self-assigned this Jan 27, 2024
@twalmsley
Copy link
Collaborator Author

The real question for this PR is whether the code is any easier to read and understand, and is it better structured - if not then I don't mind if this PR is rejected.

@GCHQDeveloper42
Copy link
Contributor

I would prefer this to be made an executable class like the other examples, rather than a unit test.

@twalmsley
Copy link
Collaborator Author

I would prefer this to be made an executable class like the other examples, rather than a unit test.

I can move it to src/main/java and add main() but will it ever be executed? We can't be sure the examples are correct unless they're executed when code changes - we might find out months later. It could be added as a build step but would need updating for every new example.

@GCHQDeveloper42
Copy link
Contributor

I can move it to src/main/java and add main() but will it ever be executed? We can't be sure the examples are correct unless they're executed when code changes - we might find out months later. It could be added as a build step but would need updating for every new example.

I take your point. Could you define the program in an example class and then execute it in a FunctionalProgrammingExampleTest suite?

@GCHQDeveloper42 GCHQDeveloper42 merged commit b01fee0 into main Feb 21, 2024
3 checks passed
@GCHQDeveloper42 GCHQDeveloper42 deleted the tw-example-code branch February 21, 2024 12:08
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