What makes a good teaching article?

Recently, I had the chance to revisit an article I wrote on Code Project. I had never written what I would call a tutorial before that article and I haven’t written one since, but it did get me thinking on why I wrote it, what I knew and what I learned from it. I thought I would share that here.

I have been bouncing around Code Project for years, and had seen many articles, read many comments. I rarely took part, as I didn’t feel I had the ability to comment or I just didn’t want to write something critical of another persons work. There was a post by a member that the articles contained on the site were of an increasingly poor quality. And I agreed. But, I had never contributed, is that fair of me?

I set off down the path of writing an article on interfaces. I planned on creating a tutorial with solid, working examples that could be applied to every day development. What I learned from this experience is that it is incredibly difficult to put together a real-world example of a concept such as interfaces. You’ll see if you take a look at the article that I eventually ended up on little more than a text book example. Further to that, the comments after publishing show that I really didn’t understand as much about interfaces as I thought I did, or that I just couldn’t apply the knowledge to an example.

So, what makes it so difficult?

From a real-world example perspective, the issue is that we can never provide enough code (either through proprietary restraints or pure code scale). Our brains work better at breaking things down into small, bite-size pieces. And showing a more fleshed out example of interfaces without spanning multiple articles you’re not going to get to show everything about them.

Some authors would tackle a sample system, something that allows you to see how the pieces fit in in the overall system. So, I might have expanded the article by several installments, put in a WinForm app that had buttons and you can see the results as we go. The issue with this is that those sample apps suffer another issue, they are too focused on the subject and never show enough about how the pieces fit into a real world system. Sure, they might show some very solid examples of interface usage, but a real-world system is rarely a single component. The time necessary to write up the other code, without explaining it outweighs the benefits of the sample in the first place.

After editing my article, I received an extremely lengthy comment from another poster telling me that I perhaps should have waited, that I didn’t understand interfaces well enough. And to an extent, I do agree, I didn’t understand enough to be able to show absolute proficiency with the subject. But, I did choose to try and share what I did know and understand with others. I put together an article that laid out an example, that described the usage and I hope that it helped a couple of people. I appreciated the comments from this new poster, and I took the time to read the response and will hopefully produce a better, more rounded article next time I choose to post something.

 

Expressions

A huge part of my experimentation with Roast Potato is down to a recent fascination with the Expression. I’ve known since I started working in the .NET environment that it could do a lot with reflection. And through the development of a filtering system at work, I’ve found some of the extents to which that can be taken and seen some very impressive results.

With Roast Potato, my direction is more of an educational jaunt. If the library turns out to be useful in some capacity, then that’s awesome, I’d take a great sense of pride in knowing my work helped someone else along. But, I want to explore what can be done with expressions, how far I can understand them. This is the start of my ramblings on what I’m finding.

Once I had settled on a syntax for RP and spent a couple of nights fleshing out the Regex and other such fun, I got down to writing the tests, and I soon realized just how quickly some of the things I wanted to do could be achieved. For example;

var expressionValue = Expression.Constant( Convert.ChangeType( value, Property.Type ) );
 
return Expression.Lambda<Func<TEntity, bool>>( Expression.GreaterThan( Property, expressionValue ), Param );

The expression above does the following;

  • Convert the object value into the type of the property we’re requesting (Price[decimal])
  • Put that value into a constant value (just an Expression to wrap around the value and allow it to be constructed)
  • Returns a constructed lambda expression using the GreaterThanExpression and passing it both the property we wish to be greater than and the value we wish to be greater than.

Given the query;

"Price gt '21'"

The resulting Lambda expression;

x => x.Price  > 21

We can then apply that against a collection of objects and filter out a list, and that’s the starting point of the roast potato library. The actual code to go and parse the fact that it’s a GreaterThan is more complicated than the part that does the heavy lifting once we’re there.

I don’t want to try and go too deep. I barely have a working understanding on Expressions so far and I want to understand so much more. Also, I want to get a working Roast Potato sample up and running so I can show what it can do. Then, I can hopefully learn what it is to understand.

Tonight I uploaded the first version of Roast Potato Console, just a little sample app with some test data that you can type the query into and see it return the results. This app will eventually go away and I’m starting to believe that most of the need is for server side anyway, not a client/server side solution. But, I’ll leave that for another post and another day.

Open Source Contribution

I’ve always been a disorganized person, both in my general management of time and resources and in my projects. Professionally, I have the job I’m doing to focus on, and although my thoughts are scattered at times and I struggle to always convey them, I get the job done. And I hope, well.

Personally though, I lose focus quickly, I find my mind being drawn to other topics quickly. One minute I might want to write the next great sim game, the next I want to write blackjack. I lack focus and will-power. Sometimes, I give up because I get bored, sometimes because I realize that I’m not coming up with anything new. Mainly, I just lack the attention span required to develop all components of a project.

Recently, in the course of my professional life, I’ve been very focused on providing a way to query data in all manner of ways, quickly and efficiently. But as the development has gone on, I’ve realized there are so many ways in which we can query data now, that there aren’t enough hours in the day to provide the ultimate solution. We’re going to have to bend a little here, and rewrite a little there. This has given rise to a new personal challenge for me, and one I’m committed to staying the course on. Now, I know I can’t take what I did for my employer and just run with that, that wouldn’t be allowed, but what I can take is the lessons I learned throughout the course of the project and see if I can’t come up with something that will benefit others trying to tackle these issues, working on them from a totally different perspective.

In order to try and focus myself a little more, I’ve chosen to make what I do an open-source  project. This way, if I stop doing it, there’s a chance what I’ve done will help someone else. It might also attract the attention of other developers that want to contribute, and at that point I have a commitment to my peers and thus I have to be more professional in my behavior.

The project I have started has, as all new projects must, a quirky name. I called it, Roast Potato. What, really? Why?

Well, to Roast is to query. And Roast Potatoes are among my favorite foods. So, I’m going to Roast a Potato (a source of data) using a Recipe. I haven’t figured out all the other quirky things yet, and I’ve only just started. But, this one is interesting me more and more, and with each .NET project I start personally, I keep struggling at the same points, what is it to get data from the server controlled by the client.

What I’m trying to aim for is a way to represent the data on the server in a standard way, and be able to query that data from the client without having to worry about all the wiring in between.

Ever heard of OData?

Yes, I’ve heard of it, I’ve used it and I really like what I can do with it. And I’m not trying to replace or reinvent the wheel here. What I’m trying to do is make a reusable and simple client side interface for some pretty complex server side functionality that I can understand. I’m also thinking of how I put this into a PHP form as well as .NET, so I intend to write client code once and two versions of the server.

Anyway, I’ll see where it goes and if nothing else, there’s some code out there to show people how to extract an expression from a string.

Battlefield 3 – Best and worst FPS ever

Although game development and application development differ in many ways, the delivery of a product, to a standard is still the end game.

Since its release in late October, I’ve had both the distinct pleasure and single-most painful gaming experience with the video-game, Battlefield 3.

If next week, after having run a beta test on our software for a month, knowing there were issues in it, went on a massive marketing campaign and released the software, I’m pretty sure the company would be hurt badly. But, in the same, I think we would do everything we could to repair the damage done, and work hard to get the problems fixed.

When EA/Dice released the beta of Battlefield 3, I was quick to give it a try. I loved its predecessor and looked forward to playing it. Once downloaded, I accepted certain quirks, certain difficulties in the interface and the potential for bugs. Overall, it ran well and my machine was coping great. The feedback all seemed to be on the missing parts from Battlefield 2, dislike of the UI, but nothing particularly unmanageable.

1 month later, after the release of the product, the forums were full of “I can’t get this to play”, “keeps crashing”, and comment upon comment showing anger and frustration at having spent money on a game that (seemingly) nobody could play. To make matters worse, EA/Dice were boasting about being one of their biggest game launches ever, that they had sold so many copies of this game, and if you logged in you could see that. Reading through the issues, I find some people having success with port forwarding, that they are able to get consistency that way. Looking at the list of ports, this doesn’t sound like a good idea. I have to forward a whole bunch of ports (include 80 and 443) to my machine, I have to disable UPnP . I’m liking this less and less. To make matters worse, it doesn’t even make a difference.

Considering the number of people on the beta, I find it hard to understand how an issue such as this didn’t delay the game. They must have seen it. The beta showed some issues up, but nothing you couldn’t put down to test software. And, if they didn’t find something that means changes to net code were done after the beta code had been finalized that broke this in a really bad way.  Maybe EA noticed it and decided to release anyway,. because they had sunk millions into advertising. I’ve downloaded two huge updates for this game, and still nothing seems to work. I get one maybe two games in (if I stay in a session, that works), but if I log out, or try and do something else on MY computer, I have to restart the machine and try again. This is ridiculous.

Yesterday, I spent a great deal of time wandering around the system trying to find some logs that could show me what was failing. But, it seems that the web based system EA/Dice have chosen to use doesn’t really do logging. The game doesn’t seem to produce any logs, and I can’t find a way of enabling a debug mode to at least show me what’s failing. This suggests that EA has been completely useless at providing any sort of advanced troubleshooting and/or this feature doesn’t exist, because this information would make it out quick considering the number of issues out there. What makes it all the more frustrating is the error messages. They’re downright insulting. “An error occurred”, “You’ve been disconnected from EA”. WHY?!!

Assuming that the issue isn’t hardware based (I have a machine capable of taking the game on the highest specs), and it isn’t software based outside of EA/Dice software (drivers are all updated, Windows is updated). Where does the issue lie? Adding to the frustration is that the single player game is “online” too, and crashes within 2 minutes of playing. I didn’t buy the game for its single player campaign, so this doesn’t bother me too much, but I can’t get any satisfaction out of this product.

I can’t send the game back, you get a code that you activate when you try to install the game. Once that’s activated, it’s bound to your account. I can’t sell the game for the same reason. So, the normal consumer action of returning the product, not fit for purpose, is unavailable to me. I’ve seen logs of conversations with EA support, and they seem as useless as a chocolate fire-guard.

EA have taken some really horrible approaches to their software lately, all in the name of anti-piracy and whatever marketing goals they have. I don’t need everyone to see that I achieved the single worst score on a server, or that I couldn’t shoot my way out of a paper bag. I don’t need to share with someone that I managed to beat their time in a race. If Madden 2013 uses this sort of system, I know for sure I’m boycotting all things EA. Go back to making and publishing awesome video games, leave the online gaming arena to the guys at Valve. They would have made this far less painful for you EA, I have never had issues like this with games distributed through Steam.  I don’t care about all the fluff, I do care about being able to play a couple of hours of a game. Especially one that ranks as one of my favorites if I can get past the issues.

So, seriously, what am I going to write?

I’ve been a programmer for over a decade and in that time, I thought I had grown enough to call myself a developer. Over the past year, I’ve spent a great deal of time deep in code, from the database to the UI and back again. The arrival of a new colleague has forced me to go back through some of that code again, explain the decisions that got me to where I am and understand my own reasons for some design. It’s made me consider myself less of a developer overall, but given me a lot of enthusiasm for learning to become a developer instead of a guy that just sits down and puts code together, a programmer.

Going through this process has given me pause for thought. Have I studied and more importantly, learned as much as I had thought over the past decade? Or is there a lot of room for improvement?

Well, going through the code showed me that I wasn’t a complete amateur at this, I obviously got the idea. But when you find yourself defending or quantifying what you did, it’s a red flag. “Well, I chose to do this here because.. ” and “I know I missed the mark here”. If I knew, why didn’t I fix it? Well, it’s because I’ve not understood as much as I’ve read. Applying the principles taught over the years is a lot more difficult than it might appear. Nothing is perfect, no code is perfect and there’s always imperfection. But, applying principles new to my every day working practice such as test driven development, have already shown me holes in my code that I didn’t see (or chose to accept). So it’s time to learn more about these practices, adopt more modern methods and see if I can’t become a better developer from it.

What I’m going to start with here is writing down all the things I learn. Either explaining them, sharing code, sharing links or just dumping them in a page. I’m going to plan posts, rather than just writing on a whim, see if I can’t give structure to them.  And most importantly, I’m actually interested in what others have to add here.

That’s a rubbish title

I’m sure I’m not the only person to ever try and document what I’m trying to do. But, I’ve never tried it before. So, it’s new to me.

I’ve recently had the opportunity to start asking myself questions about the way I think about code, the way I do code and what’s right and what’s wrong in my methods. I’ve never worked in any agile or xp process. I’ve not studied domain driven design enough to be able to say, “well… here’s how I did it”.

I’ve been given the chance to learn more about this, start doing some unit testing, some real software development and I intend to write down what I learn.

I had to do something

So, a couple of months ago now, my blog was taken off-line by some malicious idiots looking to amuse themselves by destroying what others had written. Not that I wrote anything of substance or anything worth keeping for that matter. The point is that I wasn’t harming anybody, I wasn’t speaking out against anything, I wasn’t even writing anything interesting!

So, at the time I vowed not to use WordPress again, but here I am, back using WordPress. Why?

Well, I’ve finally decided I have something to write about, so I need a blog. I can’t spare the time to put my own software into use, and the alternatives to WordPress look pretty poor by comparison. So, we’ll see how this goes.