Wednesday, December 12, 2007

Apache.org = 404

It really pisses me off that anytime i try to get something from Apache there are 404 error all over the show. I normally use Nlog, however at work we are using Log4Net. I went to the log4net site and most of the links i click on a dead... 404 bloody everywhere.
PITA!
As such i continue to use pretty much no Apache api's in my dev.

<UPDATE>
...and the downloads are 1.1 that dont run... NLog has just cemented its place in my toolbox.
</UPDATE>

Sunday, December 9, 2007

XBox

Yeah I had to get one.
At the apartment we have a huge HD screen. Gears of War and Assassin's Creed are awesome on it.
This thing blows my mind, the graphics are unbelievable... clearly I have not been up to speed on gaming or HD tv's....

I am addicted to the creed... stealth kills.. I feel like a bad man ;)

DSL's and tearing up tiers

Boo:
I read a lot of Ayende's post, well actually I read everything he puts out, so as he references his work with Binsor and Brail (which are Boo off shoots/DSL), I figured I had better see what its all about. Well I am still getting my head around things, I haven't learnt a new language in so long (shame on me). However I can now see why Bindsor would be so handy. I am not a huge fan of strings and XML to me, is one massive string. If i can get compile time checking AND get the flexibility of easy config. Sweet. Another thing on my massive to do list DSL up my configs.

Volta from MSDN labs is out... another thing I need to play with. Could be great for small teams teams if it works... after reading the blurb i am wondering if this is stepping on CSLA.Nets toes?

Saturday, December 8, 2007

Coding style and preferences

There are a couple of things i try to keep in mind when writing code, well they is plenty but specifically for this post 2.

Re-usability and Reliability.

I do all that I can to fail fast. I want my errors to come up as I type, ideally your IDE will support you on this, if not plug ins like ReSharper help. Other wise I want build errors to tell me, “Hey mate your code is junk this does not make sense!”. The last thing I want is run time errors. This is not obviously shared with others.

In my mind using strings for business logic is a last resort and if done there are always constants.

Casting is also a last resort, and usually only done from a know parent class to a subclass.

I would much rather use enumerated constants, generics, type checks to perform this business logic or flow control.

i have spotted in a few place where effective type checks are being done using string

if( Object.symbolX = "Fully.Qualified.Name.Space.ClassName")
{...}

if some one changes that name space then every check now has to be changed and the compiler will not pick it up.

it would have been just as easy (actually easier) to write

if( Object.symbolX = typeof(Fully.Qualified.Name.Space.ClassName).Fullname)
{...}
or even just do a bloody type check!

Secondly re-usability:
I am currently working as a contractor on an application that was many many week behind schedule largely due to an over worked non functioning UI. Myself and another contractor worked very hard to rebuild the UI framework (ie throw all the old stuff out and create new projects for the client side!) We knew it didn't have to be the best looking code it just had to work so the the user could see the application. 14 weeks and no visible app is pretty bad. 2 weeks later we had a app that functioned, very basically but you could so stuff. We are now almost up to schedule (6 weeks to catch up 14 weeks with 2 guys fired is not too bad).
The other developer who I wrote the UI framework with was reworking some of my code and asked if he could change (or overload) the constructor so he could inject the views controller into the view. I explained I prefer not to as it means the view become more tightly coupled with the controllers and I don't want the views to know anything other than they are Win or Web Forms.
I could understand were he was coming from, calling the controller from the view means its is easier and faster to write code. ie to save from the view just type this.IXXXXController.Save(XXXXX);
His points were valid. It is easier to code against, it is kinda loosely coupled as the View only know of the common interface assembly. I was starting to doubt why I go to the bother of creating events and delegates and event handlers (even most of them get reused).....
Then I had to make a change to a view and i realised why I follow this.
Raising events means that ANY controller can use the view. i am reusing a lot of my views. Having knowledge of the controller leads to spaghetti code..... as the other developer i currently work with is a pretty good dev I am not really worried that he is going to go down that path, worst come to worst we can retro fit the events when/if we get the time. However when we got another contract dev involved, it went pear shaped fast. He is gone now, thank god.

Benefits of using events
  • They can go on your interfaces
  • As many other class can subscribe to the event as needed
  • separation of concern
  • Changing the EventArgs doesn't change signatures of events meaning you wont break the build (provide nothing of importance is removed!)
  • Its clear where calls are coming from and where they are going. If i see a method in my controller called SuperView_RhysKicksAss(object sender, AssKickingEventArgs e){...} it is pretty obvious where this method is being fired from and why it is being fired (because I am Kicking Ass!), but you may want to check it is actually assigned a handler if you didn't write the code...

Negatives
  • You have to write your EventArgs and Event Handler. This is perceived as a headache to pretty much everyone i have worked with. When I explain the xxxEventArgs is just a DTO and the handler is a one liner they usually easy up a bit. BUT it is still an extra dozen or so line that need to be created.
  • Its easy to write sh1te event code if the devs are not aware of coding standards, meaning it is hard to understand what is going on. Follow conventions to save headaches later
  • testing frameworks offer crap support for testing events
After weighing it all up, i think for the mean time I am going to stick to events when calls need to go out of scope.

Thursday, November 22, 2007

Todo list

As always there is far to much stuff happening in the world.... I need a list!

Languages I want to learn (or at least learn more about):
  • Erlang
  • Boo
  • IronPython/Ruby
Things I want to play with:
  • VS 2008
  • Cruisecontrol.net (I have never actually implemented it myself.. which is bad)

Stuff I have been playing with recently:
Oracle. Its a big beast and is really quite different to MS/MY/T SQL. But I can see why it is the dominant RDMS...
Things I Don't like about my Oracle experience:
  • PL/Sql Developer by Allround Automations. I sucks and doesn't handler cut and paste functions properly (e.g white space characters it doesn't recognise breaks the code... why not just remove them?!?)
  • Shit schema's are not just the domain of T-SQL... they are everywhere ;) hehehe
MonoRail. The original MVC web platform for Asp.net. Its pretty cool, i have just built my new site, www.FullStack.co.uk on it and managed to get it together very fast, including the learning curve. Will i continue to use it? personally i have never really had to many issues with Viewstate and PLC. I don't put a lot of logic in my code behind so don't get in to too much troubles there.

PostSharp: I like it. It is a cool little AOP IL weaver that made my logging stupidly easy. Was going to try to add security with it too, probably wont tho...

Every day i would spend at least 2 hours read technical content, but mostly articles blogs and forums. I really don't read enough books...So lately i have been catching up on my essentials list.

Books I have just read:
The Pragmatic Programmer. Its hard to believe this is almost 10 years old. Sure it has been revised and there are some old references to languages like small talk (as opposed to newer languages like c#), but this is as relevant today as it ever was. Thoroughly recommend it.

Head First Design Patterns: I really wish i read this before GoF and Fowler... it makes the whole process a lot easier. I must say i felt like a dick buying the book as it feel like a high school book, but it is well worth it... i did make up for by buying Slash's Bio and the Flight of the Conchords dvd... sweeet.

Books i want to get
Erlang and NUnit from the Pragmatic series. I unit test every day but i would like to see "How Correctly" I am doing it. The xUnit testing book just far to big... its like 900 pages, come on...

On a side note; well done to the ever growing Open Source guys* that are getting snatch up by M$. Its nice for them to finally get some financial reward and its good to see M$ backing the real drivers of the community.

*Specifically Rob from Subsonic and Alex from Base4, but there seems to be many others at the moment too

Friday, November 9, 2007

Dependency on self?

I am worried that DI is the new singleton. A pattern with good intentions and fantastic helpful when used properly but slipping into the realm of the abused.
Wehn leaving Australia i was working on a project where there where dozen and dozens of unnessecary singletons. they really just ahd no reason to be there other than to slow things down.
Recently i have seen in quite bit of code using "constructor injection", no problem. But when you are passing in a object and then make this object dependent yopu are in effect providing circular references. However using interfaces this is allowed.
eg

My problem is: why?

I am seeing this specifically in the MVC pattern.
I dont need my views to know anything about my controller, so why pass the controller in as a constructor parameter. if it need to communicate with the controller raise an event, if the controller cares about this event it will subscribe to it.
I belive people are dodging using events because it seems tricky and DI is "cooler".
bollocks to that I say.

Strings

Strings are really beginging to annoy me. People need to think when they design API's if strings are really the best thing to use.
String are for reading, for humnas to read.
I am using a system where most of the strings should be replaced with enum or custom value. the reduction in runtime errors would be significant.
i have to campare time code in one exapmle, these are in string format. i now need to know and understand the other applications time code format so i can do a comparison instead of using
if(timecodeA > timecodeB)
{
//DO LOGIC
}
which would be the logical thing to do.