Closure is when a function (or any code snippet) has all variables linked to a value. The concept comes from functional programming, in which you can say "this context is a closure", or if it is not a closure because some variables are still free, you can assign them values and therefore they are not free anymore.
Also closure is when you finish something. For example in English you can say "think through", which I really think there is no equivalent concept in Spanish, meaning that you think of all the possible consequences and come with a unique solution (or a set of possible solutions).
So when it comes to computing, several years ago, I was thinking about this idea about client/server computing which is the basis of almost everything we do now, and I was thinking why do we store data in databases, or disks for that matter, since that complicates design, we could instead just have a messaging paradigm (like sockets) and solve everything using messages, so that it wouldn't matter if the connection was local or remote, the algorithms would be the same.
And it was like an epiphany, I realized that the server must be up, so everything was messaging and the case of storing on disk is just trivial case solved in one particular machine, but the communication is always from program to program through messaging.
Seems like nothing, doesn't it?
It means that if you program everything using sockets, you are done. That's closure!
Well, then I thought about how databases are described using functional dependencies, which are really like hashmaps, and then functional programming is all about defining functions, which in turn could be defined as hashmaps, and also object oriented programming when applied throughly in a program ends up feeling like functional programming, and finally caches are really just hashmaps.
And hashmaps are really functions (inputs and outputs). And when you define correctly the inputs and the outputs, you can define correctly any function or any program. That was one of the first suggestions I recieved when learning how to program. It is really humbling that you must go for 20 years discovering new stuff, just to arrive a very revolutionary idea, that was passed to you a suggestion when you were learning 20 years ago.
And well, it also applies to modelling, because you can draw a context diagram, for specifying all inputs and outputs for your module. That's closure!
martes, 28 de agosto de 2007
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario