2013/06/18

Welfare State 101

Welfare State 101:



The purpose of the Welfare State is to afford everyone dignity, opportunities, and access to society.
Who has maximal access to society? Working, childless, healthy, able-bodied, educated adults who own their own home. They can support themselves, they can socialise, help with causes, and so on.
So the aim is to get everyone as close as possible to that position.

Rule 1 is Health. 

If you aren’t healthy, you can’t work, can’t study, can’t look after someone else, can’t do anything as well as you could when you ARE healthy. The United States is a cautionary tale for all of us here – if healthcare is not comprehensive, people slip through the cracks and will bankrupt themselves trying to achieve health. There are a variety of valid options for running a health system, but the NHS is one of them – it is fundamentally sound, and good value for money by international standards. So, I wouldn’t mess with it too much; possibly try to fold optical and dental care into the system of paying taxes and then receiving free treatment at the point of need, but no more.
[For example, laser eye surgery is expensive, but cheaper over time than contact lenses. If I didn't have to pay up front, I would have had my eyes lasered 2-3 years ago when my prescription was sufficiently stable, and would be saving over contact lenses by now].

Rule 2 is Education

If you don't have any education, you won't have many choices in life. In fact, I think I've discussed the issue of education here.
Free education from nursery to A-level at a minimum. If someone drops out of education before age 18, they should be able to go back free as and when they're ready. I know plenty of people who didn't want an education aged 16, then grew up and realised better qualifications would be really handy. That's normal, and shouldn't be penalised.

Rule 3 is Money

Ideally we want all adults to either earn money directly, be supported by someone who is earning directly (e.g. stay-at-home parent supported by their partner), or be living off their own prior earnings (pensioner).
Due to unemployment, and disability, and taking time off to look after small children, and further education, and…there are many reasons why this isn’t going to work. At the moment we have a hodge-podge of systems and funds to deal with this, from Job-seekers Allowance, through Child Benefit, Tax Credits, Disability Living Allowance, and so on.
However, as I found while unemployed, there are cracks in this system – the specific one I slipped through is probably fairly rare, but there are common ones. How do we prevent people slipping through the cracks?
There's a radical solution - guaranteed income – every adult is guaranteed income equivalent to a full-time minimum-wage job after tax.
At the moment this would be around £11,200 a year (£6.19 an hour, 40 hours a week, 50 weeks a year). What is the cost of £11,200 a year for every adult in the UK? Well, according to census data we have approximately 63 million people, and about 16 million of them are 19 or younger – so call it 47 million people, times £11,200 a year.
That’s £517 billion, which is a suitably scary number (aka about 1/3 of the whole economy). However, a lot of the expense is already being paid – for example, everyone older than 65 who contributed to National Insurance is getting £5,700 odd a year as their State Pension, regardless of need.
Additionally, guaranteed income will cover Housing Benefit; Council Tax Benefit, Child Benefit...
The Department for Work and Pensions already controls a budget of £160 billion; Tax Credits and Child Benefits (coming from HMRC) is another £40 (that’s got us to £200 of the £500 necessary), and not to mention the fact that a basic income guarantee allows the social housing stock to be rented out, providing a countervailing income stream.
However, to close the gap, top tax rates, and corporate tax rates, are going to have to go up. The other side is that companies have more customers, fewer people who can’t afford to buy.
Also bear in mind that even with a Basic Income of £11,000 per annum, anyone earning more than about £45,000 will still be paying more tax than they are receiving in Basic Income; that’s around 10% of taxpayers and much more of the percentage of tax.
Why am I justifying this? The brief is that I am dictator and can create the welfare state I want - well there you go. It might not be complete, but that's a good start.

2013/05/12

The purpose of education

A quick interlude from the Manifesto series - that Values Development Project just keeps on rolling, and as education is the next thing on my list to consider it is very apt that the current prompt is:

What is the purpose of public education?

Or to put it another way, why is it compulsory for children to spend thirteen years of their lives learning in school; what benefit do they get from it? Assuming that the children benefit, what do their parents get out of it? And what of society at large? Do we benefit from educating other peoples' children?

The child


In the first instance, that of the child as an individual - we live in a big and complicated world. Centuries ago you could learn a trade from adults around you without any formal instruction. Almost everyone you knew would be close enough to walk over and say hello. Any contracts and tenancies into which you entered would be on traditional terms. Unless you were rich you would handle very little money in your life, and mostly make deals by paying in goods, or remembering what you were owed. And your rights in your local political system were likely to amount to "rise in rebellion if it all gets too unbearable, otherwise put up and shut up".
So the need for education was minimal.
Now, on the other hand, just to live quietly in a small town, work at a nondescript job, and stay out of trouble, you need to:
Read and write, quite well - you will sign contracts to secure your dwelling place, your employment, your communication with friends and family. More informally you will get written instructions to assemble your furniture; you will receive birthday cards; you will want to write to your MP or Councillor about your concerns.
Be able to handle arithmetic, compound interest and other mathematics - you may take on debt to buy a home, get an education, or just to get something you really want. If you don't understand how interest works, you are likely to pay much more than you need to, and may cause problems for other aspects of your life.[1]
Have a knowledge of complex systems - to know your legal rights; to know how to get involved in politics; to keep up with what's going on in the world; simply to find the right bloody form to fill in at the post office, requires not just personal knowledge of how society works, but also knowledge of who to approach with your questions, how to judge the trustworthiness of sources[2] etc.

If you don't have an adequate education you will not be able to find a job, or at least not one that's interesting and has any chance of going anywhere; so if you want to do interesting things at work, and have enough money to do interesting things with your free time, some kind of education is essential.

Also, you need a certain baseline of education in order to be able to get more - many information sources assume a certain level of competence. For example, almost all companies assume that you can read - and that you can read in English. More and more, it is assumed that you can access the Internet, and that you will be able to make use of information you find there. Supermarkets assume that you can't add up very well, so that they can make more profit, and it is very much in your interests to prove them wrong.

Enough about the individual - most people realise at some point that education is worthwhile for them personally, albeit it takes some of them years after leaving school (as it happens this is why I am in favour of offering free courses at Further Education colleges to all, up to A-level[3].

The parents


It is in a parent's interest to educate their child; a parent should want the best for their child, and the best cannot be had without an education. If you want your children to decide what they want to do in life, and to achieve their potential, then spending some time teaching them what life has to offer, and developing their skills and knowledge, is fairly vital.
The tricky thing, obviously, is that all parents have limited expertise, and also limited time; so if home-schooling were universal, many budding scientists would get a great education in the humanities, but not learn the first thing about science because their parents have no expertise in it; children who could have been great novelists will end up as lab technicians because their parents didn't have the literary chops to light the touchpaper; and children who could have done anything will get hardly any education at all, because their parents don't know enough, don't have enough time, or simply can't be bothered.
Like so many aspects of life, by pooling the responsibilities and costs of a major requirement we can raise the floor - make the worst experience better than it might have been - and make opportunities more equal.
With all the flaws and failings that our current education system undoubtedly has (a scary proportion of children reaching age 11 still functionally illiterate, for starters), it is still possible for a child whose parents have little education and less interest in education to make it in life; to learn what they need in school to go out and make the world their oyster.[4]

Society:


Educated people are more productive; educated people are better citizens; better education leads to less inequality in a society; an educated workforce is the biggest draw for companies to base themselves near you, both on the micro-scale (look at the number of tech start-ups around Cambridge) and on the macro-scale of countries in the global economy.
If you have any belief in equality of opportunity, a good, free, compulsory school system is the foundation stone of equality - and if you don't believe that equality of opportunity is a good thing, please justify yourself below, because even our darling Coalition pay lip-service to the idea.


[1]A story from my father - when he was a fairly young adult, credit cards first became available. Some of his friends went "Ooh, free money", and spent up to their credit limit because they could, be it on suits or cars or whatever - and were paying it off - and regretting it - for years.
[2]e.g. if you do not wish to receive marketing telephone calls, you can register with the Telephone Preference Service. This is free. There are several companies who will charge you money and then register on your behalf. They are deceitful bastards. Finding this out takes either bitter experience or some research.
[3]Translation into American - essentially free education up to finishing High School, no matter the age of the student.
[4] At least in theory; a range of practical hurdles do exist between baby Sam and Sam who has achieved their heart's desire.

2013/04/30

Roles of Government - Security (III)

Content note: I am getting slower in sourcing my posts. In an attempt to keep content flowing, I am going to be doing more ranting and less evidencing in my next few posts. Anything which you doubt, dispute or otherwise want to question, please hit me with it and I will try to source it or amend it as appropriate.

After Defence and the Home Office, the last ministry primarily concerned with security is the Ministry of Justice.

The Ministry of Justice is essentially responsible for the courts, prisons, the Probation Service, and the judiciary.

While I'm sure insiders could point to various problems, I don't think there's anything fundamentally wrong with the judiciary, and it's not very expensive in the grand scheme of things, so we'll leave that as it stands.
As to the court system more generally, again I am sure there are many changes those intimate with it might wish to make; the main problem of which I am aware is with access in the first place, so I would advise increases to Legal Aid funding. The current level is £1.7 billion per year, and the Government is looking to cut it; this is stupid. I would allow for say doubling it over the course of a Parliament, and thus having £3.5 billion per annum available after five years. It doesn't matter how just your laws are, or how fair your courts, if the average person on the street can't afford to bring a case, or defend one.

I'm also firmly of the opinion that "justice too long delayed is justice denied"; so funding some over-capacity of courts in order to ensure that there are not long delays for trials seems reasonable.

Prisons, detention centres etc - as discussed before, we are closing the detention centres, at a substantial saving. We are also going to cut prison occupancy substantially as those convicted purely of drug offences are released.
Where is that money going to go? Primarily into probation and drug treatment programs; indeed, it may well be worth spending more on those services than was spent on prisons, in order to cut imprisonment still further - locking up one person for a year costs around £40,000. A life sentence (minimum 25 years before parole) costs at least £1,000,000, and up to (sentenced at 21 to a life-means-life sentence, lives to life expectancy of 79) - about £2.3 million. Quite apart from improving peoples' lives (both those who would have been locked up, and those who would have been victims), spending money to prevent crime saves money. You would think that our illustrious austerity-coalition would be in favour of it.

It is surprising how many people favour longer prison sentences, as though they would solve anything. I'm not going to go in-depth with all the criminology, not least because I'm not a subject matter expert, but here are a few facts:
1) when there was a death sentence in this country, which was applied to a minority of convicted murderers, most murderers faced a prison sentence of around 14 years, which could be shorter if paroled.
2) Without denying personal responsibility for specific crimes, the commission of crimes in general is a social ill which can (and should!) be mitigated. For example the high proportion of offences to pay for drug addiction - if addiction is medically treated, then most of these offences should disappear.
3) I want to hit 2) again because it's really important. The law should rightfully come down like a ton of bricks against someone who is educated, who has had opportunities, and has chosen to commit crime; those whose education has been derisory, whose opportunities have been slim, whose upbringing has been damaging, should be given more help, and a chance to set themselves back on their feet, rather than punishment.

I am well aware that rehabilitation isn't nearly as emotionally satisfying as punishment, and so a policy of light sentencing, community sentences wherever possible, and well-funded probation services is likely to come across as "weak", "coddling criminals" and whatever else the tabloids want to fling at it.
The initial means to solve this which occurs to me is to fold the probation service into social services more generally; link any educational support targeted at failing students, with support for families that are struggling; help for the homeless; and so on - because a lot of social problems are linked, and so dealing with them all under the same heading seems sensible.

2013/04/15

Roles of Government - Security (II)

Last time: Defence now the Home Office. (Part of the Manifesto series).

The Home Office has responsibilities for immigration, internal security and law and order. It used to cover the criminal justice system and the courts, but those have been transferred to the Ministry of Justice.

Immigration is such a minefield that I'm going to save that for last. Internal security (meaning the Security Service, aka MI5) is in a similar state to MI6 as discussed in my previous post; so again, my prescription would be more direct oversight by Parliament. If anyone knows more about what should be done with MI5, please chime in below.

Law and Order

The Home Office is responsible for the catastrophe that is government drugs policy - the Secretary of State has the power to add and remove drugs from the classifications of Class A, B and C, among other powers. So point one - remove all drugs from class A and B; declassify all Class C drugs. Anything deemed truly dangerous can be retained as Class C, so that there are substantial penalties for supply, but minimal penalties for possession.
The social harms of drugs policy - imprisonment of non-violent offenders, the contempt for the law fostered amongst those (20% ever, 9% in the last year) who repeatedly break the law doing something less harmful than getting drunk, the difficulties of treating addicts who are convicted criminals, and the vast funds funnelled to criminal organisations who have no legitimate competition - are far greater than the harm to society of permitting the use of drugs. The Government's response to drugs should be moved into the Department of Health, and HMRC, as the treatment of addicts will be paid for by the taxes on the sale of legal drugs. Alcohol pays more into the Exchequer than alcoholics cost society, and the same is true of tobacco; there is no reason that other drugs can't move the same way.

Police Tactics and Behaviour

Having taken away a large part of their work, there is another thing about the police which has been bothering me; their public order tactics. While crime rates have been on a slow but steady decline for years, the police have nonetheless been getting more heavily equipped. This is seen especially in two venues: firstly at football matches, and secondly at protests.
The right of freedom of association and to liberty and security of person under the European Convention on Human Rights (Articles 5 and 11 respectively) clearly protect the process of people coming together in a public space to either demonstrate for or against a cause, or purely for the purposes of entertainment (like football!). However, entirely peaceful assemblies have been kettled - surrounded by police and not permitted to leave, sometimes for hours at a time. On some occasions this has led to confrontations between police and protestors; on others it has led to injuries and even death among the previously peaceful protesters. In all instances it has a chilling effect on the freedom of expression of both protesters and bystanders, who are made well aware that they might be detained in cramped conditions for hours at a time if they join in a demonstration, rally or protest which the police don't like. It also fosters hostility between police and law-abiding citizens, damaging the common consent and co-operation of the people whose support the police rely upon to actually do their jobs.
So, directly, kettling should be banned in all but the most exceptional circumstances. Any instance of kettling should be reported to the Home Secretary - multiple anecdotal reports of kettling that I have heard, including one which I experienced don't seem to be publicly recorded -  and discussed by the Home Affairs Select Committee in the Commons. More broadly, however, the police should be firmly instructed to treat peaceful assemblies of people as just that, not as hostile mobs waiting to attack.
The Home Secretary should be unafraid to sack senior police officers who fail to recognise the importance of an actively involved citizenry in the political process, or who like to unlawfully imprison hundreds of citizens who were going about their lawful affairs. (Detaining hundreds of people for several hours is equivalent, in loss of time, to sending one person to prison for several months. This is very much NOT OKAY.)

Immigration Policy


Okay, now I've pogo-sticked my way across a couple of minefields, let's open up the really big one. Immigration is a hot button issue, and has been at least since the Celts were discussing the excessive rate of immigration of Anglo-Saxons into Britain some time in the fifth or sixth century.
However, after sixty years of record-breaking immigration since the Empire Windrush arrived...the population is growing, but steadily rather than out of control. The percentage of the population which is not both white and British is growing - but 80% of us are both, and many of the remainder are either white (and mostly Irish or Polish) or British (but with cultural and family ties elsewhere, especially to India and Pakistan).
More directly, most of those who came from the new EU Member States to work are staying here for a few years and then going home.
So that's point one - the system isn't exactly falling apart. The existence of the British nation isn't under threat, and as is shown by a variety of measures from birth-rates to language use, most immigrants to Britain do gradually assimilate. Anyone who mentions Eurabia style paranoia is off their rocker - in 10 years, Islam has increased from 3.0% of the English and Welsh population to 4.8%. Anyone obsessing over the growth of Islam in the UK is ignoring the much faster conversion-based growth of non-religion.
What is more, immigrants to the UK are more likely than native inhabitants to be steadily in work; to be educated and highly qualified; and to be proud of their connection with Britain.
I know that all of this should seem obvious to anyone who looks at the data - however, to anybody who reads the Daily Mail, the fact that immigrants to this country aren't straining the benefits system* to breaking point while destroying our native culture might come as a surprise.
Dealing with the linked, though opposite, fear that immigrants "steal" the jobs of native people is a little more complex. There are valid concerns here; fortunately, the economic evidence suggests that the improvements to the economy thanks to immigration lead to more jobs being created than the immigrants themselves fill; what is more, evidence from the economic crash since 2008 is that EU citizens are more likely to return home or move elsewhere in the EU for work than to remain in the UK if they lose their employment.
So, as a result of all this, I would want to make some fairly broad changes to the immigration system. Essentially, anyone who can get to the UK, and pledges to learn English and abide by UK law, would be granted leave to remain in the country and helped to find employment.
Anyone convicted of a crime in the UK who did not yet hold citizenship would face either a sentence of deportation to their country of origin, or a sentence of imprisonment followed by deportation, depending on the severity of the crime.
And any immigrant who has established themselves in the UK and wishes to become a citizen would be permitted to do so by following the usual process already laid down in law.
Perhaps British Embassies and consulates could be provided with resources to teach English and a bit about UK culture to prospective migrants, and provide them with advice and contacts to help them to establish themselves here on arrival; that would come under the Foreign Office, which we'll get to in another post.
This sounds drastic, and extreme; however, it's a fairly safe bet, based on the way migration seems to work. Migration draws the most qualified, the most motivated, or the most desperate of people; anyone who is content with their life is never going to migrate, and most people who aren't highly qualified will only migrate if their life or family are in serious danger. Migration boosts the economy of the host country; it also results in financial aid to countries of origin through remittances; and migrants who cannot find work will generally go home. So the numbers of migrants should not exceed what the economy can bear; we will also be meeting our international obligation to take in refugees and asylum seekers.
This will greatly simplify the operations of the UK Border Agency, as well as permitting the closure of Yarls Wood and the other immigration detention centres. This is probably for the best.

*Yes - 40% of UK citizens receive some kind of benefit from the state, as against 23.1% of migrants from "A8" states (Poland, Czech Republic, Slovakia, Hungary, Latvia, Lithuania, Estonia, Slovenia).

2013/04/10

Roles of Government - Security

Part of the ongoing Manifesto series.

As discussed last week, the security of the nation and its people is a core responsibility of any government.

External security is handled by the Armed Forces, and the Secret Intelligence Service, better known as MI6. As much as MI6 are getting more open over time, what exactly they do with their money isn't the clearest, so  beyond making MI6 more accountable to Parliament directly, I don't have a clear sense of what changes might need to be there.

The Armed Forces are a bit more open - it's hard to hide tank regiments or frigates, after all. Current state of play has a budget of about £40 billion (Wiki claims £36, but I don't think this includes all defence research etc) for all three services and procurement/defence research; this is generally considered to be the 4th biggest defence budget in the world, after the US, China and Russia.
Given our longstanding and active alliance structures, a substantial increase in the defence budget seems somewhat unnecessary; essentially we are closely aligned with the biggest military power in the world, and closely linked through NATO and/or the EU with five more of the top 15 (France, Germany, Italy, Canada, Australia).
It seems easy to say, then, that we face no existential threats as a nation, and that the primary roles for the Armed Forces will be expeditionary wars, peace-keeping and peace support, and aid to the civil power. However, given that some Armed Forces capabilities would take a generation to re-build if lost entirely (e.g. operating carrier aircraft is not an easy skill to regain once lost; nor is armoured warfare), there may be some capabilities which it is wise to retain in case they are required in future.

Taking the three Armed Forces in order:

Royal Navy

The Navy currently has 6 destroyers and 13 frigates; two helicopter carriers; two assault landing ships; three more large landing ships; seven hunter-killer submarines; four nuclear missile submarines; and assorted minehunters, patrol vessels and other smaller warships.
The Navy also controls the Fleet Air Arm (currently consisting of assorted helicopters and training aircraft) and the Royal Marines - who account for roughly a combat brigade. There is a contract under way to provide two aircraft carriers.
With an aim for defence of peace-keeping and expeditionary wars, what capabilities does the Navy need?
Troop transport and assault landing capabilities are a must - with five capable landing ships that seems to be fairly well covered. Maritime patrol and anti-piracy options require a few frigates and destroyers, though I don't know exactly how many. The hunter-killer submarines provide a serious maritime warfare capability, as well as shore bombardment with cruise missiles.
That's all good - while there may be a shortfall in number of ships to be everywhere and do everything required, the actual capabilities look fairly well matched to what I'm aiming for. The really big gap is the carriers, of which only two are being constructed, and which won't be ready until 2020 or so. That's pretty shoddy - we have no carrier until at least 2020, and then (given about 1/3 of the time a carrier will be in refit, working up to effectiveness or in training) with only one carrier most of the time, which could easily be thousands of miles from where it was needed. Not great, that. I would ideally want to order another carrier. That's going to have a knock-on effect in terms of escorts (frigates and destroyers) to keep the carrier safe in combat, so we might need some more frigates and destroyers as well.
The trouble is, carriers aren't cheap - so without raising the budget much, where is the money going to come from? There's an easy start - scrap Trident and don't replace it. The UK doesn't need an independent nuclear deterrent; I cannot think of a single situation where it would be used where French or American missiles would not be following pretty shortly, if they hadn't arrived first. If you're worried about the UK's "seat at the top table" of world relations, I think that having the second largest and most capable carrier fleet in the world should be enough to ensure that. And budget-wise it saves on the nuclear missiles, the submarines which carry them, and the cost of designing and building a new generation of submarines and missiles.
The Fleet Air Arm is going to have to grow to give three carrier air wings; however, at least some of that growth could be shared with the RAF (train RAF pilots to land on a carrier and you're away...). As for the Marines, I think that their size is appropriate at present, as long as the Army is big enough to fill in behind them if necessary.

British Army

Speaking of the Army, they currently have:
2 Armoured Brigades making up 1st Armoured Division; 3 Mechanised Brigades making up 3rd Mechanised Division, and 16 Air Assault Brigade.
Armoured Brigades are the heavy fist of conventional war-fighting. A mixture of tanks and personnel carriers with supporting artillery and engineers; additional support units come in at the Divisional level. Armoured forces last really saw use in Iraq War part two - before that, Iraq War part one, and before that....probably Korea. They're logistically intensive, expensive beasts.
Mechanised Brigades are still fairly heavy - they're infantry operating from lightly armoured vehicles, still have some tanks attached in support, and also have artillery and engineers attached. Mechanised battalions, at least, can operate in contexts like Afghanistan, though Brigades with their supporting units are still a heavy logistical load.
Light Brigades - currently only one exists, comprising 5 battalions of light infantry, supported by light artillery (equipped with L118 guns which are helicopter-portable) and helicopters.
In terms of capabilities, 3 Commando Brigade (the Royal Marines plus some support units from the Army) are effectively another Light Brigade.
It seems important to retain an Armoured capability, though at present it isn't much used, and keeping any less than a Brigade is probably not worth the bother; that's at least one of the current Armoured Brigades required. As for the other, while I would consider converting an Armoured Brigade into a Mechanised Brigade, that's a fairly similar force structure with lighter vehicles. So it might well be worth retaining the two Armoured Brigades, at least in the medium term. My inclination would be to convert an Armoured Brigade to Mechanised next time their vehicles need replacing.
Call it two Mechanised Brigades (enough for a small Mechanised Division, or combined with the Armoured Brigades, one big heavy Armoured Division); the third current Mechanised Brigade can convert to a Light Brigade.
That would leave two Army Light Brigades and one Royal Marine Light Brigade, and the capability to deploy up to about one Mech/Armoured and one Light Brigade for extended periods - deploying formed units for more than about 1 year in 3 is excessive and puts a lot of strain on soldiers and their families.
Ideally I'd like to add a Light Brigade to ease the strain of deployments but I'm not sure what the costs of that are likely to be.
All of this is based around Regular Forces; the TA should be at a minimum maintained at its current size, and ideally expanded, again so that extended deployments place less stress on the lives of TA members outside the Army; with a side point of trying to maintain the Army's links to a wider population for whom military life grows ever more distant.

Royal Air Force


The Air Force has a few primary roles - Air Superiority, Tactical Strike, Transport, Maritime Patrol.The Air Superiority role is covered for the foreseeable future by the Eurofighter; Tactical Strike is currently covered by Apache helicopters (actually operated by the Army Air Corps) and Tornado fast jets, but Tornado is slated to be replaced by F35 Strike Fighters. Despite delays and problems with the F-35 program, this is probably a good thing as long as the strike aircraft for the Navy's carriers are going to be F-35s, for commonality of training and parts. If that decision needs revisiting then the RAF should probably also be looking elsewhere for strike aircraft. The F-35 certainly is costly and slow in coming, but I don't know enough about alternatives to know whether it is the best option currently available.
Tankers and transports are already in the process of being replaced - Airbus aircraft mostly, which is fine.
Maritime Patrol is the real gap in the capabilities since the Nimrod was retired; probably buy something adequate off the shelf; other nations must have an adequate Maritime Patrol Aircraft in place at the moment, and if not the Americans at least must be working on something. We probably don't need more than one squadron, so developing a British aircraft for that one is a tad excessive.

And that's enough on Defence; already quite long, so expect separate posts for the Home Office and the Department of Justice to follow.

2013/04/05

The role and purpose of Government

Not to get too ambitious or anything; I mean this is something people have been arguing over for generations, and major philosophers have disagreed fundamentally over it. (In ancient times, Plato's Republic; for an early grounding, Locke and Hobbes are pretty good; later Rousseau is interestingly wrong; Marx, obviously, and not to forget Jeremy Bentham, and that's the Twitter-length list).
So, I'll knock this off in a blog post and then I can get on to the difficult stuff...

Governments rule by the consent of the governed. In the case of a dictatorship, it can be a sort of sullen consent in that the people are not yet in open rebellion; in the case of a democracy the continuation of government requires a more active consent in the form of voting for them from time to time.

While I'm highly dubious of his State of Nature, I think Locke basically has it right that in agreeing to form a government over us, we give up certain rights, in return for having protection from other people.
So the primary responsibility of government is protecting its citizens, and this develops in three directions:
First, the citizenry as a whole must be protected from external threats, this heading broadly covering our Ministry of Defence, GCHQ and the SIS (better known as MI6).
Secondly, the citizenry must be protected from one another; this covers the Home Office and the Ministry of Justice, aka the police, courts, prisons and so on.
Thirdly, the citizenry must be protected from the government. Understandably, this is difficult for the government to handle itself, and is probably best dealt with by means of a free press and an independent judiciary in combination with regular elections.

That's all well and good. However, the government of the UK does a lot more than this. The Government budget for 2010-2011 ran to almost £700 billion, of which the Armed Forces, Intelligence Services and Criminal Justice system required around 8.5%.
So, what's the other 90-odd%, and why is the government responsible for it?

You know, when I phrase it like that, it sounds a bit libertarian - the idea that we are all responsible for ourselves, and that if something is worth doing then those who are affected will get together to do it without needing the government to force them. Without wishing to misrepresent the libertarian point of view, it summarises to the idea that government should secure the borders, enforce law and order, and otherwise stay out and let individuals get on with it.
It's an appealing perspective - who doesn't want to be free to make their own decisions? And there are several ways to deal with this libertarian critique of government action; I am going to take a less usual one, which riffs shamelessly on discussions of subsidiarity that I have seen on Fred Clark's blog.
Subsidiarity is a term from theology, but it is neither solely nor necessarily a Christian concept. It is the idea that as a human being, you are responsible for everyone and everything around you; but that you are responsible to a greater or lesser extent, depending upon your proximity to the problem, your ability to be of assistance, and so on.
This meshes well with moral intuition - mine, at least - consider the case where you walk down the edge of a lake and see a child drowning. It is your responsibility to do something to save that child, even if you have never seen that child before and will never see them again. If you are a strong swimmer and there is no-one else around, it is on you to swim out and save the child. If you're in a wheelchair, your responsibility would be rather to look for a life belt to throw, or for someone who is able to swim out; if you come by and the child's parent is already swimming out to save them you should perhaps just keep an eye to make sure they get back to shore okay. Universal responsibility, modified by proximity, personal circumstance, capability.
What does that translate to on a national level? Well, if there is a consistent problem of old people living in misery despite their own savings and everything that families and local communities can do, maybe the government should run a pension scheme. If there is a problem of poor people being unable to access healthcare, there might be a good case for providing healthcare free at the point of delivery. If you need to plan a transport network on a national level, perhaps the national government should be the one to co-ordinate it. If someone can work hard at a full-time job and not earn enough to survive, perhaps the government should enforce a minimum wage.
If you become aware that a growing economy requires a well-educated workforce, (or that a flourishing civil society requires an educated population; or indeed that an effective democratic government requires a well-informed citizenry) then you might see a need for free schooling.
In fact, if you look at the history of public services in this country, all the big ones come from just this sort of process - a recognition that all other solutions had failed, and thus a campaign for the government to step in as the provider of last resort. Specific examples include:
The campaign for the old age pension.
The foundation of School Boards for universal primary education.
 I'm open to argument on whether particular individual services are necessary, but the sweeping libertarian critique of government-in-general fails on both practical and moral grounds.

To summarise:
Government is the guarantor of security from threats abroad and law and order at home; it is also the provider of services too big for any other actor, and generally the "x" of last resort, where "x" can be "parent" (the care system), "lender" (as seen in the case of Northern Rock), "beneficiary" (for those who have neither a will nor close relatives), or a variety of other roles that may be required from time to time.

Next up will be a consideration of the first role of government - security. That will probably get too big for one post, so I might break it down by department - first Defence, then Home, then Justice, thinking about what the current situation is, and how it could be improved. All constructive input is welcome.

Part of the Manifesto series.

Manifesto Project

So, I was reminded I kinda like this blogging thing; and I've had an idea bubbling around in my brain for a while.

Politics is a rum old game; you vote for an individual because they're a good candidate (or you like his tie, or because her party is the one your parents voted for, or whatever), and then at the end of the election we get a new government based on the emergent combination of the results of 600-odd local contests, and most people switch off politics for the next five years.

There are good and bad points to the way the political system runs at present, but that's not quite what I'm focussing on here. What I'm interested in is this: what are the policies I would like to see a candidate, or a party, standing for? If they had no coalition of support to build, no special interests to appease, what should a would-be government plan to do?
And can I get other people to stick their oars in? I mean, I'm a generalist, and I like to think I'm pretty well informed, but there are bound to be consequences to my suggestions that escape me.
I aim to make this a series of posts over the next couple of (few?) weeks, gradually exploring more areas of public policy and government action. This might just help me to bring some order to my own thoughts; hopefully it will be of interest and/or use to other people.

All posts will be linked to here:

Role and Purpose of Government

Security I - Defence

Security II - Home Office

Security III - Ministry of Justice


The first one should go up later today, and will be starting with the basics: in broad brush-strokes, what is the purpose of government, and thus what is its role in national life?

2013/04/04

What is the purpose of marriage

As part of Forward Thinking: A Values Development Project I have been following both Libby Anne at Love, Joy, Feminism and Daniel Fincke at Camels With Hammers as they curate conversations on values development.
I've had an inclination to stick my oar in on several of the previous questions, but my thoughts have remained sufficiently abbreviated to fit as comments on the original post.
The latest prompt though, I had a few thoughts. More than a few, in fact, because it strikes fairly close to my heart. The question is "What is the purpose of marriage?"; having been married for most of a year and spent some time before that preparing for and considering marriage, my personal interest should be obvious.

I could go on and on about my marriage; about how our relationship functions...but that's not the key point. Not only is our relationship, like all relationships, idiosyncratic but equally most of our day to day interactions could just as easily take place between boyfriend and girlfriend as between husband and wife. I need to look at a slightly higher level to see where the differences come in.

I'm going to start with a few things that marriage is not, before going on to lay out what I think it is; I feel that setting a few boundaries is useful, especially when dealing with terms as loaded as marriage.
For one thing, marriage is not religious. Religious people can get married, and they're welcome to involve their religion in their wedding or even their marriage as a whole, but they don't own marriage. I have repeatedly seen it suggested that we ought to end the current fights going on over marriage by giving up - granting control of marriage to religious groups, and offering the legal benefits of marriage as civil unions or civil partnerships to everyone. This is nonsense. The whole point of fighting over marriage is that it has both a legal and a social meaning, and divorcing (!) the two would be difficult and somewhat pointless. In England and Wales there has been civil marriage available since the Marriage Act 1836. We have the best part of two centuries of experience of this now, and I'm not entirely clear on why that should change just to appease the minority of people who really hate the idea of two men marrying one another.
Besides, I will be damned if I permit anyone to boil down marriage into "God says you can have sex now."
Breathe
What else is marriage not? Well, it isn't necessary. It isn't something everyone will do at some stage - and nor should it be. You don't have to get married to have kids together (either naturally or by adoption and fostering). You don't have to get married to live together. You certainly don't have to get married to have sex! Making it obligatory devalues the commitment of marriage, by re-fashioning it into a hoop you've got to jump through on your way somewhere else. Again, if some people want to wait to get married before moving in together, why not? As long as they're not trying to make it expected for everyone to do that.
Marriage is also not just about the wedding; this is something that I became aware of because my wife spent some time frequenting wedding forums in the build-up to our own wedding. A marriage isn't a one day thing that only affects the rest of your life because you've got a ring to wear and a nice photo album. How much more trivially can you treat a commitment?
And another thing - admittedly linked to the religious thing, but they probably are distinct - marriage isn't about child-rearing. A couple without children are just as married as one with a dozen. You don't become more married on the day each child is born.

Alright, that's probably enough on what marriage isn't; now what is it? It isn't about the children; it isn't about the wedding, it isn't necessary, and it isn't about god.
Logically enough, I asked my wife, who said that she would define marriage for a child thus:
"Marriage is a legal contract by which two people who love each other become family."
Definitely a good start. It has limitations, but so would any one sentence definition of something important.
I think what distinguishes a marriage from a serious, long-term relationship is that getting married makes an explicit statement that you intend to be together for life; that the two of you are family and wish to be recognised as such; that you are entwining the courses of your lives together to the extent that it will be difficult and messy to separate them.
At this point I think it is important to note that I stated "intend". People make mistakes, people change, and life can really spin you for a loop sometimes. Being able to end a bad marriage with a divorce is hugely important, and asking which partner in a relationship is at fault for its failure can be invidious. However, I feel that you shouldn't enter into a marriage unless you think your relationship is going to last for a lifetime. This is one place where emphasising my point that marriage is not necessary is important. You might not meet someone you really want to spend the rest of your life with until you're 60; you might never do so; that should not shut you off from many other things you might be ready to do but which traditionally are bound up with marriage. The more carefully chosen marriage is, the more likely it is to actually last a lifetime.

Getting married is one of the most significant decisions that you can make in your life. We only get so much time in life, and declaring that you wish to bind yourself to someone for all the time that you have is huge. Family is significant, and bringing someone into your family, joining theirs, and binding the two together is another big deal.
Declaring to your family and friends that you intend to, expect to, and will work your arse off in order to be with this person for life is a massive commitment, in my mind second only to bringing a child into the world.
And then add in all the legal aspects to it, the time and expense devoted to getting married in the first place (well, you can have a quicky Registry Office wedding for £100 or so, but most people don't want to do it that way...) and you begin to get a sense of how much of a big thing it is to get married.

Do you want to tell me again that I should just have a civil union?

2012/05/08

Udacity timings

So, the three Udacity courses that I'm doing at the moment:

1) CS101 - the introductory course, aka "How to Build a Search Engine"
2) CS212 - "Design of Computer Programs"
3) CS262 - "Programming Languages"

Are all currently on week 4 of 7. Which means Week 5 will start on the 14th; Week 6 will start on the 21st, and Week 7 will start on the 28th.
And whaddaya know, I'm getting married during Week 5, on honeymoon throughout Week 6, and getting back just in time to catch up on a week and a half of material and then do the assessments.

On the bright side, CS101 is fairly simple - as an introductory course - and because the course matter hasn't changed since it was last run I can access all of the lessons now. So I'm finished with CS101, and I'll just need to refresh my memory a bit before doing the assessment/exam/whatever.
CS212 is okay - the concepts aren't generally that complex, but some of the application does get pretty tricky, because it's trying to teach habits of thought and rules of thumb, more than specific methods. A sort of "do I really want a hammer for this job, or a spanner?" At least, that's my impression; equally, it assumes a fair bit of knowledge that you can get from other students on the forum, or from other websites etc in order to focus on what he really wants to get across. As such it's quite rewarding, but more of a time commitment than it might have been.
CS262, is cool. Like CS101 it takes a big, ambitious-sounding aim - in this case "Write your own web browser" - and yes, this means that by the time I am finished I will have written my own Google and my own Firefox XD - and gets you there through the course of seven weeks. There is some commonality of material with CS212, which is all to the good. For example, CS212 introduced Regular Expressions, then sort of assumed that you knew how they worked; which I did, because I'd been slightly more comprehensively introduced to them by CS262!

Well, at the end of the day I work best under pressure - so I guess it's all to the good that it's fallen out this way, because I'll have a crunch around when I finish the courses, and then get back to the original point of this - my app!

2012/04/28

7 card hands

Further to what I discussed here, interestingly enough one of the pieces of work in the Udacity course CS212 is to write a function to find the best hand of five cards in a group of 7.

So I've still got the problem of dealing out the flop (cards on the table) as well as the hands for each of the players, but I can come back to that, this is a 'killing two birds with one stone' moment.

Now, out of seven cards, let's call them C1-C7 (or C0-C6 if you prefer), how many different hands could I have?
Hmmm. Well, out of my set of 7, I can discard any two; and working through the sets 1-2, 1-3, etc up to 6-7, I can get 21 different sets; leaving me with, conversely, 21 sets of 5.

Remembering good coding practices, however, we want to generalise. So rather than doing something like:

for i in 21:
    hand = [1, 2, 3, 4, 5, 6, 7] - discard[i]

where discard = [(1,2), (1,3)...]

Actually, hang on - maybe that isn't so bad. As long as discard is generated by a function which is more general, discard itself can be fixed values.
To explain what I'm talking about here, discard takes the form of a list, with each item on the list being the two cards to discard, leaving a five-card hand.
It is possible to have a program where discard is 'hard-coded', meaning that my code literally says:
discard = [(1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (2,3), (2,4), (2,5), (2,6), (2,7), (3,4), (3,5), (3,6), (3,7), (4,5), (4,6), (4,7), (5,6), (5,7), (6,7)]
Now that has three problems with it:
1) it's ugly. Yes, this matters!
2) it's error prone - what if I mis-typed one of those options? A hand will appear twice, or not appear at all. What is more, this means that this scales poorly - or in other words, if I had to do this for sets of 100, it's massively more difficult.
3) it's hard to adjust.
Having all that data hidden away in discard is fine.
In fact, I think it will be clearer if I generate discard elsewhere and then just refer to it here.

Right, enough messing about. I decided that Python must have a way of handling what I want to do; so I did some research and found: this Python documentation of something called itertools - or methods for achieving things which require a lot of iteration.
Specifically something called combinations. Combinations("ABC", 2) would give AB AC BC - perfect!
No need to mess about with what I was talking about with discard as a first step, I've jumped to having all the possible 5-card hands output from a 7-card input.
Now what I need to do is rank the 5-card hands against each other - well, all I need is to run hand_rank (a function already written as part of the Udacity material) - and it's job done.
So after all that, the result looks like this:
def best_hand(hand):
    "From a 7-card hand, return the best 5 card hand."
    hands = itertools.combinations(hand,5)
    return max(hands, key=hand_rank)
Back to the problem of dealing.

2012/04/26

Poker? Poke 'er!

Having mostly completed CS 101 (Introduction to Computer Science, aka Build a Search Engine), which was awesome, I just need to wait for a final exam to come out.

So I have moved on to looking at CS 212 (Design of Computer Programs), which has so far focussed on a program to judge winning poker hands, with an added bonus of a procedure to deal the hands. And here I hit a problem, because that procedure is:

def deal(numhands, n = 5, deck = [r+s for r in '23456789TJQKA' for s in 'SHDC']):
"Shuffle the deck and deal out numhands n-card hands"
random.shuffle(deck)
return [deck[n*i:n*(i+1)] for i in range(numhands)]
Just to explain what's going on here:
First it defines (def) a function called 'deal'. Deal can take as inputs the number of hands to deal (numhands), the number of cards per hand (n), and the definition of the pack of cards (where r is the card values, and s is the suits).
Then there's a bit of a description of the function, before shuffling the pack randomly.
Finally the idea is to return an output where:
we get a number of hands (numhands), each containing n cards, by counting out the first n cards, then the next n cards, until the hands are complete.

This is okay for a whole bunch of card games; in fact, considering poker it would work for Five-card Stud, which may be what was intended. But what I've always played is Texas Hold'Em, which has a different structure.
For anyone who hasn't had the pleasure of playing Hold'Em, the basic structure is that each player receives two cards in their own hand, and there are then five cards dealt face up on the table. Each player makes their best hand of five.

So I've tried to put together a function to do that job:
def deal(numhands, n=2, face=5, deck=[r+s for r in '23456789TJQKA' for s in 'SHDC']):
    random.shuffle(deck)
    hands_out = deck[0:face] + deck[(n*i+face):(n*(i+1)+face)] for i in range(numhands)]
    return hands_out

which unfortunately...doesn't work.
I believe the logic is sound; I'm just getting some part of the syntax wrong. I'll come back to it; once this works, I will also have to make an additional function to work out the best hand of five cards from the seven available to each player, and the rest of the code should then follow.

2012/04/20

The reason for my absence

I have been having far, far too much fun diving right into the courses at Udacity. I will raise one caveat - the instruction is very Youtube-heavy, so if your Internet is slow the experience could be somewhat frustrating.

That said, the instruction is engaging; the pace is good, and the diversions entertaining. I have also greatly appreciated the fact that you generally only sit watching/listening for a couple of minutes before you are asked to once more engage brain and do something.

Having initially focussed on the introductory course, because all the material for it is accessible now, I already feel that I have a reasonable grasp of Python.
Incidentally, as well as teaching me a wholly new programming language (shiny!), I've had a refresher on some of the principles of Object Oriented Programming, which is handy
Give it another couple of days working at it, and I expect that I will have achieved the initial promise, of writing a search engine.
Yes, that's right, using Udacity, Python and a few days of my time, I too can create a Google! Cue maniacal laughter.


Oh - and one last thing - it isn't too late to sign up!

2012/04/13

Sire, there is no royal road to learning*

I talk a lot about the frustrations of learning to program; there are a number of reasons why there may be more than the bare minimum going on here, but there is always some frustration in programming.

So today I thought I'd share some alternative routes to getting into programming, other than this somewhat foolhardy "Dive right in and use the Internet!" approach which I've taken.
First off, there are real live courses at actual Universities, or FE Colleges near you. However, costs can be prohibitive, and a lot of the time you need to be in a classroom, so working it around a job isn't exactly practical.
So we move on to distance learning. Well, there's always the Open University; but their costs can still be substantial.
There are also books like Dummies Guide to... or a similar idea for Android specifically. I learned a bit about Visual Basic for Microsoft Excel from a tome that seemed big enough to be the Liber Paginarum Fulvarum**, though I got more from diving into already-written software and then referring to the book when in trouble than from working through it in any systematic way.
Moving right along, there are also respected academic institutions who have some or all of their courses available online. That could be very handy, but there's no interaction, so it might not be much more rewarding than a book or similar.

There's also a Wiki-based solution and other similar efforts out there; and for anyone who has a grasp of the basics but wants to get into more real problems, there is the excellent OpenHatch, set up to prepare people for getting involved in Open Source projects.

Finally, there is the one that I am trying at the moment, which I discovered through an excellent blog I read called Unequally Yoked; Leah who blogs there has recently been taking courses including How to Build A Search Engine over at Udacity and recommended it highly. The next round of classes is starting on Monday (the 16th April) so if you want to have a crack at it, come join the party!
Because I have previous programming experience but no knowledge of Python, I've gone for How To Build a Search Engine (which is an introductory class), Programming Languages and also Designing Computer Programs.
For the inexperienced I'd advise starting with How to Build a Search Engine and leaving it at that. I may find that three at once is a tad ambitious, but I had to resist the temptation to sign up for all six, so I think I'm doing well!

*Slight misquote of Euclid, speaking to Ptolemy "Sire, there is no royal road to geometry"; the meaning remains - if you want to learn something useful, expect it to take a while. Viz the 10,000 hour rule.
**by Achmed The I-Just-Get-These-Headaches

2012/04/12

2012/04/11

Testing Test...

Spent much of the day going around and around and around in circles. The word is argh.

I begin to wonder whether I should try condensing the app into one view for now, then trying to figure out how to add a second view separately...might be a way to separate out the issues enough to attack them productively.

2012/04/10

Source Not Found

I haven't yet found any useful suggestions on dealing with Source Not Found; so, I'm going to take some stabs in the dark and see if any of them result in a scream.

First off, I know that I have said that the warnings aren't that important, as long as there aren't any actual errors. How about I just test that; I comment out the unnecessary import statements [a simple /* on one side and */ on the other does the trick. Alternatively for single lines // works.]

Commenting in this way is a great method to quickly change code around - because if I decide that removing something was a mistake, I just have to uncomment it, not remember how it went and re-type it.

Then the remaining warning is around
private DatePickerDialog.OnDateSetListener mDatePicked;
and how I use it in
mDatePicked = new DatePickerDialog.OnDateSetListener() {
In that Eclipse is telling me that mDatePicked is not used! Um, oops...what's gone wrong here then? I declare mDatePicked, as you see above, then I do some stuff onDateSet.
Now, I have a sneaking suspicion that there's some duplication between these two lines, so let's see what happens if I take one out, leaving
mDatePicked {
 Nope, that errors. Badly. Howabout taking out the first one? Also makes things worse, in that the warning has upgraded to an error.
Aha! Stack Overflow to the rescue! Looks like the whole thing is redundant now I've got
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
So I'll just try cutting out the lot, see what I get. No...that causes even more problems. I'm going around in circles here. I believe the technical term is GAH!

2012/04/09

Testing, Testing, 1-2-1-2

To test an app, first thing you need is for Eclipse to not report any errors.

Then you need to feel that there is enough of your app complete to be worth testing. For instance, I don't really-truly care about whether the home screen looks right, if all I can do is look at it. I want to know whether it works when I press buttons.

Then you Save All (Ctrl+Shift+S), and finally you go to the green and white Button for "Run Wedding Logistics".

Having already specified a test machine (in my case using the specs for my own Android phone), it should just load up. Be aware though, this step can be veeeery slow.
And...ah. Oh dear:
Well, at least you can see what Toast looks like! As well, of course, as the appearance of the testing software [which is included in Eclipse].

It does occur to me that most programming I've done will talk about de-bugging, and this seemed to be more of a 'run program' option. Hmmm. *Looks around* Aha!
I clicked on this:
I should have gone for this:
The Debug button. Debugging is one of those terms that is more literal than you think - while the origins are obscure, it was popularised in the days of the first computers, vast buildings full of valves such as Colossus or ENIAC. - when it was possible for a bug like a moth to get into the works and cause the machine to behave in unexpected ways. The archetypal bug is pictured here.

I believe my error is linked to the fact that the tutorials from hackaday were with already completed and tested code - so the bit of seeing it work at the end was just the reward. Anyway, now I hit Debug, so I'll see what pops out:
Source not found.
Ah. I have no idea. Will have to come back to this once I've done some more reading.

2012/04/07

Index Post up to Saturday 5th April

For convenience:

I began by introducing myself; the software that I am using; and my first decisions in the design process.

I then made a start on this project, working on a design in DroidDraw; before moving my work into Eclipse, then getting bogged down for several posts as I worked out how to solve a niggling little problem.

That got me up to last weekend, when I disappeared on my stag do, and came back a little hungover; bringing me into this week.

This week I began with switching between the two activities which currently make up the app; fun with onClickListeners, then made some slow progress which culminates in a couple of finishing touches.

Next week we go on to testing.

Finishing touches

As I said last time, I reckon there are two things left to do before I have a module that is worth testing.

First - I want to notify the user when a date is entered successfully. Now, this is not essential in the grand scheme of things, because when the whole app is complete, closing SSA will lead the user to a screen which shows the date (among other things). Whether or not I decide to retain it then, I want to have it now, just so that I know it's working when I test it!

The easiest way to do that is with what is called Toast - I imagine because when it is ready, it pops up! Toast is a kind of message that appears in a little box floating on the screen for a set duration.
Toast has three key components (or 'arguments', in this instance). The Context, being the current state of the application; the Text, being what you want your Toast to display; and the Duration, being how long to display it for.

As usual with Android's imaginative variable names, we get something like this:

Context context = getApplicationContext();
        CharSequence text = "You are getting married on " + WedDate "!";
        int duration = Toast.LENGTH_LONG;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
As you can see, here we will tell people "You are getting married on []!", for a duration of Toast.LENGTH_LONG. I don't know exactly how long that is, but it's a few seconds; certainly long enough to read this message.

Alright, so on to the second thing I wanted to add - and this is probably entirely temporary: a message on WLA to confirm that the app knows the user's wedding date.
I've put exactly the same Toast, just replacing "You are getting married on " with "Your wedding date is ", so that if I close SSA and get back to WLA at the same time as a Toast appears, I will know which Activity is responsible for it.

In both these cases, I already had the import statement - import android.widget.Toast - otherwise I would have to add it before Eclipse would be happy.

Now, bearing in mind that 1) This is one small corner of the planned app, and 2) That it may not even begin to work when tested - it's time to start testing this thing, and see what breaks!

2012/04/05

Slow Improvement

Aha! It gets better - I have not only discovered that it is possible to make the calendar appear, not just the day/month/year spinners; I have also discovered a method called onDateSetListener. I've even found out how to make a value (like "Yes, a date has been picked") persist from one session to the next.

The calendar thing I'm going to just make note of for now - remembering as I said back here that as long as it works, prettiness comes later.

The method onDateSetListener might explain some of the problems I've had with onClickSetListener - it wasn't quite the right method for what I was doing. I'll try replacing it based on what I've found at the Android Developers' forum and Stack Overflow.

So from
WeddingDate = (DatePicker)findViewById(R.id.datepicker
WeddingDate.setOnClickListener(this);
I now have:
WeddingDate = (DatePicker)findViewById(R.id.datepicker);
        mDatePicked = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
I think that's progress, of a sort? At least, Eclipse isn't flagging any major errors, and I can put something into the method stub to cover the last point I mentioned up top - making sure that once a date is picked, the user doesn't have to do it again.

That's where this comes in. Now, the example given isn't quite right - it's for a setting that the user might change at any time, so the setting is re-saved every time the application closes. I want mine to save the setting solely when the user finishes with SSA - if they ever say they want to change the date, I'll get the app to just bring them back to SSA.

So, in WLA I have put
        SharedPreferences settings = getSharedPreferences(WedPrefs,0);
        String WedDate = settings.getString("WedDate", "");
which is aimed at getting together an object called "settings", which in addition to knowing the Wedding Date can also hold other information in future. I've picked my variable names and properties such that they match up with the if block I created here.
Coming back to SSA, where it said //TODO above, I've now got
SharedPreferences settings = getSharedPreferences(WedPrefs,0);
SharedPreferences.Editor editor = settings.edit();
WedDate = String.valueOf(year) + String.valueOf(monthOfYear) + String.valueOf(dayOfMonth);
editor.putString(WedDate);
This still isn't quite right - the string WedDate operates, and becomes year + monthOfYear + dayOfMonth [for example the 19th May 2012 would appear as 2012419* which I think is the easiest way to grab it back out afterwards] but then Eclipse isn't keen on editor.putString(WedDate); and I'm not sure why.

Well, I wasn't. I tried typing it again, and when the tips popped up:
I saw that the putString method requires two separate arguments.
By analogy with the method in WLA, the first argument has to be "WedDate".
Because of the name I've given in SSA, the second argument has to be WedDate. Fortunately one is in "" and the other is not, so that isn't confusing at all!
May want to change one of those names, I'll think about it.


In any case, this has taken a while, but I've nearly finished the initial stage. There are two immediate steps remaining - one, a message to inform the user whether the date is entered successfully, and two, something on the WLA to state whether a date already exists.
Then to build this into the full app, I'll need something to direct the app back from SSA to WLA - if I understand Android convention correctly, that will be automatic as long as I close down SSA correctly.
Then I can start testing it.

*2012419, you say? Yes. 2012 for the year; then Java counts months from 0 to 11, so in spite of being the fifth month May comes out as 4; then 19 for the 19th. I think that the month will show as 4, not 04...
Some systems counting from 0 and others from 1 is the reason for fence-post errors!