12-03-2016, 11:22 PM
Soo I thought this may give you all a chuckle, especially the programming savvy though I moved the technical details to the end.
So our professor was being a braniack and demonstrating how his code example was super efficient.
*He is actually a genius*
In short he used a pattern called decorator, it acts similarly to an LinkedList.
So he drew a diagram on the board of about 8 objects and abbreviated the getData() as "getD" and used psuedocode for explaining purposes.
and was like
"OK class, we will start out here at the outermost object and we will work our way to the center. So the first thing we will do is getD."
*some snickering occurring behind me*
"then we will move further in and getD"
*I get it at this point and try and hide a smile*
"So, Alex what will we do here?"
*"getD, sir"*
"thats right we getD"
*at this point my friend jonathan behind me cracks up, trying not to burst out laughing he triest to wrap his face in his arms, this causes me to nearly loose it*
and through the next approximatly 5 objects the teacher pauses and repeats and "here again we getD"
*im almost in tears and the rest of the class is trying their best to maintain composure, every time the teacher says getD its like a slap in the face!*
It crosses my mind, in one class period we got more d than a group of gay guys doing a gay pubcrawl at a pride parade.
ugh it hurt soo bad, then my desk was freaking shakeing because johnathan was physically vibrating trying to prevent a outburst of laughing. The teacher had his back to us and I started to slip outa the room but I realized we had 2 objects left to getD, so I started drawing random crap on my paper and doing math in my head trying to distract myself.
AAANNYY way just thought you guys may get a smile outa our cs class getting soo much d![Wink Wink](https://gayspeak.com/images/smilies/wink.png)
//**********************************************boreing details
Each class inherits from an abstract item class then each class stores the next class in sequence as a field. IE
Item item; //much like Node node;
double value;
One thing they also share is a getData() method.
so when one class does this
public double getData(){
return this.item.getData()+this.value;}
all items effectively walk a list that delegates responsibility onto the next object
its super efficient because imagine a store with 10,000 items.
the cashier can scan something say (pencil) that value passes into a switch or something until pencil is found and retuns a numerical value based on cost.
if you purchase items p, and the store has some ammount of items i then the time complexity is O(p*i)
doing what the professor did is simply O(p) //much much less!
simply makeing an abstract class with default methods and fields each item in the store can inherit the item class and even though each item has its own class the code is really short since your useing extends.
//*****************************************end boreing details
So our professor was being a braniack and demonstrating how his code example was super efficient.
*He is actually a genius*
In short he used a pattern called decorator, it acts similarly to an LinkedList.
So he drew a diagram on the board of about 8 objects and abbreviated the getData() as "getD" and used psuedocode for explaining purposes.
and was like
"OK class, we will start out here at the outermost object and we will work our way to the center. So the first thing we will do is getD."
*some snickering occurring behind me*
"then we will move further in and getD"
*I get it at this point and try and hide a smile*
"So, Alex what will we do here?"
*"getD, sir"*
"thats right we getD"
*at this point my friend jonathan behind me cracks up, trying not to burst out laughing he triest to wrap his face in his arms, this causes me to nearly loose it*
and through the next approximatly 5 objects the teacher pauses and repeats and "here again we getD"
*im almost in tears and the rest of the class is trying their best to maintain composure, every time the teacher says getD its like a slap in the face!*
It crosses my mind, in one class period we got more d than a group of gay guys doing a gay pubcrawl at a pride parade.
ugh it hurt soo bad, then my desk was freaking shakeing because johnathan was physically vibrating trying to prevent a outburst of laughing. The teacher had his back to us and I started to slip outa the room but I realized we had 2 objects left to getD, so I started drawing random crap on my paper and doing math in my head trying to distract myself.
AAANNYY way just thought you guys may get a smile outa our cs class getting soo much d
![Wink Wink](https://gayspeak.com/images/smilies/wink.png)
//**********************************************boreing details
Each class inherits from an abstract item class then each class stores the next class in sequence as a field. IE
Item item; //much like Node node;
double value;
One thing they also share is a getData() method.
so when one class does this
public double getData(){
return this.item.getData()+this.value;}
all items effectively walk a list that delegates responsibility onto the next object
its super efficient because imagine a store with 10,000 items.
the cashier can scan something say (pencil) that value passes into a switch or something until pencil is found and retuns a numerical value based on cost.
if you purchase items p, and the store has some ammount of items i then the time complexity is O(p*i)
doing what the professor did is simply O(p) //much much less!
simply makeing an abstract class with default methods and fields each item in the store can inherit the item class and even though each item has its own class the code is really short since your useing extends.
//*****************************************end boreing details