code review (i)
TRANSCRIPT
![Page 2: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/2.jpg)
Agenda
• Specific Case Pattern
• Decorate Pattern
• JAVA Optional and Generic
2/15
![Page 3: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/3.jpg)
YOU HATE the STATEMENT
3/15
You must lock the resource before opening …
![Page 4: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/4.jpg)
YOU KILL the
STATEMENT
4/15
Replace the null value by a do-nothing class
?
![Page 5: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/5.jpg)
Engineer is always
SINGLETON
5/15
Singleton
pattern
Singleton
pattern ?
![Page 6: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/6.jpg)
Coding is YOUR
life
6/15
Query the data with
3 optional arguments
1) filter
2) limit
3) offset
![Page 7: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/7.jpg)
YOU always work
for the
OLDER SPEC
7/15
WAIT...The order should be
1) limit
2) filter
3) offset ? ? ?
![Page 8: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/8.jpg)
8/15
![Page 9: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/9.jpg)
YOU have a DREAM
9/15
Query the data with
3 optional arguments
1) filter
2) limit
3) offset
Iterator<T> iter = …
iter = withFilter(iter);
iter = withLimit(iter);
iter = withOffset(iter);
return iter
WAIT...The order should be
1) limit
2) filter
3) offset
Iterator<T> iter = …
iter = withLimit(iter);
iter = withFilter(iter);
iter = withOffset(iter);
return iter
![Page 10: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/10.jpg)
10/15
![Page 11: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/11.jpg)
God could not be everywhere, and therefore
he made ENGINEER
11/15
WAIT...The order should be
1) limit
2) filter
3) offset
Query the data with
3 optional arguments
1) filter
2) limit
3) offset
![Page 12: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/12.jpg)
What can We do for this code (1/2)
12/15
![Page 13: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/13.jpg)
Redundant Statement
13/15
![Page 14: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/14.jpg)
What can We do for this code (2/2)
14/15
![Page 15: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/15.jpg)
Compiler is
your best
FRIEND
15/15
1. Unchecked type
2. The input argument is checked
java.lang.ClassCastException
(Dataset.Column cannot be cast to java.lang.Integer)
![Page 16: Code review (i)](https://reader030.vdocument.in/reader030/viewer/2022021423/58a307521a28abea508b5f0b/html5/thumbnails/16.jpg)
QA