Saturday, September 17, 2011

Classes of Cheese: Part 3 of Marcus and the Cursed Cheese

In objected oriented programming, a class defines the type of an object. In particular, an object's class defines the data and methods for that object. Alternately, the individual objects in a program can be viewed as specific instances of a class.

There were stacks of cheese everywhere. The tables were covered with half-filled containers of bleu cheese, brie, feta, mozzarella, and ricotta. Along the wall were large wheels of cheddar and blocks of swiss cheese. It smelled like a good cheese shop should. Marcus suddenly realized that he was incredibly hungry.

"Pardon the mess," started the foreman. "We are in the middle of packing today's soft-cheese shipment."

"There is so much cheese." the cheese minstrel breathed quietly. He was in awe. Never in his life had he been around so much cheese. And for a cheese minstrel, that is saying a lot.

"And over at that table, we are preparing for our shipment of the Swiss Cheese class." added the foreman while motioning to a table covered with blocks of swiss cheese. There had to have been at least fifty blocks of cheese on the table, stacked into neat piles.

"Class?" asked the cheese minstrel. Before the foreman even started to answer, the minstrel had his pad of paper out and was ready to record every detail.

"Yes. Those cheese blocks were all formed by our machines using the same recipe." answered the foreman. "We simply tell the machines: make a block of the swiss cheese class. The blocks have different attributes, such as size or number of holes, but they are all instantiations of swiss cheese."

The foreman walked over to the swiss cheese table. "Take these two blocks. We would describe both as Swiss. They are described by the same internal attributes, such as: weight, size, number of holes, sourness, etc. Granted, they actually have different values for those attributes depending on the specific block, but the attributes themselves are the same. And they have the same range of behaviors, such as EmitSmell."

"Emit smell?" asked the cheese minstrel without looking up from his notepad.

"Yes. Cheese does not have many actual behaviors, but it certainly does smell. Come have a sniff of our new triple-mold ultra-bleu cheese. I think that you will find it most interesting."

Marcus shook his head to try to clear away his current cheese-inspired trance. He had been staring at the massive quantities of bleu cheese for the better part of the conversation. His stomach was rumbling, but he had a mission. He needed to determine who had cursed his cheese. "Can you tell me what your visitor was looking for?" he asked.

"I am not sure. He just wandered around for a little while muttering to himself. He stopped and looked at some of the outgoing cheese shipments. But that was all. He never touched anything."

"Boxed or unboxed?" asked Marcus. "Was the cheese already packaged?"

"Uh..." the foreman seemed confused. "I think it was already in its boxes. Why?"

Marcus did not answer. His mind was racing. It was worse than he had thought.

To be continued in Part 4: Inheritance in Cheeses and Magic Spells...


See how the entire saga of the curse cheese began in Part 1: Data Validation, Marcus, and the Minstrel of Cheese

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.