Archive for the ‘Pragmatic programmer’ Category.

Service vs. Component

I was having trouble to differentiate between both nor could I 100% explain to someone what’s the real difference between a Service and a Component. Today I’ve found a really nice definition by Martin Fowler which I would like to share with you:

Component

I use component to mean a glob of software that’s intended to be used, without change, by application that is out of the control of the writers of the component. By ‘without change’ I mean that the using application doesn’t change the source code of the components, although they may alter the component’s behavior by extending it in ways allowed by the component writers. – Martin Fowler, Inversion of Control Containers and the Dependency Injection pattern

Service

A service is similar to a component in that it’s used by foreign applications. The main difference is that I expect a component to be used locally (think jar file, assembly, dll, or a source import). A service will be used remotely through some remote interface, either synchronous or asynchronous (eg web service, messaging system, RPC, or socket.) – Martin Fowler, Inversion of Control Containers and the Dependency Injection pattern

Read error messages, understand them and write your own

Over the past years I have seen that many developers don’t really read error messages nor do they try to understand them. That’s not a good thing! Error messages are here to help us find the problem. Each error tells us exactly what’s wrong.

Instead of trying to think what the interpreter/compiler tries to tell us people start copy&pasting errors and posting them on forums. The forum “experts” do nothing else than reading the actual error message (as that’s the only information they have) and answer the question. Why can’t a developer do that in first place?

I recommend following these steps on each error you encounter:

  1. Read the error
  2. Read the error again!! Character by character. (I know you have seen the error 1000 of times but probably you never fully read it)
  3. Try to understand what the error wants to tell you. Think of the developer who wrote the framework, lib, programming language, etc. and ask yourself what was on his mind. They try to help you (us)
  4. If you did not understand the error you probably don’t have enough knowledge about the tool you are working with:
    1. Improve your knowledge on that field where the error happend and get to understand why it happend and what it exactly means (then go to step 1)
      That’s the point of time where you start to improve dramatically as a developer!
    2. If you are too lazy and just want to get thing done. Google it
      That’s the point of time where you should ask yourself if programming is really the right job for you!

You will notice how happy you will be about error message in the future. You’ll start hoping for error messages popping up and get the feeling how to write your own meaningful errors.