Archive

Posts Tagged ‘Programming’

Uh-Oh. Someone needs to learn some programming principles

October 5th, 2009 No comments

SQLite Concurrency

April 11th, 2009 No comments

Recently, I wrote an application that used a SQLite database and wrote data into a common database rapidly, over several connections.

I initially wrote the application to use one thread, and only one database connection, but as I improved the software, I converted it to use multiple threads with one connection per thread.

I quickly ran into the problem though that the database quickly became locked – one thread would block out the other and would not return the lock. It wasn’t consistent though as to which thread would be blocked – it was usually the second thread, but not consistently.

Having read a post from the pysqlite mailing list, I think it explains the problem a little bit more accurately, and kind of exaplins a solution. Although, it does seem a little bit drastic (essentially, reconnect everytime you need to run a concurrent query).

I’m now very interested to find out whether this will cure my problem. It does seem a bit drastic, and quite IO intensive, but it’s worth a shot!

I’ll let you know my mileage….

Ant Building

July 6th, 2006 No comments

I think this post by Stefan Bodewig kind of sum’s up what I’m thinking about the Ant build utility.

My company started using Ant about a year ago. We use it to compile Progress 4GL code, as well as Progress Webspeed files by using the PCT extension.

When I first saw it, I didn’t like it. I decided that using XML as a form of programming language did not make sense. I have no problem with using XML to describe build rules; the problem I have is related to the way that you can specify “build target a, followed by target b”.

But having recently gone through the process of installing it and editting a build XML file, I have to say I’m very impressed! I can overlook my distaste for “programming with XML”, because the rest flows very well indeed. Plus, I can understand it much more that I can makefiles.

Categories: Uncategorised Tags: , , ,

Fun with VMWare, New UML Tool and IPv6

July 3rd, 2006 No comments

On Friday, I had the day off, so I decided to play with VMWare Server on a new PC that I had inherited. I’m so impressed so far, for a free product, it does so much.

I’d played with VMWare Player at home before, and within the last year at work we’ve gone VMWare crazy and now host an awful lot of our servers in VMWare images, so I’m well used to their products by now.

I’m impressed by VMWare server though. It does so much more than VMWare Player. Even allowing somebody to install the VMWare-Tools into an image makes the “upgrade” a must.

I spent Friday building some images for a project I’m about to start work on, so that I can test it on different variants of Linux and FreeBSD, as well as on the Windows machine I have. Didn’t hit a single problem with the images, and it even runs Haiku incredibly well (that’s a one up on BeOS which doesn’t work in a VM at all).

Over the rest of the weekend, I’ve also discovered an excellent UML editor for Windows, called StarUML (http://www.staruml.com), which was a professionally produced product, but has now been made Open Source and Free (as in beer, I think).

I also did a little research on IPv6 which proved very helpful. I knew a little about it from a 5 minute aside in a university lecture course, but from what I’ve learnt over the weekend, a lot of thought has gone into the mechanism. The new style of development interface makes a lot more sense, seems very compatible with IPv4 and means that future version of the protocol will require fewer implementation changes! (Lets hear it for commons sense!)

So, put all those points together, and you can pretty much tell that I’m writing some kind of server, but that’s all I’m going to say!

Categories: Uncategorised Tags: , , ,

A Crash Course in Character Encodings

March 1st, 2006 No comments

This article, “A Crash Course in Character Encodings“, has certainly cleared up a lot of issues that I didn’t understand about Unicode character encodings!

I must admit it was the one area of software engineering that I was very grey about! Although the article is written for a Python audience, it still makes sense to me (although I looked a Python, I’m not a Python Developer!), and the principles are easily transferable.

If you need instruction in this area, read the article – it makes a lot of sense out of a confusing area!

Categories: Uncategorised Tags: , ,

Interesting Article

February 23rd, 2006 1 comment

I’ve stumbled upon an interesting article this morning called “I hated php back when it was cool“, which kind of vocalises some of the gripes I recently developed with PHP.

Namely, the language has grown exponentially, but without a structure to tie the language together effectively. I just love the description quoted in the article:Aristotle Pagaltzis makes an interesting point when he says how PHP suffers from a lack of initial design. … Basically PHP seems to have started out as a pet project, and had its features battered on with a staple gun, rather than included in the design.. Everything is done with a series of functions, most of which have different patterns of behaviour or different parameters depending on what version of PHP your running. This makes coding effective sites an absolute nightmare!

My other chief gripe is classes. Despite the recent changes to the whole class handling system in PHP, it’s still rubbish, and most of the time, I can’t use the improvements that PHP 5 brings because no bugger supports it!

To me, when the PHP people get to writing version 6, they need to stop, and quite literally start again. I really mean that – it doesn’t matter if the “newer” PHP code is not backwards compatible – it isn’t very BC at the moment, and so they should take more time, consider their direction, and plan ahead.

Categories: Uncategorised Tags: , , ,

Adaptive Firewalls

February 2nd, 2006 No comments

I’m thinking of building an adaptive firewall on my Linux router at home.

I’ve noticed that people are scanning the ports on the computer, and running HTTP requests to see if they can trip several known security flaws (e.g. in AwStats).

I did a little reading up on how to build an IPTables based adaptive firewall, and I’m beginning to concoct some ideas in my brain.

Basically, what I want to do, is constantly scan the requests that are made to Apache, and maybe some other server apps, and build some rules to pick out naughty behaviour. Once I’ve done that, I can get the IP address of the offender, and build a list of banned IP addresses. I’ll only want to “ban” (i.e. block at the firewall) those IPs for a set amount of time (e.g. 24 hours), but the response time of the firewall must be quick in order to catch these people in the act, and so I must rebuild my IPTables rules in reasonable time. After the 24 hours is up, I then need to clear any expired IP addresses down again whilst still keeping blocked IPs and my other firewall rules in place.

I’m therefore thinking that producing a series of scripts based around Cron is not suitable – you can’t schedule it to work more that once every minute. It could mean that I need to produce some server program (either using a UDP socket, or UNIX-type pipe) to receive IP addresses as soon as possible, and to store the data for 24 hours.

Anyone got any good suggestions?

Categories: Uncategorised Tags: , , , ,

Here’s A Question

January 17th, 2006 1 comment

Are all software bugs repeatable? As in, if you discover a bug in a piece of software, is there any type of bug that could not be repeated?

My answer is “Yes, all bugs are repeatable”. Bugs depend on circumstances, so as long as you can repeat the circumstances, then you can repeat the bug.

I’m betting Richard thinks otherwise…. 😉

Categories: Uncategorised Tags: , ,

iWeb Produces Crap Code!

January 13th, 2006 No comments

OK, so iWeb was launched the other day, as part of the new iLife ’06 package, and as soon as it was released people started using it and testing the output.

It appears, according to this post, that it produces some pretty nasty output – or should I say that it is not good engineering practice to produce the same output as iWeb!

However, I think that someone has nailed the situation pretty much on the head in the commentsWell, iWeb was built so that you didn’t have to write any code at all, so why care?

So what if there is some unnecessary code? It is a brand new application, and it gets the job done without the user having to write a line of code.

Posted by: Appleologist at January 12, 2006 09:42 PM

My point is this: Yes, it generates some pretty nasty code (although, full credit to Apple, it does parse correctly and conforms to standards), some of which could be cleaned up easily. But, as quoted, the people that will want to use this application are those people who don’t have enough web experience to develop this kind of site on their own, and so don’t care about what it generates – just as long as it looks good on their screen. The site will use up more web space, and more bandwidth, in order to host it, but not that much more.

The people that are commenting on the quality of the code, are going to be those people that know how to produce websites efficiently and correctly, and are people that care about the amount of bandwidth that their company uses, because bandwidth costs money.

Not having used iWeb, I can’t really comment on the use of the application, or it’s intended market, but from the evidence that I have seen, and my perceived target user based for the app, I would say that it does a pretty good job.

(Note To Apple: Please just tidy up the code a little, and get rid of that damn “Generator” tag – that thing just stinks of “Frontpage”!)

Categories: Uncategorised Tags: , , , ,

IT Graduates Not Happy With Courses

January 11th, 2006 1 comment

Apparently 46% (in this survey, at least) of UK IT Graduates are not happy with their courses saying that they failed to prepare them for working in “the real world”.

I would sit myself firmly in the 54% of the other Graduates that are happy with what I did at University. I think that may be the 46% were not aware of what they have been taught:Graduates were disappointed they were not taught Java and .NET – despite demand for them in the commercial sector.This makes me think that they have made an oversight. I was taught several languages at University, but only briefly touched on Java, and had no (at University, at least) experience of working with Microsoft .Net. The fact that both of these products (along with other, important, commercial products such as Oracle) are now available as a free download which these graduates could go to learn on their own, is not stated.

Even though I wasn’t taught them fully, I feel that I would not have a problem with switching to these languages. Why? Because I was taught how to program, not how to program in X, Y, or Z languages. The skills are very transferable, if you put your mind to it (incidentally, I am not stating that all programming languages are the same – they are not, but many ideas and concepts do, readily, transfer).

Let me put this into the context of an analogy:

Imagine that, at University, you were taught to drive a car. You were taught what all the pedals were for, how to steer, when to change gear, how to drive in traffic, the whole lot; except the only car the University had available for you to drive and to practice in was, for example, a Honda, and sometimes there was a Vauxhall on offer if you took the right course in your third year.

You then graduate from University, and start looking for a job, advertising yourself as a “driver”, as there is little need for a specific “Honda Only driver (with some experience of Vauxhalls)”.

When you get to your job, you are asked to drive a Ford.

When you immediately get into the car, most things are the same, and you can more-or-less start driving straight away. OK, every now and again, you forget where the windscreen washer is, or it takes you a bit of time to get used to the gear box, but after a while you are driving well. Could you then say that you felt disappointed because your University did not teach you to drive a Ford? Most things are the same, except for a few little levers and things, but the principles are all exactly the same.

University is not about learning specifics – it is about learning principles. The problem with principles though, is that you can’t use “principles”, you have to use an implementation of those principles, which may have included, changed or excluded those principles at will.

Ignoring those principles, and only absorbing implementation specifics is a unwise thing to do.

Categories: Uncategorised Tags: , ,