Wednesday, 16 October 2013

Game #002 - Your Interplanetary Age

Game #002 on Github

My second game is another little tech demo which asks your age and returns its equivalent on every planet. Yes, another ground breaking show of technology!

I quite enjoyed make the interplanetary age calculator. This was mainly due to the challenges I encountered whilst coding.

Feature Creep


As someone in the IT (I am a software tester) I am very familiar with feature creep. The phrases "Couldn't we just" and "It would be nice if" are punishable offences around me!  I started #002 with the idea to ask the user their age, and break it down to months, days, minutes. It's a simple one, and a small step up from #001. Then I thought "Wouldn't it be nice if I finished with the user's age on Mars?" Yep, feature creep almost before I had started to code. A bit of searching later, I found a site with Your Age on Other Worlds. And the wish to write a python script which gives you your age on all the planets in the solar system was born. First I put together a table to help me with the different revolution periods of each planet. This formed the basis of my calculations further down the programme.

Planet Rotation Period (Earth days) Revolution Period (Earth years/days)
Mercury
58.6 days
87.97 days
Venus
243 days
224.7
Earth
1 day
365.25 days
Mars
1.03 days
1.88 years
Jupiter
0.41 days
11.86 years
Saturn
0.45 days
29.46 years
Uranus
0.72 days
84.01 years
Neptune
0.67 days
164.79 years
Pluto
6.38 days
248.59 years

The Int to Str, Str to Int Switcheroo 


When I started coding, I asked the person their age and updated a variable, put that variable into an equation, and print the answer. Simple. For a newbie like me, it took a little bit of research to find out why my code kept on failing. It was great fun. It turns out that the input command produced a string, which wouldn't play well with my equation. The solution was to take the user input and turn it into an integer. This meant that the equation worked.
The next problem encountered was that the print statement wouldn't work because the print command doesn't work with integers. Having researched the need to change the user's input to an integer, it was relatively quick to realise what needed to be done. The result was the following flow of code:

 print("What is your age?")age = int(input(">>> "))  
 mars_age_years = age / 1.88  
 print("You are " + str(mercury_age_years) + "Mercury years old")  

This bit of code would essentially calculate and print a user's age on Mars

Round, Float, Decimal - Who knows!?


If the code above is run the result is that you age is likely to be have a lot of numbers after the decimal point (eg. 5.319148936170213 if you input an age of 10). This doesn't scan as easily as having an  age to two decimal points. This is where the majority of my research came in.
I recall in java it is easy to restrict to a number of decimal points by wrapping your equation/result in float. In python there are three options, all with different foibles of their own. I won't go into them here as I don't entirely understand what the difference is at this point in my learning.
After a decent bit of research, I found that rounding the age to two decimal points produced the answer I wanted. So this:
mars_age_years =  age / 1.88
became this:
mars_age_years = round(age / 1.88 ,2)
I now had a working script I could apply to all the revolutionary cycles of all the planets.

Github Learnings


Part of the fun of this project is putting the code out there for all to see. Like many people I use Github. I have the windows client installed, and it is very easy to push everything to the cloud for all to see. I am researching whether there is an online python interpreter so the scripts can be run without the need to have python on the machine.
I had just finished the game and was attempting to put the final version up on Github when I inadvertently rolled back on my machine. Being new to it all, I attempted to revert to the version online, but because there was now a disconnect between local and git, I was getting an error. It took me two and a half hours to sort out what would have taken someone with the knowledge five minutes to do! I really need to be a little more careful with how I roll back in future.

Game #002 Conclusion


If you have taken a look at the script in full, you will note that everything is still very procedural. There are no functions defined, for example. This is ripe for a revisit further down the line to refactor just about every line of code to make it easier to read and maintain.
Another thing that needs to change is that the user input is incredibly brittle, and not very interesting. If you put 0 in, the programme crashes. If you put a decimal in, the programme will crash. A loop needs to be added to handle these two things.
And what about interplanetary days?! The site I found during my initial design and research calculates the user's age in days as well. This is particularly interesting as each planet's rotation period is vastly different. So, this would definitely be a good addition to the whole programme.

Watch this space.

Wednesday, 9 October 2013

Game #001: Greeting

Github

Remember, my posts are like buses. You wait 10 months for one, then two come along straight away!

I have uploaded my first game. As I said in my first post, many of these will probably be a demo of something, rather than a full-on game. And this is no exception.

Greeting.py is a script which will ask you your name and then greet you. It's such a small script, I can post it in its entirety.


print ("Hi! What is your name? ")
name = input(">>> ")

print ("Welome " + name + "! I hope you enjoy your time browsing the 100 Games project.") 

The main feature of this script is to get the user's input. For games to be interactive, they require input of some kind from the user.
Obtaining the user's input is cunningly done via the input command. Whatever the user types in will be assigned to the variable name for use in the next line, the welcome statement.

Ways to enhance this script may be to only accept characters A-Z, filter out swear words using a dictionary, limit the number of characters a user can input. The list is endless! I will probably want to use some of the above ideas in later games when I interact with users in more complicated games.

P.S. I used the standard highlight function of blogger to make the code look code-y. I realise it looks a bit pants right now. Hopefully I can find a way to style the code snippets better in the future.
[Edit] Found it! Code highlighted

Tags for google+: #Python #100Games #Game

The 100 Games Project

Well, it looks like my idea about blogging more didn't really take off. 10 months on from my last post and here I am with the second article of 2013. Let’s see where we go from here.

100 Games Project

The title of this blog is the 100 Games Project. It is something I am trying which will hopefully help me to learn programming in a fun and interesting way.

Last week I noticed a tweet by Z. A. Shaw, who wrote "Learn Python the Hard Way", mentioning Jennifer Dewalt had finished her 180 Websites in 180 Days project. I remembered hearing about this a while back (probably from Shaw himself), and went to take a look. For the past week I have been reading Jennifer's blog, following the journey from her first website onwards. I was impressed by how she took an idea, and then used Stack Overflow, Google, and anything else to work out how to complete the idea. This lead to was Jennifer encountering more advanced technology (than HTML and CSS) such as jQuery and javascript a lot sooner than in most book lead courses on web development.
Reading the blog got me thinking about my own attempts to learn programming and how often I have got to a point in a course and then given up, got bored, or distracted by another language (where I have usually repeated the same process). The 100 Games Project aims to take Jennifer’s process of using ideas to direct learning to help me with my studies in learning to code.

I am currently learning Python through Udacity's Introduction to Computer Science course. So far I have really enjoyed the show a little, test a little way of presenting the language. Plus the idea of building a web crawler is appealing. I know, however, that if I don't do other things with my knowledge, it won't bed in and I will end up getting to a point where I struggle, get bored, and then stop. The 100 Games Project should go some way to keeping me interested, and bed the knowledge in.

Why 100 Games? 

100 games is quite a lot of games, for sure. I expect a lot of them will probably be more of a tech demo than an actual game. Other games will probably be incremental versions of past games. Even so, I will try and do something new (for me at least) with each game. If I revisit the majority of an old game, it will be to significantly change what was originally coded.
In the same way that Jennifer did, I will also blog a little bit about each game, and uploaded everything to github. That way there is a record
of each game, and other people can take them and play (with) them as well. It will also serve as a reminder of where I started and where I got to should I ever complete the project!

I realise I have now rambled on for quite long enough. If you have read this far, well done. Other posts will definitely not be as long. This I promise.

Friday, 4 January 2013

Testing: What Will 2013 Bring?



I don't make New Year's resolutions. I tried to once and got a stressed and disappointed when I didn't achieve any of them. I think failing at New Year's resolutions is a common occurrence, particularly with the "lose x kg in weight", "exercise y times per week", or "cut z out for a month" ones. There's probably been a study on it and everything! 

So, I don't make resolutions. 

What I do make is a list of things I would like to do in the coming year. It could be mistaken for a list of resolutions, but it's not. It's not, I tell you!!!

 What is on my list of resolu things to do this year? Here goes...

Blog More about Testing

I am a software tester, test manager, consultant, networker, social media user, blog reader, and uTester. I get a lot of exposure to testing, both in practical and in theoretical terms. I often find myself coming up with little tips, tricks, and ideas that make me think "I should blog about that!". And then I don't. So, the first item for me this year is to blog more often. I am not going to go silly by blogging every day! That would lead me to not blogging at all (the old failed resolution pressure again)! I am going to aim for once per month and see where that gets me. 

Learn Enough Coding to Develop Something

I have spent the past few months learning Selenium, and have really enjoyed it. I have been using resources by Alan Richardson which are excellent. The flavour of Selenium taught by Alan uses junit. I get along fairly well with Selenium-RC and Webdriver using junit, but that is mainly just running tests.
What I want to do is actually make something in code! I have a few ideas, but do not have the coding skill to get them to point of going public just yet. This year I want to put at least one item which I made from scratch out there for people to look at, use, refactor, whatever. I already have a little text adventure on github which was written in python. One idea would be to take that and write it in java. This isn't difficult. I think I could handle that already. What I would do beyond that is extend the number of rooms, add a little ASCII art, and a few other bits and bobs. It will never be Zork, but it will be a way for me to work through the odd coding problem on my own. 

Present to my Peers

I spent some of 2012 talking to some of my testing contacts about talking at a networking event, or a conference. The ideas for talks that I have were well met and I have been gently encouraged to put a talk together. When I say gently gently encouraged, I mean "Stop dicking about and get a talk together!" is gently encouraged. This is one item on the list I feel I may actually complete. I have already got the skeleton of a talk. I now need to target a meetup to give me that final push. Watch this space!

Learn a New Testing Skill

This one is a bit vague, but is on the list nonetheless. There are a few areas of testing I would like to explore more, but always make excuses for not doing so. The two main ones that come to mind are performance and security testing. One of the specialities of my company, The Test People, is performance management. I was not hired to be a performance tester and so have had little exposure to the tools we use. Since I usually don't have cause to conduct any performance testing or similar, the way to use the software has been largely forgotten.
As or security testing, I just want to have a play around. I have no wish to become a security specialist, but I definitely have an interest in the field. It is just a case of making time to take a look at tutorials that are available, and see where they take me.

Contribute More to the Testing Industry

And finally the most general item for the list,  contribute more to the testing industry. One could argue that all of the above can be summed up by this point. But then you haven't seen me present or code!
What I actually mean by this point is that I will comment on other tester's blogs more often, put more questions and answers on SQA Stack Exchange (an excellent resource by the way), and maybe keep an eye on the Software Testing Club forums a bit more. That kind of thing.
My reason for this is simple, if you put a balanced well thought out comment on someone else's blog, you open a conversation or debate. Through the replies, you will learn more, and perhaps help others to learn as well.
By asking questions on places like SQA Stack Exchange, one has to think of the correct way to phrase the question, lest ye be marked down! The act of doing this usually sets me on the way to solving my issue. Instead of continuing to plug away at my solution, I am going to also ask on SQA Stack Exchange as that will help me to find other solutions, as well as help others when they encounter the same problems as me. 

And that's it. Five items. That should be doable right? Right!? I tried to do much the same last year, including writing a similar blog post to this one. I didn't manage to post my entry but did manage to complete a couple of the items, the most important of which was learning an automation framework. I hope to build on that this year.

Have a fantastic and prosperous 2013, dear reader. Let's see where this adventure takes us.

Friday, 20 July 2012

Testing: Editing Tests In-running with Microsoft Test Manager


A couple of weeks ago one of my colleagues here asked if it possible to edit test scripts while you are running them in Microsoft Test Manager. I didn't know, and a quick bit of google-foo resulted in nothing conclusive. So, I reached out to the testing community through the fairly new and excellent SQA Stack Exchange.

Here is my original question:
http://sqa.stackexchange.com/questions/3411/is-there-a-patch-in-microsoft-test-manager-to-allow-for-editing-tests-while-runn


Although the answer given didn't didn't deal with my issue on MTM 2010, it did set me on the right path.

So, can you edit a test case while running it? The answer is, sort of.
You can't add a step into the test you are currently running, but you can edit the original test case so future runs are correct. Below is an explanation on how to do this.


http://blogs.msdn.com/b/gautamg/archive/2010/12/11/faq-editing-test-case-while-using-test-runner.aspx

I tried to find out if MTM 2012 was going to have such a useful feature, but I have not been able to find a definitive answer. Most of my searching seems to lead back to Microsoft telling us how good MTM 2012 will be for exploratory testing.
Hmmm..
Unless they have done a complete ground-up redesign of the interface, I do not think Microsoft Test Manager 2012 will be the right tool for that job.


I will cover that in another post. 

Monday, 9 July 2012

Testing: Some Thoughts on Microsoft Test Manager


It was about two years ago when I was first introduced to Microsoft Test Manager *(MTM). It worked quite well for us; we were a completely .net environment so the running tests and pushing bugs through to the developer through TFS workflow was fairly smooth. I remember thinking at the time that once the software was out in the wild for a year or so Microsoft should send out a service pack to fix the obvious bugs, correct the UI issues, and hopefully add reporting tools as standard.

Fast forward to now. I am again in a .net environment. I am again using MTM as the tool for running tests and reporting bugs.During the interim I have been exposed to many different tools, most of which, in their way, out class MTM:
For record and playback of test steps I use Selenium IDE, or iMacros
For progress reporting I can format them natively in the application or export a CSV from just about any test tool (Testlink, Testrail, Jira, Bugzilla) and manipulate in Excel.
And for reporting of bugs, there are multiple pieces of software, Bugzilla, Jira, TFS to name a few.

You can imagine my disappointment to see that MTM had not moved an inch from where I last left it. The software is still buggy, chews up resources, crashes at the slightest misuse, and has a UI that was designed by a, well, by something that has never used software before. It is so frustrating as to almost make you weep. I have tried to fathom Microsoft's strategy with MTM. It isn't cheap, so companies invest a lot to get it set up and integrated. It seems like Microsoft are willing to let the tool mothball whilst still receiving license money from the few companies unfortunate enough to have this as their main testing, bug reporting, and progress reporting tool. Yet it fulfills none of those functions to a satisfactory level!
I can only hope that with the new generation of software versions coming out (Windows 8, Office 2012, etc.) there is a major upgrade to MTM that makes it usable.

* I started inserting links after I wrote the article. Attempting to find MTM 2010 on the Microsoft site is almost impossible. Perhaps they realised what a dog it was and hid it in the cupboard under the stairs.



[End Note] At the beginning of 2012 I was going to start up (yet) another blog about my life as a tester. I haven't done that yet, so I will be posting here for a while until I get off my lazy arse and actually set up the bloody thing!

Saturday, 18 February 2012

Welcome Visitors from Estherderby.com

With my renewed attempt to blog often has come the inevitable use to the statistics part of the blogger dashboard to see if you, dear reader, are taking a look at these ramblings I put out.

The statistics for this site aren't mind blowing, but I do find it fun seeing where people come from, and what they searched for to get here. It was while looking at these stats I noticed that a large number of referrals are coming from http://www.estherderby.com.

I have gone to the site, and searched for this blog, my name, and anything else I can think of which would tie my blog to the site. I have come up with nothing! So, if you have come here from Estherderby, please drop me a note and say hi. Also, please let me know what is bringing you here, even if it is an instruction to look at this site as an example of how not to do something. My curiosity is certainly piqued!

In the meantime, welcome my Estherderby.com friends. Come in, and have a look around!



Image:
Magnifying Glass | Michael Connors


Thursday, 16 February 2012

Recipe: Guerilla Pizza

This isn't really a recipe as a money saving technique. Pizzas delivered from the local takeaway take around 20 minutes and cost between £10 and £15 depending on how crazy you go on size, toppings, and extras.
To save a bit of money, we have stopped getting takeaway pizzas, and have started "topping" our own. It takes just as long as waiting for the delivery person, even less on a Friday or Saturday night!

Ingredients:

You can put just about anything on your Guerilla Pizza (although, perhaps steer clear from actual Guerillas). Below is a set of ingredients we use as standard with a variation of the odd ingredient depending on what is in the fridge.

1 Frozen pizza
1/4 Medium onion very finely chopped
1-2 Garlic cloves very finely chopped
A handful of grated cheese (because store-bought pizzas never have enough!)

Cooking:

It is important to allow for the extra ingredients when considering the cooking time and temperature, especially if you are cooking from frozen. The solution we use is to lower the temperature by 15-ish degrees celcius and cook for the allotted time on the back of the box (add 5 or so minutes to this if you don't have a fan assisted oven).
Check about 3/4 of the way through cooking, and then as the time is up.

There you have it. For about 1/3 the cost of a [Insert Pizza Company] delivered pizza you get to choose your own ingredients and have a bit left over for some extra beer!

Enjoy