This is just an unscripted video (part of a series of videos) showing an example of how to work with objects and classes in Java. It is a very superficial example to give the novice an understanding of how to work with classes.
In this case, the value of isFlat is dependent on airPressure. The airPressure field is private, so we can only change it's value through inflate() and deflate(). However, if you updated only airPressure and not isFlat (or vice versa), you could end up with a ball that is flat but has air pressure, leading to a violation of consistency. Since calculating the value of this attribute is relatively uninvolved. While caching has its place, it's probably better to have an isFlat() method instead.
I think the ball example is a pretty good introduction into Java (and object oriented design in general), since it actaully forces some understanding of what you're doing into the exercise. I have one thing that'd I'd like to point out that don't particularly affect this example too much, but could lead to difficult to manage code in larger projects. Assuming one had a definition for isFlat (e.g., pressure is less than 1), it should be derived. (continued)
Did you really have to make an example of balls lol
7Qerido 3 weeks ago
..... ur name's Fabio? lmao!
bountikilla 3 months ago
the best way to think of it is that you're accessing a super class by creating an object
c0decub 5 months ago
Thanks for your video its really informative..
can you by change help me in my java course work pls?
Novice2star 10 months ago
Very nice video. At first I was impatient listening to you but then as I Iisten on, everything starts to make sense. Great technique.
scottwong426 1 year ago
In this case, the value of isFlat is dependent on airPressure. The airPressure field is private, so we can only change it's value through inflate() and deflate(). However, if you updated only airPressure and not isFlat (or vice versa), you could end up with a ball that is flat but has air pressure, leading to a violation of consistency. Since calculating the value of this attribute is relatively uninvolved. While caching has its place, it's probably better to have an isFlat() method instead.
ravingidiot 1 year ago
I think the ball example is a pretty good introduction into Java (and object oriented design in general), since it actaully forces some understanding of what you're doing into the exercise. I have one thing that'd I'd like to point out that don't particularly affect this example too much, but could lead to difficult to manage code in larger projects. Assuming one had a definition for isFlat (e.g., pressure is less than 1), it should be derived. (continued)
ravingidiot 1 year ago
Thanks very much for taking the time to make this tutorial. Having practical examples makes a world of difference!
The audio compression is a tad annoying, but the tutorial itself is quite helpful!
plapricot 1 year ago
Thanks dude! really helped me out! (:
iftekhar113 1 year ago
Thanks for this ( 4 ) parts ,
saleh873 1 year ago