Skip to content

Usage of static fields #12

Description

@eugene-nikolaev

@yegor256, I cannot figure out what are criteria for making a field static or not.
E.g.

    final class TkBadge implements Take {

    /**
     * XSL.
     */
    private static final XSL SVG = XSLDocument.make(
        TkBadge.class.getResourceAsStream("badge.xsl")
    );

After reading your books I often hesitate to make something static but sometimes pretty constant non-static fields looks weird.
Where is the line which should be drawn?

I think it is more like OK than not?:

private static final String REV = Manifests.read("Rehttp-Revision");

Bit why this isn't really a ctor?

/**
     * Ctor.
     * @param base Base
     * @return App
     * @throws IOException If fails
     */
    private static Take app(final Base base) throws IOException {

Well, I guess it should be fixed as long as the methods aren't being used in a static context or in this(...):

    // DyTake.java 
    private static int code(final Response response) throws IOException {
    private static Request request(final Request req, final URI uri) 

So, what is a legal use of static fields? Is it OK for really definitions which are unlikely will need to be overriden (say even in the unit-tests)?

Activity

  1. 0crat commented on Sep 5, 2017

    @0crat
    Collaborator

    @eugene-nikolaev I'm not managing this repo, remove the webhook or contact me in Slack //cc @yegor256

  2. 0crat commented on Jun 21, 2019

    @0crat
    Collaborator

    Job #12 is now in scope, role is DEV

  3. 0crat commented on Jun 21, 2019

    @0crat
    Collaborator

    Thanks for your contribution, @eugene-nikolaev/z! If you would be a member of the project, you would now earn +15 reputation points, as explained in §29. You can join and apply to it, see §2.

  4. 0crat commented on Jun 21, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  5. 0crat commented on Jun 26, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  6. 0crat commented on Jul 1, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  7. 0crat commented on Jul 6, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  8. 0crat commented on Jul 11, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  9. 0crat commented on Jul 16, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  10. 0crat commented on Jul 21, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

  11. 0crat commented on Jul 26, 2019

    @0crat
    Collaborator

    @yegor256/z everybody who has role DEV is banned at #12; I won't be able to assign anyone automatically; consider assigning someone manually (as in §19), or invite more people (as in §51), or remove the job from the scope (as in §14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions