Idealism is what precedes experience; cynicism is what follows...

Showing posts with label Code Design. Show all posts
Showing posts with label Code Design. Show all posts

Wednesday, August 27, 2008

Guice (pronounced 'Juice')

Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 5 and above, brought to you by Google, however the principles are sound and could be used for other frameworks too.

Writing factories and dependency injection logic by hand for every service and client can become tedious. Some other dependency injection frameworks even require you to explicitly map services to the places where you want them injected.

Check it out... exciting stuff
http://code.google.com/p/google-guice/

Sunday, May 11, 2008

EventHandlers / EventListeners : Where, inline or code ?

I admit it, I have a strong preference for declaring all event handlers/listeners in code. I believe it is better encapsulation, making for more scalable and more maintainable code. But this is a personal opinion.

Jesse Liberty's rules for examples...

Reading about Silverlight 2, I stumpled upon Jesse Liverty's rules for examples, they are simple and almost universal...

Judge for yourself...

1. Keep it simple enough that the example totally focuses on what you are trying to illustrate (but no simpler)

2. Try to use something like business objects rather than cute animals or game objects

3. Don’t show off how clever you are, break the code down into small digestible parts.

4. Use interim variables; they’re easier to catch in a debugger

5. Strip away all exception and error handling and bullet proofing unless you are teaching exception handling, error handling or bullet proofing.

6. Use great variable names so you need fewer comments, but don’t convince yourself that means you don’t need any.

7. Show the output

8. Make no apologies (except when you’re wrong)

Thanks, Jesse... for letting us laymen get access to some of the experience you have gained from writing those 10+ technical books about programming :)

My Network