Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:23:04+00:00 2026-05-30T11:23:04+00:00

Dodgy – Write to static field from instance method This is the line it

  • 0

Dodgy – Write to static field from instance method

This is the line it is referring to:

record.setEarliestTradeDate(earliestTradeDate = value.earliestTradeDate);

Some more code:

Record record = getRecord(value.id);
private static Date earliestTradeDate = null;
public void setEarliestTradeDate(Date newValue) { earliestTradeDate = newValue; }

It is definitely not causing any sort of errors, but I would like to clear up the projects of any red-marked lines of code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:23:06+00:00Added an answer on May 30, 2026 at 11:23 am

    This is a hint that it is possible to change the static

    static Date earliestTradeDate
    

    in an instance method (i.e. not static)

    public void setEarliestTradeDate
    

    This is (or could be problematic) because all instances of your object can change the state of that variable.
    You can fix this by making the method static as well, so that the static variable will ony be changed in a static context. It seems to me, that this is the right approach here, because earliest Date is a fixed point somewhere in your code.

    public static void setEarliestTradeDate
    

    Or make this Date an instance variable:

    private Date earliestTradeDate
    

    This also could be a case for the singleton pattern.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having just written the title for this question I am aware of how dodgy
I am working on a simple email importer script. From what posts on this
I've got a PHP script which I'm running from a command line (windows) that
This is my code: (rather, the dodgy part thereof) if (window.XMLHttpRequest) {// code for
http://scienceoss.com/read-excel-files-from-python/comment-page-1/#comment-1051 From the above link, I used this utility to read an XLS file.
I am attempting to clean up some dodgy xml attributes with Regular expressions. My
What guidlines do you use when deciding whether to let a method dodge an
I saw this page growing in popularity among my social circles on Facebook, what
IDLE is being very dodgy as to when it will actually show an Auto-complete
I have some rather dodgy data I'm looking at, and I've been tasked with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.