Why Java Sucks

http://2014.javazone.no/videos.htmlAn ex colleague of mine sent me this link this morning. www.whyjavasucks.com
Apparently I got associated with it, haha, yes at one time I used to shoot down java at every occurrence, this was most likely because I didn’t know it well enough at the time; now I just yawn a little and continue ;-)

Programming in C# after using Java

image

Enjoy the website! I did ;-)


To see the other side of the story have a look at some of the videos here

IDE’s and tools

I’ve gotten a few emails from last night’s post asking me why I’ve gone black (and will i go back?),, well you know what they say!

Btw: I’ve Visual Studio, IntelliJ and WebsStorm on black/dracula themes at the moment and a week on I’m kinda sold, the only big downside is when I switch to another app when in dark light (in bed for example) I hurt my eyes as they adjust.

Some people asked about the IDE as it wasn’t visual studio (nope, I’ve not written java in VS yet ;-) ) so I thought it would be interesting to share what tools and IDE’s I use.

As it happens I just rebuilt my OS last weekend so it’s all clear in my head, here goes:

Operating systems:

Windows 8.1 and Mac OS as the moment, I prefer Windows, but my Mac Book Air is by far my favourite hardware… conflict!! I am doing a project with a Raspberry Pi at the moment and between that and the Mac I’ve pretty much given up on DOS* in favour of powershell (simply because I can type linux commands)

IDE

  1. Visual Studio 2013 this is my favourite IDE, I’ve been using VS since the mid 90ies, mostly these days I use VS for C#, ASP, UML, Testing, Azure, most of my pet projects are Azure based.
  2. InetlliJ : I took me a while when I started learning Java to settle on IntelliJ, I went back and forth between that and eclipse for a while until I understood java and it’s eco system enough to set up my own projects. IntelliJ is just fantastic and the tooling is great (ideal for MSofties) and there is a certain degree of familiarity as Jetbrains the company behind is the company behind Resharper.
  3. WebStorm: This is another Ide from Jetbrains (they have a few good IDE’s js,java,php,objective-c, python etc, check them out), I use this mostly for non ASP web stuff (where I naturally use VS), it’s quite good.
  4. XCode: I’ve created a few iPhone app’s, I hit the curve learned objective-C and the libraries enough to get a few apps in the store and XCode was the vehicle, I’ve not used AppCode from jetbrains but I bet it’s good! The truth is I’ve not used XCode in about a year now I guess, the reason is that I’ve moved to Android myself and don’t have a iPhone any longer (and at least for the foreseeable future) so I’m not motivated enough to do any iOS coding on my free time.

 

File management

Total Commander by Ghisler.com, I’ve been using this since 2001, I was previously using norton commander but when I changed company I no longer had access to that software so I found my beloved TotalCommander, this is without doubt one of the major reasons I prefer windows. (I must get off my bum and find a corresponding program for Mac as Finder is dreadful IMO.

XML and it’s cousins

Stylus studio: great for formatting xml and editing xml in tree and grid formats, generating xsd, debugging xlst etc, nice xpath support.

Idiot’s guide to Angular service vs factory

You won’t believe the amount on questions I’ve come across regarding the confusion between angular services factories and providers. This blog post attempts to help clarify same and get you started.

Which should I use?

Factory* if you don’t know this this is a good place to start.

Which is most powerful?

Providers

What’s the difference?

I’m not going to cover providers here so lets see the difference between services and factories.

The rhetoric

Service gets passed a function that’s considered to be a constructor, so you get back a new-ed constructor.
Factory gets passed a function which it invokes and returns the result.
A service is often used when you have 3rd party constructor function and want to use this.

Example1 – Same end result both ways

Service

First lets show the view in all it’s glory, it’s quite simple just will display whatever x is.

 
Then the angular code

image

You can see that we don’t return anything! so think of this as a constructor function, so effectively angular will give us a new TestService and we can call the doSomething method on it, the output looks like this

image

Factory

Now let’s look at the same thing as a factory

image

What’s the difference? Well in this instance we are returning something! Angular will call new on the returned object and return it.

Ok I get it but

Show me a reason to prefer one over the other? Well lets say we want to pass some information to the service or factory, well given we have no control over angular creating our service we cannot pass any additional information! it just creates the function.

Factories on the other hand we get to return what we want! So we can return a function! Lets look at some code to make this easier to see

image

So now if we don’t change our controller we have a problem, because angular has just created f for us! Let’s see this in a debugger, we can clearly see that TestService is not an object but rather a function.

image

Now we need to modify our code to work, let’s do that.

image  
image

So hopefully that’s helped you a little understand the difference.

Example 2

I’m working on a project at the moment and I’ve just created a backend REST webservice to manage user properties

image

as you can see I've got the basic REST HTTP verbs, GET,POST,PUT,DELETE, it’s done in Java, but could just as well be in .NET, node, php etc, it doesn’t matter, the basic premise of REST is that it just used what HTTP already gives us.

Now I want to be able to use this information in JavaScript, Angular itself exposes a $resource exactly for this scenario (read the docs there’s one or two simple steps needed to use it).

image

The important thing to notice is that we are returning something from our function, and we are passing parameters, therefore we cannot use a service in this scenario.

I hope this has clarified this situation for you, if so please drop me a line and let me know and I might cover providers also.
(comments are disabled until i get a better recapcha for all this spam I get when enabled).