(Also inconsistently referred to as Ky’s Guide to Starting Over 1.3 in future annotations and subsequent editions)
The following passages contain live code.
The author would like to state outright that all code contained herein is intellectual property of said author and cannot be used, duplicated, or forked without the author’s express consent and upon payment of a licensing fee of not less than 2 Deviled Eggs and 1 shiny button.
The author is not responsible for code that that does not match presented narrative, contains irresponsible amounts of monkey-patching, or is in varying states of readability/operability. The author encourages all readers to take the following examples with a healthy spoonful of maple syrup.
If it’s broke; try to fix it! Maybe the author put that in there as some kind of test? Yes, if the reader finds errors, they were intentional tests of ability. If the reader doesn’t find any errors, the author did a sterling job, or the reader wasn’t paying attention; choose based on preference.
A Necessary Diversion
I stood looking out at a barren cobblestone walk from the narrow window in my flat, the only such vantage available to me (the others had long since been lost behind piles of rusted bike chains and string-less guitars). The greedy fingers of frost that hugged the fringes of the thin plates of glass were slowly creeping away, off to find a more northern locale to continue their frigid inclemency no doubt. I found myself wondering, (aloud, if the indignant stomping from the old widow upstairs was any indication) when the wintry weather cleared, and the walks were largely free of snow piles and falling hunks of ice, how I could possibly come up with an excuse for not going to work. My boss had at this point been sympathetic to my worries about commuting in the height of winter’s unpleasantness, what with what happened to that old lady who got lost in that snowstorm a few years back on her way out to buy some Royal Canin. Didn’t thaw out until late June, and by the time she got back, her fourteen cats were quite irate. I didn’t want to risk anything of the sort and my boss understood that. But it would seem that even their patience had its limits; I had received several calls and three separate letters asking me to come back in since the weather was clearing up.
As I sipped my warm mug of ham juice and noted the conspicuous appearance of crabgrass through the remnants of snow on the verge, I decided it was time to get serious and start thinking about getting back to work.
It wasn’t so long ago that I had just helped my old friend Reginald prepare for his Ornithopter & Octopus Dressage competition; since then, I had been working through Launch School’s Object Oriented Programming class and not thinking about much else, aside from the cut-throat world of antique marble collecting. I was still recovering from losing an auction for a genuine, late 19th century Kuhnershutte Green Latticinio. In any case, I had received a card in the post from Reginald recently detailing his latest adventures with Olga.
“Olga out on a wing-walk in our latest thopter! Coastal waters of the Yucatan are splendid this time of year!”
With my work in OOP wrapping up now, and my remembrances of Reginald’s engineering ingenuity firmly in my mind, I decided it was time for a side project. It was time for me to build something!
Well, obviously, I am going to get back to studying eventually, I just need… to, uh… do this first.
My Kingdom for a Lazyboy
It was obvious that I needed to build something. But the question was what should I build? I looked at the letters from my boss strewn on the floor, the company letterhead staring up at me accusingly. The red light on my answering machine bleeped on unperturbed; it had long since gotten used to being ignored. I looked out through the receding frost at the driveway and the old j̶u̶n̶k̶e̶r̶s̶ classics in varying states of operability and consumption by rust.
Right, I needed to get to work; and the sooner the better. The tone of recent correspondences from the office had been gaining a tone that was more incommoded than it was patient, in a growth pattern that was more factorial than it was linear.
Then it struck me! It was looking me in the face all winter! The most obvious solution for all my needs was…
- to build a trebuchet to launch myself safely to work! With that in place I could soar to the company headquarters without a care in world, free from commuter’s dangers like slipping on the walk, or getting wet socks.
With my goal in mind, I took a look around the house and started finding from where I could source my materials. After all, it pays to be frugal, and I wouldn’t be caught dead launching from some prefab IKEA trebuchet. A brief search ensued, and soon enough I had identified the materials that I would need. In the apartment walls, I found a never-ending column of carpenter ants, diligently working to, as they told me, remove “all thozze extra bitzz” from the support framing. There was a considerable garage out back that was already collapsing, so nobody would mind if I pulled a few of the extra beams from it. I could get some rope from my next-door neighbor’s old fishing boat, which had been drydocked in his backyard even since he lost his leg in that terrible crabbing ordeal ten years prior. In the driveway were a few o̶l̶d̶,̶ ̶b̶r̶o̶k̶e̶n̶-̶d̶o̶w̶n̶ ̶ vintage, restoration-oriented cars I could scavenge parts from. Also, plenty of used floss lying about the bathroom and stuffed in the closets. Don’t judge me. You never know when you might need it and this shaped up to be one of those times, now didn’t it? And most important of all, the glimmering ruby of my Danish Parure Tiara, the lone Lazyboy sitting somewhat askew in the parlor. It was moth-eaten and smelled like dropped spoonfuls of Shalimar Takeaway with distinct notes of ferret, but I loved it. Yes, it was time to breathe some new life into my old friend and give it some new purpose.
I had all the materials I would need, so all that remained was figuring out how to piece it all together. I knew what my problem was: I needed to get to work, while avoiding the dangers of late winter/ early spring commutes. I also knew what my goal was: I needed to build a trebuchet that could launch a passenger to a destination. The issue now was how to piece it all together. So, naturally, I tried to think about the problem and my end goal procedurally. I took it step by step, considering everything that I would need to do from start to finish.
Clearly, this wasn’t just some Purple Martin’s birdhouse to be approached with a hammer, some nails, and go-getter attitude; no, this was going to take more forethought and planning. If only there was some way to approach this problem that could take a procedural nightmare and provide a reasoned, organized approach.
Wait, there is such an approach and what luck, I had just been studying about it! Object Oriented Design principles might be able to help me navigate out of this procedural Emyn Muil. After all, OOP is just a way to conceptualize a problem and construct a solution!
So, I sat down and thought: the first thing that might help is to abstract some of the details of my idea. I started by thinking about the problem in a basic way:
“The trebuchet will first be assembled. The frame will be assembled from wooden beams. Some salty boat rope will be used to attach the components. My old, musty armchair can be attached as a sling. A rusty, old car will act as the counterweight for the trebuchet with a rusty car axle serving as the main lever axle. The lever arm of the contraption will be pulled by a colony of carpenter ants secured with my old floss. When the trebuchet is armed, the ants will pull until the counterweight reaches a predetermined, maximum height. Then the trebuchet will fire.”
Using this idea as a basis, I then extracted the major nouns and verbs, as these would give me a solid basis for thinking about different objects and the collaborations between them.
This is what I narrowed in on:
Nouns: Trebuchet, Wooden Beam, Salty Boat Rope, Old Musty Armchair, Rusty Old Car, Rusty Car Axle, Colony of Carpenter Ants
Verbs: Assemble, Arm, Fire, Attach
With the complicated parts abstracted into units, it became much easier to reason about them:
At this point, I began to take down my thoughts in my trusty code editor, so could I track my notes and use them as a basis for future development and planning.
I spent the remains of the day in a fervor of action, marching about the grounds hacksaw in one hand, floss bits in the other, gathering the materials I calculated I would need. In all honesty, I thought the process would only take an hour, but as it turns out, persuading carpenter ants to come on for a non-contract labor job was even tougher than getting the floss tied about their middles. But when all was said and done, I had all my materials gathered up in a large pile in the small clearing out back.
I had every intention of grabbing a cold pint and calling it a day, but I soon found that the large pile of materials was still cumbersome and unwieldy. The carpenter ants were chewing on the beams already, and who knows how loose rope winds up coiled round a Vauxhall in a clove hitch, but there it was. I knew the next logical step was to separate these different objects so I wouldn’t have to worry about one interfering with another without my express intention! I separated the pile of materials and then updated my code, beginning to draw lines to separate out different materials and thinking about how they would need to interact.
This was well and good, but I couldn’t get to sleep with so many questions unanswered. I was thinking about how these objects could be defined, how they might interact with one another, so I fleshed out my notes with some more detail; adding a layer of basic functionality.
With that done, I decided to take a break for the night. The ants were getting restless in their mason jar and I too was in dire need of a Choco-tastic toaster pastry.
After dropping an old mahogany table leg in the jar and sidestepping several questions about carpenter ant labor laws, I decided to rest up for the night and get back to it at the crack of dawn! Now to settle down and unwind with an episode or two on Netflix and a nice early bedtime.
Building, and Rebuilding, and Rebuilding…
By 10:30 the next morning, I was hard at work with only the slightest internal acknowledgement that this project was bringing me closer to the office. I had the general structure of my plans in place, but I hadn’t logically put everything together; there were still parts of the process that needed a more definite description. There were processes that needed parameters, and elements that needed fleshing out. I let the ants out of their jar for their “Union Mandated Coordinator’s Meeting” and started improving the basic code that I had in place.
A few hours work and I was up and running with a functional program that simulated the entire trebuchet process. I had done a good deal of work. The entire trebuchet program was functional. The methods that were laid out for the trebuchet to assemble, arm, and fire were now all defined. I had added a module along with several other methods to enhance readability while running the program. I created a master cycle method that would handle the assembly, arming and firing all in one go, with different methods to display prompts that would facilitate this cycle. Just as I had separated my pile of materials outside in the lawn so they wouldn’t interact unless I intended for them to, I began the work of privatizing my classes and securing the different objects to prevent unintentional interactions.
With that done, I was feeling pretty good, and I had worked up a sizeable appetite. I sat down for a shared lunch among the carpenter ants and polished off several Peltier Glass Ribbon Lutz marbles as I ate a ham sandwich. But as the program I had built swirled around in the hazy hallways of my subconscious, I began to think of ways that it could be improved and rebuilt. For example, wouldn’t it make more sense to initialize the trebuchet with a hash of materials that had been gathered, so that I could check their status before assembling the thing? And maybe it would in fact be easier to have a separate pile of beams to use for constructing the frame? It would keep the main counterweight heavier (and thus increase the potential energy) if I pulled the axle from a different car during assembly, right? All these questions and other ideas for improvement twisted about in the back of mind until I could no longer ignore them. Improvements had to be made!
I spent the subsequent afternoon and evening hours rebuilding and testing, then rebuilding and testing again, then going back to undo some horrendous error I caused, then patching something, then realizing the patch was unnecessary if I fixed a different chunk of code. Several versions of the program came and went, until I had built a program that worked and felt functional enough to extrapolate to the real world.
Now, with my plans thought out objectively, and verified by a functional program that I felt would match the actual process quite well, I began building my trebuchet, following my code as a basis to create the transportation trebuchet.
Busily, I set to work taking the individual objects at my disposal and using them to create a much more intricate and dare-I-say-it, elegant construct. After several days of laboring (and tricking passersby into lifting heavy beams for me with tales of what delightful fun it was), I called my boss and told them to expect me at dawn the following day.
The assembly was complete, and a beautiful behemoth of maple and oak stood tall, soaking in the reddened sun of dusk, rope joints creaking as she swayed ever so slightly in the breeze. Yes, all the planning, all the struggle, the many dodgy interactions with carpenter ant union enforcers about paid sick time, it was all worth it.
That night I ran my program several times to verify that I had thought it all through and that the trebuchet would fire as expected. It was weighted correctly, it was facing south-southeast, and the carpenter ants were hitched according to union regulations.
With my preparations made, I set off the following morning.
Some say he’s still sailing through the sky to this day, endlessly soaring over the job that he will never arrive at, as punishment for defying Itineranturese, the god of woeful work commutes. Others say he did land and that there’s a small crater in the hedges about 10 meters left of the office building to prove it. The truth is, we may never know if he reached his destination or if he ever thought about how he was supposed to get back.
To be continued or not… We’ll see.
Until next time or not… We’ll see.