An exercise in refactoring

The other day at work I was implementing a new feature and found myself in a nice little, self-contained bit of code. I was adding the ability to parse a pair of query parameters from an HTTP request into an optional Period (a class used to represent a period of time in the application). After TDDing my functionality into place I reached a fully functional version but cringed every time I looked at it. I normally try to refactor during the TDDing but I just couldn’t see what to do until I had a bit more meat to work with. Once it was all in place I had enough to start chopping away at it.

Continue reading “An exercise in refactoring”

Toward a Modern Java

Modern Java? Isn’t that an oxymoron?

At XPDay this year Julian Kelsey and I presented a session entitled “Refactoring to Functional Style”. It seemed to be pretty well received and drew a lot more people to the room than, I think, either Julian or I ever expected. The theme of functional style in Java, and other common languages, continued throughout the conference. The ideas showed up in several other sessions as side topics and in one more session specifically about testing functional style programs that was led by Nat Pryce. There seemed to be a new way of working in Java that was starting to emerge.

Continue reading “Toward a Modern Java”

UX Test Your Code

So you think that new module of code that you just whipped up is just fine? You even wrote it with a pair or two! All of the names are the best that you could think of, the thesaurus is still smoking as it sits next to your keyboard. Control flow effortlessly flows from one expression to the next. Data dances in happiness for the structures that you have decided to use. This is not in any way going to be a maintenance problem!

Are you sure? Have you tested it? No, not that kind of testing. I trust that you have a good set of unit tests. Maybe even some nice acceptance tests that were looked at, or provided, by your stakeholder. No, what I mean is have you tested that it won’t be a maintenance problem?

Continue reading “UX Test Your Code”

Day 19: Carnon Down to Lands End and back to Penzance (57 miles)

Another great start to the day. I felt invigorated and had a lot more energy. I think part of this was that I knew that I didn’t have far to go and so I could push myself without having to worry about saving energy for the next day. Amazing how much more power you can put out if you don’t need to worry about sustaining it.

I decided to follow National Cycle Network Route 3 the rest of the way. It took be along some back ways, on a few dirt and gravel paths and by a couple things that I never would have otherwise seen. Cornwall used to be a big mining area and the route took me by some of the old mines. It even went along the side of an old mine tailings pond that was posted with “Warning: Toxic. Do not enter” signs.

At the End
At the End

By early afternoon I had reached Lands End! A much more bustling tourist attraction than John O’Groats, but not much really there. I signed the register in the hotel and got my picture taken at the sign. Then I sat down for a celebratory half pint (still had about 12 miles to ride back to Penzance).

One group that had just finished had done the entire thing in 8.5 days! They had taken a different route from me and completed it in just over 900 miles, but that still means that they were doing over 100 miles a day! The most amazing thing is that they had decided to do the trip just four weeks before starting and none of them were cyclists. Of course they were fully supported and carried nothing on the bikes, but that is still an incredible achievement.

Another couple a met was just passing through on their way to Cardiff. They were cycling along the coast and were carrying camping gear. They admitted to halving to get off and push the bikes up some of the hills. Cycling was nothing new to them, though. The wife had completed the North Sea Route over a series of years (a bit each year) and the husband had joined her for some of that.

After a bit I headed back to Penzance on the A roads, which were much more direct and less hilly than the NCN 3. At Penzance I had a few hours to kill before my train at 9:45 and so found a pub to sit and people watch.

A great end to a great trip.

Day 18: Lifton to Carnon Down (66 miles)

This day started a lot better. I felt rested. I felt energized. I felt like I could ride a lot further. Then I started climbing the hills again.

The day went a lot better with the motorists. Not as many close calls. Nobody stopping and reversing to yell at me. But I did notice that a lot more people were on the roads and the news in the morning was talking about people’s vacation plans.

That evening I discovered that, yes, all of England moves to Cornwall for the month of August. I tried several places in Truro, but they were all fully booked. I continued down the road and ended up being lured into Carnon Down because of a sign that promised accommodation. I didn’t find the accommodation, but by asking people where it was eventually got directed back up a road by a woman who said that there used to be a B&B up there, but she wasn’t sure if it was there anymore. I figured that I could at least check. Across the street from the possible B&B I asked some people who were on the street if the other house was still a B&B. They said that didn’t think it was, but that I can ask the woman because she was standing in the doorway at that point.

I said hello and asked if she was still running the B&B. She hasn’t for several years she said, and then she proceeded to help me find a place. She drew a map to find another place that was up the road a bit further and then she started calling the places she knew of! One place she called said that they were booked and another place the line was busy. I thanked her and headed to the place which she had drawn the map for. When I got there the owner was walking down the path and said that she had just gotten a call that a cyclist was on the way! And, yes, she did have a room.

Day 17: Taunton to Lifton (67 miles)

I felt a lot better in the morning. I had slept well and felt a lot fresher. The day played out as a blur until the hills started.

The narrow roads and increasing traffic from the beginning of the vacation season caused a lot more stress on the roads than normal. People started passing very aggressively and either getting very close to me or very close to oncoming traffic.

The hills during the day just got worse and worse. Each hill seemed steeper than the last and the extra weight on the bike became more and more obvious. I could tell that my legs were still feeling the effects of the dinner in Bristol by the amount of time they took to recover from the exertion after reaching the top. One hill was particularly steep and I was moving at about 3 mph. This caused the bike to wobble a bit and my pulling on the handlebars caused little swerves back and forth. I took to the middle of my lane to give myself more space, but never crossed over to the other lane (there were two tracks on this road). About halfway up the hill a car came up behind me and honked at me as he passed. Finding that a little shocking and very annoying I flipped the car the bird.

About thirty feet in front of me the car’s brake lights came on and then the reverse lights. I had angered the motorist. The best thing to do in this kind of situation is to not stop, just keep on trucking. Stopping in that kind of situation puts me in a disadvantageous position standing on a hill with an angry motorist and holding onto a heavy bike. At the same time stopping would send an aggressive signal to the motorist and possibly escalate the situation.

The motorist leaned out his window and shouted at me, “what the fuck is your problem?!” I replied with, “why did you honk at me?” That may not have been the best response, but I was tired and trying desperately to haul a heavy bike up a steep hill. His reply was, “you’re all over the fucking road!” All I could think was “duh!”, but decided to state the simple fact that “I’m climbing a fucking hill!” By this point I was passing him and nearing the top of the hill. He must have decided at this point that it wasn’t worth taunting a guy on a bike anymore and so he drove off.

The day ended with much nicer dealings with other humans. As I was looking for a place to stay I passed through a town that had a sign as I entered that stated that the town had inns and hotels. I couldn’t find any so I asked a woman who I saw on the street if she might know where they are. Should didn’t think there really were any in the town, but admitted that she hadn’t been living there long. As we were talking she noticed a couple walking by who she said had lived there a lot longer and called them over. They thought a while and considered having me go across the street to talk to the sister of a woman who runs a B&B that is back the way I had come. Eventually they decided that I should just carry on about four more miles to Lifton.

In Lifton I found the Lifton Hall Hotel where I enquired about a room. The man asked how much I was hoping to pay. I was a little surprised by this question and so gave him what I was truly hoping to pay (£40) and he said that was a lot lower than they would normally charge this time of year and so he would have to call someone. He made a call where I think the key words where “cyclist” and “£40” to which the answer was “yes.” Now, that was cool!

Day 16: Bristol to Taunton (54 miles)

The day didn’t start well. I had been awake since the early morning and skipped breakfast because of what the burrito the night before had done to my stomach. My legs felt like lead and every small hill seemed like a giant mountain.

After a few miles I decided that I might be able to handle a little food so I stopped at a little shop and picked up some Haribo and a Lucozade Sport. Simple sugars should be easy enough on the stomach. Outside I sat down and started to eat. The food made me feel a bit better.

As I was sitting there a family rode up and parked. The husband flipped over one of the bikes and started to work on it. I asked him if he needed any help and he said that he was just trying to clean the gears and chain a bit in the hopes of it making it shift a bit better. He didn’t seem to have the right equipment for cleaning so I pulled out my repair kit and handed him the rag.

We got to talking a bit and it turned out that he thought I was there for the little 2 mile ride around the town that was happening that day. When I told him what I was actually doing he said that made a lot more sense, as he had thought that I was showing off a bit with all of my gear and packed bike for a 2 mile ride!

That morning I had decided to make it a short day. So when I reached Taunton I started looking for a place to stay. After passing through the main part of the city I pulled out my phone and started searching the area for B&Bs or hotels. I found the Yalland Farm B&B nearby and pedaled on over.

This has to be one of the best B&Bs that I’ve stayed at. The owners had only been there for 5 weeks by that point and they were still learning how to run it, but everything was flawless. After putting my things away in my room and getting cleaned up I went outside to the patio and was served tea. Then sat down to a lovely conversation with the parents of the owners. After a while the husband came out and joined in. A little while later the wife came out. It was a nice relaxing ending for a short but tiring day.

Day 15: Aymestrey to Bristol (77 miles)

Over breakfast I had a great discussion with the owner of the hotel about what it is like being a programmer in London and how the world has been changing. Then I set out into a light drizzle that I hadn’t seen since Scotland. By midday the rain had disappeared, but the clouds remained.

Tintern Abbey
Tintern Abbey

When I reached Monmouth I stopped at a Lidl to restock my supplies and take a bit of a break. I locked up my bike next to another bike that also had panniers loaded for what looked like a little touring, so I was looking forward to a meeting with yet another tourer. Sure enough, after I got out of the store the other cyclist was standing at his bike. Turns out that he was training for an End to End (JOGLE, same as me) ride with a friend that they were planning on starting in just a few weeks. I tried to help him out with some tips from my experience, but I don’t think he really needed much help. It looked like he had everything well in hand.

When I reached Bristol it turned out that the Harbor Festival was going on. This would have been a great thing if I had a place to stay, but with the festival on it made it hard to find a place. I eventually found a nearby Premier Inn which was full, but the receptionist pointed me to the nearby Haymarket Premier Inn and even made a booking for me!

That night I ate a burrito at the My Burrito nearby. It tasted ok, but it did not agree with me. That night I didn’t sleep well. The next morning I ended up skipping breakfast.

Day 14: Tarporley to Aymestry (84 miles)

The day started simple enough as I left Tarporley. As it turns out though, after a few miles I realized that I had made a wrong turn and was following the wrong road. Instead of continuing down the A49 I had ended up on the A51. This wasn’t any big problem and I just taking a route a bit to the east of what I had expected.

At around midday I reached Shrewsbury and after seeing the sign stating that it was the birthplace of Charles Darwin, I decided to stay for a little longer than normal.  I followed the signs to the town center and found a nice little cafe to have some lunch. Along the way I saw lots of the Darwin themed things in town, such as the Darwin Shopping Centre that had a neat little awning with stained glass animals on it.

During lunch I got to talking with a couple who was also visiting the town after I had accidentally knocked over the table and broke the sugar cube dish while I was trying to lean my bike against the wall. We got to talking about the ride that I was doing and veered onto various other topics. The woman had done some cycling in Scotland when she was younger on a trip with a friend just after college.

After lunch I continued on my way and decided to start trying to find a place to stay when I reached Leintwardine. The only accommodation that I could find in the town looked like a very posh place and I wasn’t prepared to pay the price that they were asking.  Continuing down the road I stopped at what was advertised on the way into the town as the Compasses Hotel, but the owner said that they don’t have any rooms yet, but they hope to offer some in the near future. How is that for “aspirational” advertising?

In Aymestry I finally found a place that had space at a reasonable price. I showed up a little early and they hadn’t opened yet, but the owner was very nice and let me in anyway. He even placed my bike out of the way in the storage room by himself to help out! The attached restaurant made some of the best food that I had for the entire trip, too.