Work with validation

Well that didn't take long.

A huge part (and pain) of my A level coursework for computing was validation – it’s obviously quite important for user input. As one of my lecturers has previously mentioned, you can’t just assume a user is clever enough not to enter stupid things, and when a user breaks a program by doing so, it’s your fault.

The three main ones we had to deal with were Postcode, date, and time, since they have specific and complex formats. At the time, we were made to do them in massively huge if statement chains which the first time I wrote them were quite tedious, but luckily, for the second year, I could just copy across what I’d already written.

Looking back on this, I feel cheated. I’m rewriting all my validation methods as I don’t have my old coursework on my laptop (and it was in C++ which is close but not the same), and doing so now takes a great deal less code, after discovering the “DateTime” data type earlier this year, which ensures you can’t enter stupid dates (I think…I’ve googled this to ensure because it sounds too good to be true, but there’s no where that says anything about having to do extra validation like stopping 31/02/2011 from being entered – I’ll just test it out on the program to see if it stops it later), and the discovery of using Regular Expressions which is useful for postcodes. After finding these in C#, I looked into whether they both exist in C++. Yes. Yes, they do.

As I haven’t actually said what a RE is, basically it’s a definition of the format in which the string must be entered using specific syntax. This is where I can see that the maths module I had to do this year is important, as I learned about them in that module – this doesn’t mean I remember -all- of the syntax, but it’s useful to know how they work. A useful website which I will be favouriting is the Regular Expression Library, where I got my postcode RegEx from.

I can see why you’re made to do all the validation, as at the time both of those may have been too complex for what was need-no that’s a lie, both of them are really easy to use…I can see why because it does make you think specifically how you need to validate everything, but at the same time I can’t help thinking “I spent a good few hours working out the algorithm, making the pseudo code/flow chart, and finally programming each of these methods” when it’s literally taken 3 lines of code to see if a postcode fits in a regular expression.  I love moments like these.

For those who need to use regular expressions, all you need to do is add the library System.Text.RegularExpressions and set up your regular expression as shown in the screenshot above:

Regex Name = new Regex(“your regular expression here”);

if(Name.IsMatch(string))

{

whatever you want to happen here

}

Hope that helps.

Module choices and procrastination

Random photos are cool.

I got an email yesterday saying I’d not done my module choices, or the right number of them anyway, so I’m now looking over them again.

As I said previously, I’ve been struggling over module choices. I’ve put them in now, although I will always be thinking have I made the right decision. I went for both graphics modules in the end but was debating not doing either and doing information systems and systems engineering instead, mostly due to being quite interested in information systems, but at a guess it’s something I’m likely to be able to pick up later.

I’m also doing (again, said this a few blogs ago, may as well say it again) – Networking & Web Technologies, Advanced Programming, Passport level 5 Spanish. Myadmin also says I’m doing Artificial Intelligence…not quite sure if that’s allowed, that would mean I’d got 140 credits rather than 120? I don’t mind doing both really because I am interested in AI, I just kind of need to check that out.

Other than that, had my maths exam on Monday which was relatively straight forward, I found it a little more wordy than the past papers which I think most people thought, but I think I’ve done okay. Additionally during revision time I started rebuilding the system I made during A level in C++ in C# – my aim is to connect it up to a MySQL database, so that I can have clients sign up and request appointment bookings online, which I’ve found the library for, but up until today I’ve not had access to my web hosting (think it’s time to move again when my year runs out -_-) so been working with files instead. I’m slightly less interested now because it’s always more interesting to code than to revise, but I want to try and finish it if not before I get home, during the summer. I could have just waited till the C++ module begins next year (I’m very rusty on C++ now because I just have no reason to practice it – might look into it again during summer)

Principles I’ve learned in producing programming cw

List blogs are cool. A few things I’ve learned in mostly programming coursework this term and last term, but also during 3 thing game.

  1. Classes are useful
  2. Doing one thing at once is better than doing 1 thing, breaking it and moving onto another
  3. Sitting staring at code for hours won’t fix it
  4. Neither will pressing compile over and over again hoping it will magically work
  5. I either can’t draw to save my life or can’t be bothered to put effort into drawing to save my life
  6. Relying on your 1337 ability to code things in a hurry is a bad idea
  7. Relying on the fact it roughly works and that the bugs “are quite small” is also a bad idea
  8. Making graphics fade out is surprisingly easy (in XNA)
  9. If it works one way that isn’t the way you’d like it to work, but it works nonetheless, don’t overcomplicate it.
  10. Stop programming and do some other coursework that’s less finished, or revision.

First year almost over

So we’re in the final few weeks of first year and it’s flown. I feel that I should just put my protips for surviving it because it’s something interesting to blog about:

A guide to surviving first year CS from my point of view

- Grow a thick skin + a sense of humour.

- Don’t be afraid to stand up for your opinion or ask questions. Better to be wrong, heard and corrected than never heard at all, and if you’re right you’ll feel better about your own intelligence ;)

- Don’t diss geeks or pretend you’re not one of them. At the end of the day, we’re all human, and if you picked CS, you’ll probably be as geeky by the end of the year, and that’s not something to be ashamed of, just keep up other interests

- Don’t be intimidated by other people’s knowledge.

- Remember you’re not alone, and there’s a million and one blogs which will make you feel better about whatever’s been thrown at you so get googling.

- Drink plenty of wine at the end of the day and watch plenty of girly movies.

- Kick ass.

 

At the moment deadlines are piling up – the group project’s due in sometime this week, sweepy cleaner’s due in next week, as with the maths, and on top of that there’s another group project we’ve not recieved yet and exams, aswell as a program demo and the presentation for the group project.

I’m not too worried really – sweepy cleaner’s working now, there’s a few tweaks need to be made but hopefully the code session with byeguys and tinkerbell (Adam and Ryan xD) should help tomorrow, just need to get my levels drawn. I can’t imagine life outside the lawns, shock horror about actually cooking next year! Exciting though, although I no longer have the failsafe “well, all I need is 40%” unless I want to waste my degree :P

I lied. I miss php.

She's not related to anything, BUT NAWWWW MY DOG'S SO CUTE (her name is Jenny, btw, not PHP)

As part of the aforementioned website making bit of coursework, I’m now onto doing the sales figures report for this imaginary company, Hull PCs.

I suddenly really miss PHP.

It’s been a long time since I’ve had to manually type in figures into a flat HTML file, and it stinks. It hurts more the fact there’s a database as part of the coursework which a team member is doing, so the figures have already been typed into a useable format (lol access isn’t useable don’t lie charlotte) which could be outputted into a report using PHP and mySQL ridiculously easy, so the way it’s set out just makes me think “WHY ARE YOU DOING THIS TO US”

I’m not even sure if what I’m doing is correct to be honest, but chugging along with it anyway.

HTML – missed you man.

I’ve had quite a long break from doing just straight web design, for various reasons. Once I got onto PHP about year 11/12 doing the regular tags and graphics and css and stuff just became boring and old fashioned. As part of the IT & professional skills module in the team project coursework one of the deliverables is a website, so I gnabbed it because it’s what I enjoy doing. Without web design I probably wouldn’t have done computer science – when I was about 12 or so I started and kept excitedly going to my dad saying “LOOK LOOK WHAT I DID”, and several years later I learned more than him (“charlotte I found this website with loads of javascript bases and DHTML codes, it’s called dynami-” “yes dad, dynamic drive I found that years ago jeeze you’re so slow!”) which…is one of the reasons I’m doing this course, I like knowing more – so it’s something like going back to my roots as I’m not allowed to use scripting such as PHP. Slightly annoying this rules out javascript aswell I assume, so I can’t put flashy stuff in like slideshows and random images and things, although I guess this is a good thing as the main thing is just to show you’re competent with HTML.

My style’s grown up a lot since I started, for the better really, I began with blending images together, adding effects to them, making layouts full of lots of graphics, which isn’t really a professional way of building websites. Unlike luckier people my age who do this and have had chances to build websites for people, I never had enough contacts to be able to do it professionally and thus don’t have a portfolio as of yet. I still don’t really know how to price web design – I’ve always done it for fun. Doing this deliverable has made me start my list of stuff I need to do this summer, anyhow: sort my own website design out, and do my dad’s, A3D3 (Fun fact: that stands for As 3, Daughters 3. As in, “hope my 3 daughters get 3 As at A level”. Before asking him I assumed it was either some play on R2D2 or something computer related. Naww) because it’s god awful. (Don’t look at me, I didn’t make that!) Also, plug plug plug if anyone needs their computers fixing, A3D3′s his computer repair company.

met office update

Blogging from my phone as I’m down south at the moment. Realised I hadn’t blogged about met office for a while – I received a phone call first week of easter about my third choice placement, and subsequently a phone interview. By this point I’d realised I didn’t even really want any of them as it lasts 3 months, meaning I couldn’t interrail with my big sister or really, do anything over the summer. The job this time was essentially populating a couple of moodle sites. I didn’t get the job, which they were nice enough to email me the following day, but the phone interview experience was useful, and its nice I got throough on two out of three of the placements I went for, considering the level of competition. If I go for it next year, unlikely, seriously need to rethink how I talk about the various projects I’ve done and hope not all the systems I do as coursework next year are games. Still slightly bugged no one told me if I got through on my first choice, but oh well.

Sweepy cleaner progress – it looks pretty. That’s all that matters.

Sofa's a bit dusty

If only the title were true :P I took the plunge a few days ago, after considering having friends draw my artwork for me (but realising it’s not that hard when you know your graphics program, and that friends might ask me to pay them), and made sweepy cleaner look slightly less pixelated, and discovered a major flaw in my intersects method – due to me actually setting the origin vector as the middle of the sprite, (which…is technically correct, but as I haven’t worked with the origin very often I cut it out to save hastle), intersects was only registering from the middle to the right, and ignoring if the vacuum hit the middle to left portion of the furniture.

I only paid attention to this because previously (see last blog), my sofa was tiny so it wasn’t such an issue.

Anyway, as you can see, problem I’m having now is stopping dust spawning on furniture, and for that matter, the walls, and taking away health when the vacuum hits the top wall (it currently works for the left and right walls). I took a look at the spec, just to see what else I’m missing that’s vital, the only real big thing I’ve not got yet is an attract mode along with a highscores table…and I’ve given the vacuum more health than it should have so I may change that. It’s quite easy to never lose at the moment with the amount of health I’ve given. (5 for every life, although at the moment after you lose your lives it carries on because I haven’t done the gameover state) Also, need to work on a start screen, pause and gameover. Additionally to this I’m intending to:

- Do levels, still with the vacuum going through the door at the top, and then slowly scrolling level1′s furniture and background out. I don’t imagine it’s actually that hard…but we’ll see.

- Magic pixie dust – should be easy

- Sound effects – I intend to record my vacuum cleaner when I get chance – may aswell while I’m home!

I was debating whether to do the “deadly lightshade” addition where you have an AI character chasing the vacuum, which I could work out with some thought process, but I think levels is easier to be honest, and if I fit in sound effects and pixie dust then those 3 add up to 20% – the maximum for additional work on top of the spec.

In my head, biggest thing I’m probably struggling with is stopping myself from thinking “well that’s broken so let’s add another complexity somewhere else”, when it’s tough I tend to be doing half of one thing and half of another somewhere else.

I should also be getting along with my group project work – I elected to do the website portion as I’d probably actually enjoy it – pack for Cornwall tomorrow and get my Quantitative methods coursework done. Had this issue at A level and GCSE – I love doing the fun parts, but tend to do them too much and then not look at the less fun parts.

I wish my family were as geeky as me.

Sweepy Cleaner progress - IT WORKS I TELL YOU

At the moment my Sweepy Cleaner is finally coming together – my problems at the moment are collisions with walls from the vacuum and stopping my dust from spawning on walls and furniture. The first one I have an idea of where I’m going wrong, but the latter I’m still waiting for more brainwaves.

Swimming and leaving the house seems to help with brainwaves – I very rarely actually think about swimming when swimming…well…that would be like thinking about walking when you’re walking – it’s like when you take a shower and think about everything you’ve done before it and have to do after it, I probably solve some of the greatest thought problems in my life in the shower or in the swimming pool.

Anyway, after managing to do random dust spawning and points, I took my laptop downstairs to show my mum and sister going “LOOK LOOK WHAT I DID”…and their response was something like “brilliant charlotte, its a vacuum touching some dirt. WELL DONE *sarcastic clap*”…well…that’s more what I would probably respond with if I was disinterested, but you get the gist. Not bothered. I showed it to my dad, who is quite geeky but hard to impress, and he was slightly more interested but not nearly as excited as me.

We established last night, my sisters and I, that as a family we are quite geeky – one sister does Chemical Engineering, the other’s a licensed drug dealer (pharmacist), and we had the discussion that random things trigger geeky thoughts – for me it’s stuff like words you can equate to computing – “global” “instance” etc – for the other two it’s more chemicals, drugs and medical stuff – but the problem is that they don’t really meet in the middle so we get excited about stuff that’s not related to each other, and whilst I don’t really judge my sisters for being “OH MY GOD CHEMICALS”, everyone except my dad just thinks “charlotte it’s a sodding computer, calm down”.

-sigh- #geek problems.

Hull’s got it right

I was talking to mum today about programming and such, and I often advocate that hull compsci dept is awesome – don’t really need to to my mother because she did the coloring in degree (geography) there, so to both of us hull is the best place in the world. Anyway back on topic, I say hull is awesome because they’ve got 3 thing game, push people into going up for development competitions, and well, we’ve got rob miles. But just to big it up more, when we found out hull teaches c# at open day last year, my mum looked into how many jobs there were for c# jobs, particularly here in Sheffield. A big fat zero, diddly squit, is your answer. She looked again a couple of days ago – now there’s bloody millions! It’s probably got a lot to do with Microsoft using it for Xna development as well as Sony for the ps vita, but at any rate, there’s solid evidence Rob Miles can predict the future.