343 reputation
122
bio website whitemagicsoftware.com
location Victoria, Canada
age 40
visits member for 3 years, 9 months
seen 2 days ago

http://whitemagicsoftware.com

Read my technical manual Indispensable, which covers Business Intelligence with JasperReports and R:

http://whitemagicsoftware.com/books/indispensable


Nov
3
accepted Approach to develop an inline editor for enumerated lists
Nov
3
answered Approach to develop an inline editor for enumerated lists
Jul
8
awarded  Nice Answer
Jul
8
awarded  Nice Question
Jun
22
awarded  Cleanup
Jun
16
awarded  Popular Question
Mar
19
comment Succinct Lazy Initialization Pattern
The Annotation Processing Tool might help here.
Mar
19
asked Succinct Lazy Initialization Pattern
Nov
29
revised Approach to develop an inline editor for enumerated lists
edited body
Nov
29
asked Approach to develop an inline editor for enumerated lists
Nov
29
awarded  Informed
Nov
14
accepted What are the disadvantages of self-encapsulation?
Nov
14
comment What are the disadvantages of self-encapsulation?
@BryanChen: Thank you. Fixed.
Nov
14
revised What are the disadvantages of self-encapsulation?
added 37 characters in body
Nov
13
revised What are the disadvantages of self-encapsulation?
added 5 characters in body
Nov
12
comment What are the disadvantages of self-encapsulation?
I disagree about making issues harder to debug. By consistently applying self-encapsulation, it makes the entire system easier to debug. Add a stack trace in the accessor to show exactly when the unexpected value was set and how. Combined with Aspect Oriented Programming, debugging the system becomes trivial. I cannot imagine a manager saying, "The system should crash for our users."
Nov
12
comment What are the disadvantages of self-encapsulation?
While developers must handle unexpected values, eliminating null pointer dereferences would help produce crash-free software (other flaws would still be present). You mention needing to handle uninitialized values, but self-encapsulation ensures all values are initialized (i.e., never null), which means that no extra code is required to handle the null (i.e., uninitialized) case.
Nov
12
comment What are the disadvantages of self-encapsulation?
The hypothesis is that using class-scoped variables directly results in code that crashes more often than using variables indirectly (and consistently) via accessor methods that force all uninitialized variables to be initialized immediately prior to use. In the example shown, calling setAttribute( null ) will cause the attribute's value to be re-initialized prior to use (e.g., makes a database call to find the current value).
Nov
12
comment What are the disadvantages of self-encapsulation?
+1. I neglected to mention that the createDefaultValue() method is used, lazily, to provide a valid non-null value -- this method abstracts how the value is initialized while allowing subclasses to override how the initial value is obtained. This provides reusability through the Open-Closed Principle.
Nov
12
asked What are the disadvantages of self-encapsulation?