Skip to content

Require constructor parameters to avoid temporal coupling #97

Open

Description

At this time the POJOs do not require any specific details on creation. However, the API calls require certain values to be present.

My suggestion would be to request the values required in the constructor to avoid temporal coupling and runtime errors.

Activity

  1. jeevatkm commented on Apr 15, 2019

    @jeevatkm
    Owner

    @janoszen I think currently supported has validations for the required parameters. If I misunderstood your suggestion, could you please provide some code snippet to explain the idea?

  2. jeevatkm commented on Apr 17, 2019

    @jeevatkm
    Owner

    @janoszen Thank you for sharing your suggestion. It is helpful to define a constructor in the respective POJOs. I'm not sure when I can get to this suggestion; there are feature(s) should be added is in pending state.

    FYI, the library already has validations in almost all methods I believe, for example -

    public Droplet createDroplet(Droplet droplet)
    throws DigitalOceanException, RequestUnsuccessfulException {
    if (null == droplet || StringUtils.isBlank(droplet.getName()) || null == droplet.getRegion()
    || null == droplet.getSize() || (null == droplet.getImage()
    || (null == droplet.getImage().getId() && null == droplet.getImage().getSlug()))) {
    throw new IllegalArgumentException(
    "Missing required parameters [Name, Region Slug, Size Slug, Image Id/Slug] for create droplet.");
    }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions