FLIP FLOPS , REDIS , CEPH , DATA CENTERS AND ALL : WHAT IS STATE ? (Part 1 of 2)

Stateful this. Stateless that. Managing the state is extremely important. Pure functions in functional programming are such that they guarantee the same output for the same input. That means they do not change state. This makes them suitable for many things, such as concurrent execution of many instances without worry. But state there, too, can not be brushed under the carpet. It has to be managed in the context of overall architecture, design, and approach. I could go on and on, but I guess my point is clear. State is important. In the world of software engineering, it is very important. But what exactly is state?

State is in essence, information. In the information theory sense of the word.? So things like :?

  1. My mom asked me to check how many apples were in the tray, this is a query about the state of the tray and/or the state of the apples.
  2. My son asking me to open the curtains and check if it is raining outside or not is a query about the state of weather where he and I are living
  3. Summing up the revenue column of a CSV file and printing it to a log file is also an algorithm that runs over the state of the CSV file; the output changes the state of the log file.
  4. Changing the background color of my GUI widget is changing its state?
  5. Inserting a new record in a database in a certain table is changing its state
  6. Consuming a message from a topic in any queuing or register/notify or pub/sub system is also just getting to know of change in state when it happens.

Clearly, state is very important - it is what we play around with in software engineering. How we play around with it is, in essence, the algorithm in execution. One could say that the state is as important, if not more, in real life.? For those interested in these topics and their inter-relation, I have a beginner-friendly video here that I can highly recommend?

Video title :?Navigating the ICT alphabet soup - Signal , Information , Data , Coding , Computation

Video length: 40 min that you could watch at 1.5x speed if so inclined as well

Video URL: https://www.youtube.com/watch?v=2IM7rp2irFg?

All right, back to this article.?

So, a state is a record of information, either stored or in transit. In software systems utilizing electronic digital computer systems, that state is kept somewhere for some time - on hard disks, in memory, or in transit over some communication system like data buses, network wires, wireless signals of Wifi, etc. That “in transit” eventually needs the physical layer of the OSI system. That means some properties of the physical world are utilized to carry that information or state, as we may call it. There is typically an encoding scheme and a decoding scheme for pushing and receiving the encoded/decoded state/information to/from the physical layer.?

The fundamentals of storing the state are the same for hard disks and other storage mechanisms like tapes or CDs and for RAM. Some physical property of matter is utilized to store the encoded state and retrieve the decoded state. Whatever that property might be. Whatever the encoding scheme might be.? But it will have some properties of matter and some encoding scheme.

This layer is the fundamental layer and all there is to it.

Rising above this layer, there are, of course many other aspects that come into play, not because of the fundamental nature of the state as much as in response to the questions :?

  • What is the read access pattern for this state?
  • What is the write access pattern for this state?

As you might have noted, these questions concern the algorithm, aka work, aka execution. What purpose does the application need to be served from the writing and reading of this state? How can that purpose be best served?

That brings us to the world of Data Structures. A data structure is a codification of patterns for state representation and methods of accessing and modifying the state. An array, stack, queue, binary tree, or linked list are all just that: patterns for representing the state and methods of accessing and modifying that state. Different data structures better serve different application requirements.?

A data store/database is also, in essence, a collection of data structures and associated algorithms for accessing and modifying the state. In essence, that is. Of course, with bells and whistles and on steroids, but in essence, it is just that.?

We might as well think a bit further about encoding and decoding of state.? In the so-called application layer, we also always decide about this. When we say a data blob is binary or ASCII or UNICODE UTF8 or whatever, all we are specifying is what the given location in memory contains and how it is encoded. Which also tells how it should be decoded or interpreted. Cannot help adding a quote by Nietzche here :?

“There are no facts, just interpretations”?

This is how a key component of modern computer software systems is built - state.?

We will conclude this discussion around the state in part 2 of this article. Stay tuned.

要查看或添加评论,请登录

M. Taha Masood的更多文章

社区洞察

其他会员也浏览了