Posts

As part of my endeavour to write this year, I set myself a challenge of reading 52 books. However, as of week 13, I’ve only managed to polish off 8 books so far! I’m really falling a bit behind the curve. However, inspiration struck whilst out watching Ready Player One with some friends at the weekend. As with many a movie, there are some drastic changes from the excellent Ernest Cline novel, but one that hit me on a personal level was at the end of the movie.

SPOILERS BELOW

After successfully winning the egg hunt, Wade gains full control of the Oasis, and makes an executive decision for the betterment of human kind: Shutting down the Oasis for 2 days a week, on Tuesday and Thursday.

For me, this seemed like a great idea. Imagine all the things you could accomplish if you weren’t hanging out in the virtual world for 2 days a week? Well, back here in the real “real” world, and I am putting myself onto a similar regime, aptly named:

No TV Tuesday!

From now on, I’m going to not watch a single minute of TV on Tuesdays. Instead, I’ll crack on with something more productive with my evening:

Reading

Writing

DIY (cough, not likely)

After completing the first night of this, I’m happy to report I succeeded, and managed to read a good chunk of a novel in the process.

If I manage to keep to No TV Tuesday for a few weeks, I might consider extending it to the full Ready Player One level of No TV Tuesday and Thursday!

The first golden leaves had begun to fall when Casper first experienced his curious curse. It had been weeks since he last left the area, living, working, shopping, and socialising all in a 4 block radius from his basement apartment. He’d been working just one block away at a small business operating out of a couple of apartments for the previous few years. It wasn’t the nicest of offices, but he loved working there. His walk to and from work passing a small row of shops, restaurants and bars. There was a doctors surgery in the building next to his office, and a pharmacy and dentist opposite his apartment. He really did want for nothing. So there was rarely a reason to actually leave the area. The occasional shopping trip down town, a party, or business trip out of town might claw him away, but failing that, here he could be found.

It was, with a chilling start, that he first discovered his prison. He’d been invited to a party at a friends house in down town, and was making his way there on foot. Walking along the small roads, filled with the ubiquitous two story terraced housing, he turned down an alley way short cut and found himself somewhere else. He came to a crashing stall. He turned and the alley way was gone. Rather than coming out on the outskirts of down town, he found himself standing outside his own apartment. How had he gotten here? As the hairs on his neck stood up, he started walking back towards the party, trying to convince himself that he had imagined it all.

When he reached the alley way he paused. Looking deep into the opening, the dark shadows daring him to turn back. His fists tightened as he took a deep breath and stepped into the abyss. With each step the darkness closed in, his heart rate thundered, his breathing deepened, and his fear rose. With a final, staggering step he fell through the exit and stumbled, landing on all fours. He stayed there for some time, unwilling to raise his head to see where he was. Too scared to face what might be. Too concerned it might have happened again.

After a time, minutes or hours he could never say, he summoned his courage. He closed his eyes and climbed to his feet. Counting silently to three, lips moving, but no sound escaping, he slowly opened his eyes and stared, dumbfounded at his own apartment. He had lost his mind. He couldn’t believe what he was seeing. Again and again, he raced through the alley way only to find himself back home. He tried different routes, hoping the alley way was the cause of his troubles. He skipped out the short cut, simply following the roads, even taking the long way around. It made no difference. Whenever he got to more than 4 blocks from his house he would find himself, inexplicably, back outside his small basement apartment. Eventually, exhausted, defeated, he gave in and descended the small flight of stairs and entered his apartment. Lying down in his bed he stared upwards at the ceiling for hours, before sleep finally took him.

The next day he awoke in a dazed state, convinced he had had the most unfathomable dream. He showered, dressed, and headed out for work, paying deeper attention to the rich world around him that he had ever before. Watching the people, some neighbours, some total strangers, as they left their homes to head out on their day. The parents with their push chairs, walking two abreast down the small pavements, causing others to quickly jump in and out of the road, narrowly dodging traffic. The students, in their multitudes, racing to the bus stops to head off to university. The dogs tied up outside the shops, patiently waiting for their master, or yapping at every passer-by.

After work he headed directly home, resisting the temptation to try to leave the area again. Deep into the night, still unable to sleep, his resolve to remain gave way. He flung his door open and fled his home. The door left swinging in the wind behind him, he raced directly down his road. Sweat started to form as he pushed himself onward. Never letting up the pace, he came flying up towards the 4 block limit from the previous night and, screaming with all his might, crashed on through directly back to his apartment. He collapsed, tears streaming down his face as he contemplated his new world reality.

Over the coming weeks he attempted to leave the area, but never with any success. He contemplated telling someone. Friends, family, colleagues, the police, his doctor. But what would they think? They’d think he was crazy. They’d probably be right, after all, he himself thought he was crazy. Come spring he had given up trying to leave the area, and come summer he had finally adjusted to his closed off life. He made excuses for parties, and instead hosted friends at his place. He dodged invites to meet down town and relocated to the local alternatives whenever possible. He managed to change his meetings to on-line sessions rather than site visits, or convinced a colleague to take his place when this wasn’t possible. Nobody seemed to notice that he never left the area, but then why should they? They had their own lives to worry about. Their own problems. Regardless, he was adapting well.

By the time summer gave way to autumn, he had almost forgotten about his little 4 block prison. Content in the fact that he would never again need to leave his cell. Making his way to work, the leaves were starting to fall again, and he felt totally at peace. When he entered the office, there was an excited buzz in the atmosphere. People were smiling and chatting. Business had been good, maybe we’d won another big client, he thought to himself. “Hey, Casper, have you heard the news?” a colleague shouted as he took his seat, “the company have bought a new office. As of tomorrow, we finally get to work with the big boys, down town!”

The rising sun peers through the clouds. Thin beams of yellow light kissing the leaves, the grass, the road. Their warmth breathes life into a monochrome world. Grey shadows give way to golden green. A silver mist rises, reaching with fingers of moisture, stretching, grasping for the clouds above. The mist swirls, waves of water pushed aside by a rhythmic pacing. Flashes of colour come trotting across the sea of green. Each impact throwing a shower of morning dew into the air. Rainbows form and fade in an fraction of a second. Forever following the galloping colours before them. Birds sing, the clouds separate and the mist burns away. The flashy stampede continues on. Some remain for hours, others barely minutes, some go slow, others are a blur. All are the same. One foot then the other, one step at a time. Thoughts of work and life are left behind. It’s just them and the fields. Them and the park. Them and their vibrant running shoes. Starting the day off right.

Looking out. Longing. Thinking. Not knowing what it was that captured you, but knowing that something most definitely had. The ocean beat against the rocks. White waves cresting and crashing across the cliffs. The sand beneath you as golden as autumn leaves at sunset, as soft as winters first snow and as warm and comforting as a lovers touch. The wind’s constant kiss was ever present. It’s force threatening, but never aggressive, never personal. Yet it was all yours. A universe encased. No nagging interruptions, no drains upon your time. Just the constant thrust of water against land, of air against rock. It draws you in, pulling you from life, to install within you a rebirth. On the edge of the world, near the end of the map, you find what you never knew was lost – you find yourself.

National Novel Writers Month is upon us once again, and I am going to join it for the first time. Been playing around with writing natural language for humans rather then code for computers for a while now, but never managed to gather much momentum with it. Well starting tomorrow, that is going to change. I will have 1 month to write a 50,000 word novel. Easy! haha! Only 1,667 words EVERY day!! Wish me luck.

As with many software companies that have been around since before the browser wars, web 2.0 and our current age of new MVC frameworks being launched every couple of days, we have “legacy” code. Lots of it. The vast majority of our legacy code is written in a language called Delphi, and we still perform tweaks and maintenance on it every day.

10 years ago when we started producing new systems using the Microsoft .Net Framework. These newer systems are written in C# and take advantage of all the benefits a modern language has to offer with the added ability of having access to our 30 years so of legacy code compiled as .Net DLLs. The down side of this is the added baggage that Delphi.Net comes with. Even tiny little applications that we want to use a snippet of legacy code with required 20 or so additional DLLs to be dragged in so that it works.

To remove this bloat from our smaller applications, we need to duplicate some of our legacy library directly in CSharp. The catch being, we need to keep the two libraries in sync. We therefore need to automate the library generations as much as possible, allowing us to regenerate our classes whenever they are changed in our Delphi library. This is where the Reflection features of the .Net Framework become our new best friend.

Reflection in .Net provides us with libraries run-time objects that describe the classes that are referenced at run time.

The simplest example of reflection is the typeof function:

Type typeString =typeof(System.String);

Type typeString = typeof(System.String);

The returned Type object will expose the constructors, properties, methods and fields of the class String. For example:

In each case above, we can investigate these “info” objects to discover more about that aspect of the class. For instance, using a PropertyInfo, we can determine it’s name, return type, it’s get and set methods, whether it is public, private, static, read only etc. We can also use an instance of the class in conjunction with an info object to execute a function, get a value of a property etc.

Performing this analysis on our Delphi.Net library in conjunction with some code to create plain text files is allowing us to generate our own CSharp versions of many of our legacy Delphi objects. Sometimes we are generating entire classes, especially when there is minimal business logic with in the class, and sometimes just interfaces to be used to manually implement the CSharp version. It’s proving invaluable to us, and giving us a real opportunity to migrate our library without double maintenance.

I will post a more detailed example of digging in to types using reflection soon, but have a play and have a think about how else you could use reflection yourself.

Hello all. I am Mike Sothern, a full time software engineer living in beautiful Norwich, Norfolk in the UK. At my day job, I’ve been using C# for about 10 years, pretty much since the start of .NET 2.0.

During that time I have worked on a multitude of projects, including dragging legacy systems across from older languages into the .NET world. I’ve decided to start sharing some of my experience with the C# language and .NET Framework with a wider audience that the 10 person team of developers in my day job. To this blog I will add stories of my experiences and short tutorials and hints for how to make the most out of the language features.

So if you are reading this, and you are interested in learning more about C#, then you are in the right place, and I extend you a warm welcome.