Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'dirty-flag' / 'dirty-values' mean?

Tags:

I see some variables named 'dirty' in some source code at work and some other code. What does it mean? What is a dirty flag?

like image 497
piotrek Avatar asked Nov 21 '12 22:11

piotrek


2 Answers

Generally, dirty flags are used to indicate that some data has changed and needs to eventually be written to some external destination. It isn't written immediate because adjacent data may also get changed and writing bulk of data is generally more efficient than writing individual values.

like image 193
Dietmar Kühl Avatar answered Oct 30 '22 12:10

Dietmar Kühl


There's a deeper issue here - rather than "What does 'dirty mean?" in the context of code, I think we should really be asking - is 'dirty' an appropriate term for what is generally intended.

'Dirty' is potentially confusing and misleading. It will suggest to many new programmers corrupt or erroneous form data. The work 'dirty' implies that something is wrong and that the data needs to be purged or removed. Something dirty is, after all undesirable, unclean and unpleasant.

If we mean 'the form has been touched' or 'the form has been amended but the changes haven't yet been written to the server', then why not 'touched' or 'writePending' rather than 'dirty'?

That I think, is a question the programming community needs to address.

like image 43
Adrian NH Avatar answered Oct 30 '22 12:10

Adrian NH