Tuesday, 3 July 2012

Equals or ==?

So Android is pretty ubiquitous now. New tablets/phones coming out with the version 4 upgrades and awesomeness. I personally love my Android phone. No, it's not expensive, but I love it!

However, this is where I get to moan. I have never really touched Java before Android came out. Some people swear by it, I swear at it! It's not that Java is an aweful language, in fact there are some really nice features. However, from a C# point of view it is somewhat like learning Polish after learning Russian.

You see the slavic languages are very similar. The have a similar verb conjugation and many similar verbs, and then you get to the important bit, the verb that is the difference between like and love and it lets you down and changes. (Russian love transliterated is "lubit" in Polish lubic is to like).

The same thing happened with Java. I'm feeling confidant in the fact that I can write code without looking up syntax just because it's SO similar to C#. So much so that when i evaluated two variables with a

     if(var1 == var2) { // Do Something... }

statement, saw in debugging that they had the same value I expected that the // Do Something... code would run. WRONG! Turns out that the == in Java is COMPLETELY different to C#!

"EEEJIT!" you say. "Java is a better and older language than C#"

"No need to be rude!" Say I "C/C++ is an even older an more widely known langauge than even Java"

So how do we get around this evilness? Why does this happen?

Java-Samples states : "the equals( ) method compares the characters inside a String object. The == operator compares two object references to see whether they refer to the same instance"

So the equals() method was what I needed. Tbh I had not been so dissapointed by a language inconsistancy since the lack of switch in python. I look forward to comments and suggestions (clean ones please) about what I'm missing in Java that makes it better than either C# and/or Python. 

Sunday, 20 May 2012

New Site and more soon

Well this is more of an update than a rambling. I have just finished putting together a new site for a client. It was fun to do although due to distance and for both of us this being an in between other work type of job, the site took longer than I am usually happy with.

The site is available at www.rosehouseherbalclinic.co.uk and as you can probably tell it is for a herbal clinic. The owners are friends of mine and their clinic is really nicely set out and they have all sorts of cool decorations and more importantly a deep knowledge of their craft.

The main tasks with the site were to get past my lack of horticultural knowledge. We chose a CMS so that the owners could blog for themselves and also change the content themselves, and this helped me to not have to blag as if I knew anything about herbal medicine.

The logo was done by an independant party, and excellent designer Chloe Miller. The choice of green  as the main color was partly chosen by the logo design but more by the nature of herbal medicine. In actual fact there were several logos done in numerous colors.

We have some more sites in the pipeline and underway. Look out for a builder's site, Jaqal couture and more...

Finally, a note as to why there have been fewer blog posts of late. We are house sitting and so I have had to use a laptop to do my work, which is HORRIBLE! I know that a lot of people use laptops and do great amounts of work on them, however, I am old-fashioned in my computer use and I find that the mouse tracker thingy is no where near sufficient for my comfort. On top of that, I am sharing the laptop with my wife who likes to spend money using it!

Tuesday, 8 May 2012

Ubuntu 12.04 First Thoughts and synergy fix.

As I am rather an impulsive sort of person I thought that I would give an opinion on Ubuntu 12.04 only a few days after upgrading my server machine. (Server as in I keep my important files that I share with other machines, not as in I server apache websites!)

So my first thought? Well I was really excited by the idea of the HUD - not just because it seems like a term from a gaming interface, but also because the idea means we can escape EVER bringing a space hogging ribbon bar over to ubuntu (result!!). However, to note that Libre office (a default Ubuntu app) does not support this beast makes me want to cry in my cornflakes. ;-( However, the dream is there for future releases.

So the next thing I looked at was the black background that it gave me? Why? I had used one of the default wallpapers in the previous release of Ubuntu. A lovely autumnal walkway reminiscent of a parisienne path. However, on the new update, my favorite wallpaper has sadly been extinguished! With no real replacement amongst the defaults (and the fear of losing it again next release) I decided to use a picture. At least that is easy in Ubuntu!

Now today, and the reason for sharing this article, I'd had enough of clicking ctrl, stopping synergy, starting synergy and then going through the whole process next time i need the ctrl, shift or alt keys. Apparently the latest version of Ubuntu is incompatible with the stable release of synergy.

Google to the rescue and it appears that the Beta is fine. So I installed direct from the website on the Linux machine. At this point it must be noted that I am a moron, especially as when I tried to run it I nearly threw the cat across the room (a plan foiled due only to a lack of feline in the flat) when it still did not work. Then the moment of eureka when I remembered that the Windows machine would most probably need updating too.

Now as updates to beta versions of products go, I am yet to find anything that I do not like and particularly on the Windows version of Synergy. User interface is easier than going deaf in a night club and I was back up and running in no time. What's more, the ctrl button works!!!

So, what do I think of Ubuntu 12.04? For me it has caused numerous, small headaches. However, I LOVE Ubuntu. I was talking to collegue in the office the other day who said that he could not wait to get home to work on Ubuntu again (the office is nearly all Windows 7/XP). He could not stop thinking about it! Whilst he might just be the saddest person I know, I share his sentiments about using Linux in general and the rush that it gives you. Furthermore, the user base and community (aside from bearded zealots) are superb and what's more, IT'S FREE!

So the big question is, will I ever do all of my work on Ubuntu? hmmmn, probably not anytime soon, C# is still mainly a Visual Studio beast, despite the advancements of Mono. Although, given time and incentive (this mainly means when Windows 8 is released and I can't take any more metro, ribbon bar in the explorer, which is by the way a complete break of Microsoft's own usage terms for the Ribbon bar and HUGE BUTTONS that are useless not on a mobile device after being hit with a hammer on the fingers.......) I might just move over to the lovely Linux for good. Here's to the future!

Tuesday, 1 May 2012

Android Programming - Yes I know it's Java!!

So this week has lead to me getting to that point in my interminable list of projects to do where I finally bit the bullet and started doing some development for Android.



The first thing that struck me with Android development is Java. I could not believe that I was being forced in to such an unusually bloated language for such a small device. However, I instinctively feel that the guys behind it must have a much better undestanding than me so, let them get on with it. The interesting thing is that it is not a standard JVM but rather runs on the Dalvik VM.

So I decided to go for the new kid on the block Intellij Idea as an IDE. I looked into the Eclipse, and didn't much like it. I installed and almost immediately went with Intellij and haven't looked back. I realize this is subjective, however, I don't care! ;-)

The second thing I learnt was that you need to have a kettle handy for the first time you run the emulator. Closely related is the fact that you never want to close the emulator until you are sure that you are done debugging. This is somewhat due to the fact that the time it takes for the emulator to load the first time is comparable to my grandmother crossing the road, walking up the stairs and putting a brew on for me!

But when you get past all of that, I was really impressed with the layout tools, the xml resources and how easy they were to use, the simple differences between activities, services and broadcast receivers and how they all fit together with the Java language. (it nearly turned me to Java for desktop apps but not quite!) Everything by default is well layed out in the various folders and I feel that I automatically know where I should look for changes to be made after only a day looking into it, and I am no master by any stretch.

A few more interesting features took my eye (and it is possible that these are IDE specific):

[1] Awesome debugging and logging in the Android tab
[2] Git support  (oh yes!!!!)
[3] The DDBM (Dalvik Debug Monitor) has Emulator control where you can call the phone. Great for the app I am writing and also for feeling that you have friends without having to talk to them on the phone!!
[4] Good support network. I can't belive that in the relatively short time that Android has been about, I can find someone else somewhere who has done, is trying to do, will do something that I am trying to do and documented it online (go to love Google for that). This is something that even Python and C# have not yet managed despite the slightly longer life they have led.

So all in all, I really like programming for the Android and would recommend it to anyone! Programming is fun again!! Actually it was always fun but now we have an emulator which means that debugging is more interesting for my long-suffering wife :-)

Monday, 9 April 2012

My Favorite Relational Database.




When I first started programming; I mean really programming and not just bashing websites together with HTML/CSS; I went through a huge amount of tutorials for c#. I found video tutorials a great way to learn how Visual Studio works, how to write code and how to connect to a database and show the data in a half decent way.

However, one thing I have noted with the trends in Microsoft technology is how they favor their own brands of tech over others (not surprisingly). This is ok, until it comes to relational databases! Every tutorial I went through was based on MSSQL or the compact version. Whilst I know their are jobs around for these technologies and they integrate with Visual Studio much better than anything else does at the moment; I hate MSSQL. Heres why...

One of the first ASP.NET sites that I programmed for a local company (that was stupidly simple in that it just showed workers for their business.) was a great testing ground for me to learn Linq. I so wanted to learn linq that I did the project using MSSQL as a back end. I had used it before and had nightmarish problems with deployment which I will not go in to here. (or to any one other than a psycologist. )

So I am all fired up for going into a linq2sql project and getting all the benefits of a DAL without writing it. Wahoo! However, the customer was almost immediately unhappy about certain fields that they had asked for and others that they wanted to add in. Therein lay the first problem. The changing of the database was SO slow, even (or especially) in VS. Then you have to update the DataContext which took an age!

After some time they outgrew the shared host that they had been given, and we got them set up on a Cloud server. I took the oppurtunity to change the database structure to PGSQL (which is pretty much the only RDBMS that i use now, aside from obligitory MySQL) and boom. The whole app ran like a song even on my local machine.

The next thing i noticed was the bloat of the server for MSSQL. I had a phone call from the client saying that there was an error when trying to upload a picture. I looked in to it and voila! the Harddrive was full. I thought, that's naff. There isn't that much on it. When, however, I uninstalled the now redundant MSSQL server, I had 2/3 of my hard drive back!!

So although this is only one brief chapter in my pathalogical hatred of MSSQL, I hope that it will warn young devs away from the evil that lurks behind every VS tutorial.

PS. I am now writing an app using MongoDB and I would highly recommend that as well as MVC as it is so nice not to be patronized (as much) by VS!

Monday, 2 April 2012

Safari Issues with FormsAuthentication

So today, one of the customer's that we have had noted that his browser (on the iPhone) was losing his login everytime he closed it. Whilst fighting the urge to make rude comments about his choice of browser/os/life, I decided to see where the issue lay today.

So the long and short of it is this: Safari loves to lose Session Data if it is not persisted. So the way we were forwarding from logon :

FormsAuthentication.RedirectFromLoginPage("Username", false);


Simply did not cut the mustard! We needed to rethink so we put:

FormsAuthentication.RedirectFromLoginPage("Username", true);



Weren't we awesome? Well, whilst this did fix the problem of Safari forgetting everything like your aunty noris, one of our devs came up with the great idea that maybe we should have an ebay-esque, "log me in all day" feature.

This required a little reading and the result was the idea from stack overflow (as most of my google searches seem to end).

Now we choose the timout (default of 30 mins) based on the user selection. Much better! One thing I did note was that the code will default to the timeout if left in the web.config, therefore, keep the tag but remove the timout (if there!) from the tag.


Now, as long as our users have cookies enabled (resist the matrix runs on xp quote) and you are away. Of course, there may be more elegant solutions, however, we got it working!

Sunday, 1 April 2012

Welcome to my blog

Hi all. This blog is going to be all about programming and other aspects of life that are touched by computer use. I am not a programming master and as such I often come across new things that I learn in my travels. As I do so I will share them here and you all can get involved too.

One thing that I feel passionate about in the sphere of programming is the place of Open source and community software. Therefore, if I produce a tool, library or other set of code that I think will be useful, I will definately share it on either sourceforge or github (or both if I am feeling energetic.)

Contact me for more information or for a full CV!