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

Feature Request/Idea:Code optimization suggestions #8771

Closed
noobyu6 opened this issue Jun 3, 2022 · 6 comments · Fixed by #8970
Closed

Feature Request/Idea:Code optimization suggestions #8771

noobyu6 opened this issue Jun 3, 2022 · 6 comments · Fixed by #8970
Milestone

Comments

@noobyu6
Copy link
Contributor

noobyu6 commented Jun 3, 2022

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
@pdurbin
Copy link
Member

pdurbin commented Jun 8, 2022

@noobyu6 are you using a tool to find these? If so, which one, please?

@noobyu6
Copy link
Contributor Author

noobyu6 commented Jun 9, 2022

@noobyu6 are you using a tool to find these? If so, which one, please?

I am a researcher from Fudan University and developing a tool working on this. And I hope my suggestion is helpful!

@noobyu6
Copy link
Contributor Author

noobyu6 commented Jun 14, 2022

Hello? So, are my suggestions helpful to your project?

@pdurbin
Copy link
Member

pdurbin commented Jun 14, 2022

Well, sort of? 😄

We always appreciate feedback on our code and "continue to increase the quality of the software" is one of our strategic goals that we list at https://www.iq.harvard.edu/roadmap-dataverse-project

However, every time we change code we review and re-test it, so it's not "free" in terms of time to make changes. As far as I know, all the Java classes you mentioned are working fine.

I'm not sure what to suggest. Some possible avenues:

I'd love to hear more of your thoughts! And thoughts from other developers, of course. 😄 What's the best way to clean up a code base?

@noobyu6
Copy link
Contributor Author

noobyu6 commented Jun 20, 2022

thanks for your reply, i have made a new 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 a pull request may close this issue.

2 participants