In this Java lesson, we review the keywords "private" and "this". We continue talking about "instance fields" which are also called "properties" and "member variables". We will refactor the code to be much better than it was before because before we had a lot of redundant calculations. We did it the awful way to prove a point... that we can (if we wanted to) maintain values in a controlled fashion by using private instance fields with getters & setters. But, now let's do it the right way with Lazy Evaluation. Mr. Stride at NCHS does a quick demonstration of Lazy Evaluation in the Point class. He will eliminate an instance field for the distance to the origin and shows how calculating it on the fly is much cleaner code. Lazy Evaluation is what you'll want to do when evaluating Cell expressions in TextExcel (when that day comes).
0 Comments