Monday 17 December 2012

Naming conventions that suck

I've been using C# for while now but I've spent most of my career to date using java in enterprise development. The naming conventions for java, the official ones from Sun that is, seem to be mostly logical and there is a well defined getter/setter access naming for beans that fits nicely I especially like that boolean member variables have a getter preceded by 'is' because it makes sense.

There is, or at least doesn't appear to be the same level of common sense with C# instead there seems to be a clinging on to the past. At least most people no longer put sz at the front of zero terminated strings or i in front of integers like back in the C/C++ days which lets face it were quite some time ago and things have moved on so get over it.

When I see code where interfaces are preceded by 'I' or member variables that are prefixed with '_' it makes the code look childish, it's what I'd expect an old school programmer/hacker from yester-year who has refused to expand their own understanding would do.

In the days of C the naming conventions were there because there were no clever IDE's so the quickest way to convey to the user what a variable was was to include something in the name which were generally kept short (I don't know but there may have been a limit on variable name length). The fact the conventions such as 'I' for interfaces and '_' for member variables is retained in a language that lets you define a variable as 'var' and let the compiler infer the type smacks of hypocrisy and those that follow it are simply refusing to grow beyond their limit understanding.

I for one am looking forward to the day that variable names contain spaces as the norm like they can in Groovy because it makes sense to be able to convey simply what the purpose for a variable is as it no longer matters how many characters are used in the name so be expressive.

A strange convention that I started using then found to be wonderful for allowing me to scan read code was to put a space after the opening parenthesis and a space before the closing parenthesis, it sounds odd but the little box that the parameters are now in really can be easy to spot whereas you can't quickly scan down code where there is no space because it seems harder for the brain (mine at least) to see the fact that the parameters are separate from the method name.

Just remembered another stupid convention used in C#, capital letters for methods and capital letters for properties. This seems like an opportunity missed since methods are usually verbs they'd fit nicely in the middle of a sentence whereas properties tend to be concepts or nouns that are more likely to be names therefore why not lowercase for methods and upper case for properties. Ok, so it's not that stupid I just prefer lower case methods as capital letters tend to stop the flow of my brain due to decades of teaching it that a full stop followed by a capital letter signifies the end of a section that the author deemed worthy of signifying.

Thursday 13 December 2012

Machines that learn

I wanted to design a machine that learns, always have ever since I saw wargames with Matthew Broderick. Trouble is it ain't easy. Humans are very good at seeing patterns and I wondered if this has anything to do with the ability to learn. Maybe if we see patterns we're able to apply previous experience to similar situations. On another note I was thinking that a tree of decisions where each node is itself a tree creating thing. This would tie in with the idea of CNN where there is a bias feedback loop between nodes. Ok so I am starting to like the idea that each node in a tree is itself a tree creating thinking machine, I like the idea that all this tree has knowledge of is what ever is below it i.e. its children and its childrens children e.t.c.

Sunday 18 November 2012

What to do?

I've got a load of ideas buzzing round my head at the moment so thought I'd slap them down on here so I'll be forced to actually see it through!

  1. I have a gps unit that works with the mtkbabel program, however it also has bluetooth connectivity that I've never used before. My plan is to write some j2me app that can use the bluetooth and this unit to give gps to my really old mobile phone.
  2. I want to make a javascript based drawing application that produces svg graphics, which I am only starting to play with but finding really cool.
  3. combine 1+2 so that the svg is a scaled image that the gps coordinates can be plotted on.
  4. make a good window switcher for windows 7 because all of the ones I've found so far suck donkey's balls.
  5. finish making my algebraic compression algorithm combining the fact the a rubicks cube can be put into millions (if not billions) of positions but you can get from any one to another with just 23 moves. Fractals can make infinitely complex patterns from relatively simple rules. the path from one piece of data to another can be plotted by some mathematical formula, I think genetic algorithms could be used to discover the best fit formula.
  6. I think I could take gpx and transform it to svg via some clever xslt, that'd be swish.
  7. fed up with there being no 100% standards compliant browser I've decided to make my own, however I've decided to make the entire thing a cluster of modules that can all be pulled out and replaced. This has a good side effect in that I want to describe the outcome of javascript programs as simple operations to be performed on the browser, these can be described as a series of simplistic commands much like idl or bytecode. This in turn means that no one is stuck with using javascript if they don't want to they can make a module that interprets whatever language they want into idl. Since the language will only effect the browser the sandbox will be the browser, plus a web page that uses a module that the user doesn't have can actually supply the module to the user and it will be automatically installed just for the browser. The other thing is that I like the pipeline model of IIS (and the chaining of command line apps in *Nix based machines) so I want the entire thing to be a cool little pipeline where each module effects the document as it flows through the pipe and is presented to the user :)
  8. make a world simulator, objects with gravity, collisions e.t.c. all with a view to simulating a clock mechanism and then make the mechanism a reality.

There are other things but these are the first few I can think of and want to get cracking on.

Monday 8 October 2012

Tree Searching

It has been a very long time since I've written anything on here, what with having a baby daughter to look after and spending most lunchtimes keeping fat at bay in the gym (yes I am aware it's 80% diet, trouble is I don't eat enough, post for another time.)

Anyway I have 10 minutes before the end of my lunch break and looking round my desk can see an interesting note on tree searching.

imagine you have a tree of

                  a
                 / \
                b   c
               /\   /\
              d e  f  g
             /\ /\ /\ /\
            h i jk lm n o
I know this diagram is messy but I have 10 minutes and don't want to leave the text editor yet.

Now image the way in which this structure is expressed is as a map for example

a: b, c

would mean a has children b and c, you could then have an algorithm that would expand the first (left most) item in a list and depending on whether the expansion is stored to the left or right would determine if we had a depth first or bredth first search. I remember when I first saw this idea back in the 90's when playing with Haskell (Hugs98 if anyone's interested) and thought it was cool.

lets expand and store at the front, this would give a depth first search, ooh one other thing to note, leaf nodes are sent to the back since there is nothing to expand on.

  1. a
  2. bc
  3. dec
  4. hiec
  5. iech
  6. echi
  7. jkchi
  8. kchij
  9. chijk
  10. fghijk
  11. lmghijk
  12. mghijkl
  13. ghijklm
  14. nohijklm
  15. ohijklmn
  16. hijklmno
now if we expand the nodes but store them at the back of the list
  1. a
  2. bc
  3. cde
  4. defg
  5. efghi
  6. fghijk
  7. ghijklm
  8. hijklmno
no more expansions as we've reached the depth, so in some pseudo code it could be

expand([x:xs]) => expand[x] : expand[xs]

expand([x:xs]) => expand[xs] : expand[x]

it looks so simple :)

anyway back to work.

Thursday 21 June 2012

Some cyclists are dickheads

A cyclist tried to play chicken with me, who was in a car, I kid you not! This is the sort of cyclist that gives the rest of us a bad name, here's how it played out. in a 40mph limit I am behind a van doing ~25-30mph obviously looking for an address or something, I see that in the distance on the other side of the road there is a cyclist but that is all for what looks like miles. I move out around the van approaching 40mph at which point I notice the cyclist is now moving towards the centre of the road, bit odd since he hasn't signaled that he's turning right any way I complete the overtake and move back over to the left and on the road in front of me the cyclist is shouting and pointing at his head like I did something wrong! I ride my bike a lot and I think it's because of arrogant pricks like this that some motorists cut me up, it's a sort of do before it's done to you response because they expect EVERY cyclist to do something crazy. What an arsehole!!

Friday 9 March 2012

Wandering mind

The human body is amazing, it tries to keep all parts operating optimally.  If one particular part is stretched to its limit the body will try to compensate in preparation for the future.
I have no real evidence from this other than observing people that go to the gym.  What I mean is someone who goes to the gym and stretches their arms to the limit for example by lifting heavy weights will generally see an increase in the size of their arms the more they do it.  I am starting to think that the same may be true of the brain, the more you use it the better it gets.
I take this one step further by saying that because I work a very sedentary job I have to exercise my muscles outside of work, and when I was a youngster working in a factory I used to have to exercise my brain outside of work by learning languages e.t.c.

I think this is a good practice and think that maybe not enough people do this kind of exercise, just a thought.

Wednesday 29 February 2012

Are we in a democracy?

Wikipedia defines democracy as;
Democracy is an egalitarian form of government in which all the citizens of a nation together determine public policy, the laws and the actions of their state, requiring that all citizens (meeting certain qualifications) have an equal opportunity to express their opinion.

This got me thinking about whether I live in a democratic country and according to this definition the answer has to be no.  I do not have an equal say in what happens, even the person that is supposed to represent me and my best interests isn't the person I voted to represent me, nor could I guarantee that they would have my best interests at heart.

Here's why
The things that are important to me and matter greatly to me don't effect most of the people who work in Westminster.  Most have never had the joy of getting electricity via a card that has to be topped up like a pay-as-you-go mobile, or had to make the choice between a new pair of shoes or filling the car with fuel.

I guess what I am trying to say is that the people in charge in Westminster have a different agenda, this is why there are new laws past to protect the already rich with lower inheritance tax and stamp duty e.t.c. and yet they can vote to close libraries and hospitals and post offices because there is another one only 10 miles up the road.  This is fine if you drive and can pay for the fuel as the politicians obviously can but for those that can't it may as well be a million miles up the road.

I recently read an interesting article in Dodgem Logic#2 (I know there are now 8 issues I am trying to catch up) that suggested a random selection of the real public should be chosen to govern for a limited time only before swapping, the reasoning is that the decision making politicians would be more inclined to make decisions that are beneficial to the general public as they would soon be rejoining the general public.  The only bad point in the article was that it held up Greece as the shining light of this principle and frankly the Greek government balls the whole lot up!  The article did raise the point that anarchy isn't a bad word, it simply means without leaders, i.e. everyone is seen as an equal.  This sounds a bit like the foundations of Marxism/communism, I know they are different but no one has succeeded in explaining the subtle differences to me yet so I view them as synonymous with each other and anyone who has read Animal Farm (George Orwell, not the porno) will immediately think "...but some are more equal than others".  There in lies the rub, it takes a great deal of self control to not want to post yourself as the leader, is it human nature, can it be avoided or are we doomed to always be a people led rather than equals?

My Utopia
My idea of a utopian land would be one in which everyone was free to think/do/say and learn whatever it is they wish to as long as it didn't interfere with someone else.  I think this was the general idea behind 1930's pursuit of happiness but I am not sure.  Anyway it would be nice if the goal of every human was to better themselves for humanity rather than the acquisition of wealth or power (vaguely remember Capt. Picard saying something similar).  It does sound a little far fetched at the moment, but doesn't it also sound good, and something worth aspiring to.  I sure as hell think so which is why I view a day in which I haven't learnt something as a day to regret and I don't want to live a life full of regret, who does?

Saturday 7 January 2012

An Idea I am toying with
While I wait for some photos to upload to Google+ I thought I'd jot down an idea that I've been playing with for some time now.  But first, don't you think it's great that Google+ lets you upload full resolution pictures, it makes for a wonderful offsite backup facility!

Back to my idea;
For a long time I have worked with people that all have their own views on the way in which code should be formatted, these formatting styles only effect the way the code is viewed and have no effect on the way the code functions because white space is ignored in the languages I have used in industry unlike python which is undoubtedly a good language IMO.
The way I decided to solve this problem was to store metadata along with the code, basically a program sits between the developers IDE and cvs that alters the code the developer writes and stores it in cvs as XML the view of the code is then determined via some xslt that the developer has decided upon.

I extrapolated this idea along the inevitable evolution and decided that by being able to apply metadata to classes, methods even code blocks, if cases e.t.c. I could get the vm that was going to run the code to use this extra information to decide how to priorities the calculations in order to make concurrent programming far simpler.


I'll keep you posted on how it goes this entry was just so that I am forced to make a start on an idea I've had for a good few years now!!! How time gets away from you and these ideas never come to fruition, just like the energy generating compost heap idea I had when I was 12, I still hold out hope for that some day :)


 
Stack Overflow profile for Richard Johnson at Stack Overflow, Q&A for professional and enthusiast programmers