Showing posts with label basics. Show all posts
Showing posts with label basics. Show all posts

Monday, June 29, 2009

Living without friends sucks

And again I stumble over a scenario where it would be so absolutely helpful to have C++-like friends in Java.
Again I need to jump through hoops to get the desired behavior.
I am working on an integration of our SAL (Sensor Abstraction Layer) with Esper.
But the messages from SAL can go to other receivers like JMS, too.
The problem comes form the fact that the messages coming from the SAL have to be readonly to not mess Esper up.
As I like my code easy readable I prefer setters over big constructors. But in this scenario setters would be very problematic as they would allow the manipulation of data at any point in the future. Something that must not happen from the moment on the message went into Esper.

So public setters are a no go. Protected setters don't work as they are only accessible from the same package. So I end up having to write a big constructor, collect all the data from the different sources and then create the object.
Exceptions might be another way of solving the problem. But all the boilerplate code ...
Wouldn't it be nice to declare it protected and define a list of friends who can access it?
Then I would be able to create the object, pass it to the friends who are allowed to access the setters and then put the object into Esper without having to worry that somebody messes up my messages.
So sad.
Note:
I put together a little idea using CGLib and a set of different interfaces to built a proxy based solution. As soon as I get some time I will post it here.




Sunday, April 12, 2009

Software development basics

Software development is my passion. I love creating code, brooding over algorithms, learning new languages or frameworks and just about everything that is related to it.

Having started to code on the C64 more than 20 years ago I can savely assume that I know a lot about the process and the required mindset for coding.

And it's exactly that mindset that I miss in a lot of coders that come out of university.

It's not there fault. Universities tend to just teach the tools, like a programming language or UML, skipping the essential basics.

I don't want to get started on how much I think it is wrong to start coding with a language like java.

What I want to get started on is the basic set of principles and rules that should be the mantras of every developer and most engineers.

So this article marks the beginning of a small series about what I think are essential rules to follow to become a good coder.

In the series I will cover the following things:

K.I.S.S.

Divide and Conquer

Premature optimization is the death of software

Separation of concerns