Skip to content

Feature Request/Idea:Code optimization suggestions #8771

@noobyu6

Description

@noobyu6

Overview of the Feature Request

Some fields can be replaced by local variables
What kind of user is the feature intended for?
(Example users roles: API User, Curator, Depositor, Guest, Superuser, Sysadmin)

What inspired the request?

What existing behavior do you want changed?

Any brand new behavior do you want to add to Dataverse?

Any related open or closed issues to this feature request?

Hi,

I find that the private field cm at Line 20 in the file 'dataverse/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SWORDv2ContainerServlet.java' on the master branch is only assigned and used in the method init. Therefore, this field can be removed from the class, and become a local variable in the method init. This transformation will normally reduce memory usage and improve readability of your code.

 private ContainerManager cm; // line 20 this field can be replaced by local variable ​   public void init() throws ServletException {         super.init(); ​         // ContainerManager cm = containerManagerImpl;         this.cm = containerManagerImpl; ​         this.sm = statementManagerImpl;              this.api = new ContainerAPI(cm, this.sm, this.config);     }

Besides, there are other fields like this.I sorted them out and put them in the table below.I will be happy if this transformation is helpful.

Location Field
edu.harvard.iq.dataverse.api.datadeposit.SWORDv2ContainerServlet sm
edu.harvard.iq.dataverse.api.datadeposit.SWORDv2StatementServlet sm
edu.harvard.iq.dataverse.Shib emailAddress
edu.harvard.iq.dataverse.DataCiteMetadataTemplate xmlMetadata
edu.harvard.iq.dataverse.search.IndexServiceBean rootDataverseName
edu.harvard.iq.dataverse.DatasetPage protocol
edu.harvard.iq.dataverse.DatasetPage customFields
edu.harvard.iq.dataverse.DatasetPage authority
edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.csv.CSVFileReader doubleMathContext
edu.harvard.iq.dataverse.DatasetServiceBean xmlOutputFactory
edu.harvard.iq.dataverse.harvest.server.web.servlet.OAIServlet repositoryConfiguration
edu.harvard.iq.dataverse.harvest.server.web.servlet.OAIServlet setRepository
edu.harvard.iq.dataverse.harvest.server.web.servlet.OAIServlet itemRepository
edu.harvard.iq.dataverse.dashboard.DashboardUsersPage authUser
edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.dta.NewDTAFileReader constantTable
edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.dta.NewDTAFileReader dataLabelLength
edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.dta.NewDTAFileReader headerLength
edu.harvard.iq.dataverse.harvest.client.FastGetRecord xmlInputFactory
edu.harvard.iq.dataverse.rserve.VariableNameCheckerForR safeVarNames
edu.harvard.iq.dataverse.mydata.DataRetrieverAPI rolePermissionHelper
edu.harvard.iq.dataverse.mydata.DataRetrieverAPI roleList
edu.harvard.iq.dataverse.mydata.DataRetrieverAPI myDataFinder
edu.harvard.iq.dataverse.search.SearchIncludeFragment solrQueryResponseAllTypes
edu.harvard.iq.dataverse.ManagePermissionsPage roleList
edu.harvard.iq.dataverse.mydata.MyDataFinder userIdentifier
edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.por.PORFileReader caseQnty
edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.sav.SAVFileReader spssVersionNumber
edu.harvard.iq.dataverse.ingest.IngestableDataChecker regex
edu.harvard.iq.dataverse.ingest.IngestableDataChecker rdargx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions