Skip to content

Programming – Tidy up my code or not?

January 9, 2012

My code works. It’s not complete yet though – the deadline is coming up in a month.

I initially wrote the program as one monolithic c file – around 1600 lines. At the time I didn’t know how to write a make file for GTK, and I just wanted to get on with the coding. As it turns out, writing the make file was dead simple, and I should have just done that from the start.

I’ve since broken the code out into some modules, so it’s a bit tidier. But it’s still using some global variables, which I’m now considering putting into structs and passing those to the methods that use them.

So it’s a question of whether it’s really worth doing this? Can we just say that I’ve learnt my lesson about programming modularly (do it from the start), and just get the project done?
I guess realistically, it might only take another day to get this done. Which isn’t that long in the scheme of things – and it will give me the satisfaction of have nice tidy code.

What I’m feeling hesitant about is – that I don’t know the correct form for modular programming. I could spend a day reading articles online about modular programming. But that would feel like I’ve spent a day and haven’t got anything done. I do have a lecturer I can email, and ask him to come in and give me some one on one advice about how to best go about it.
But in the mean time?
What I’m a little worried about, is if I spend all this time breaking it into modules, and that turns out to be the wrong way to do it, then I’d spend an additional bunch of hours going about doing it the right way.
Well – back to work doing it I guess.
Update: – It’s 5:40pm and I’m giving up. I haven’t had a particularly productive day (I slept in), I didn’t get started till 1pm. Am going to go home, try get my head straight, and hopefully have a very good day tomorrow.
Update: – It’s the end of the next day. I saw my lecturer today, went over some things. I have a better idea of how I could have gone about things, but this code is too far gone.
I’m just going to have to make do with what I’ve got, hopefully no body in the future has to read it.
It’s a relief though – now I can just get on with doing the work.

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: