This is important, because in 3/4 of this diagram, your code is inherently safe to run in a multi-threaded environment. There are no synchronization blocks required, there is no need for complicated gatekeeping. And yet, somehow a lot of code winds up with mutable data and synchronization headaches.
Applying just a few functional programming principles to your work can go a long way. Parameters should generally be considered inviolate, use return properly and don't try modifying your inputs directly. Prefer constants to variables.
When you kick off a process, you really don't want it randomly reaching out and modifying some kind of global state. If it REALLY needs to send messages home, give it a tool to do so, such as a callback function it can use for that purpose.
No comments:
Post a Comment