Tag Archives: object-oriented programming

Things I used to be Wrong about – Part 1

I get very annoyed about politicians being held to account for admitting they were wrong, rather than forcefully challenged when they were wrong in the first place. Unless they lied, if someone was wrong and admits it, they should be congratulated. They have grown as a human being.

I am about to do something very similar. I’m going to start confessing some wrong things I used to think, that the world has come to agree with me about. I feel I should congratulate you all.

You can’t design a Database without knowing how it will be used

I was taught at university that you could create a single abstract data model of an organisation’s data. “The word database has no plural”, I was told. I tried to create a model of all street furniture (signs and lighting) in Staffordshire, in my second job. I couldn’t do it. I concluded that it was impossible to know what was entities and what was attributes. I now know this is because models are always created for a purpose. If you aren’t yet aware of that purpose, you can’t design for it. My suspicion was confirmed in a talk at Wolverhampton University by Michael ‘JSD’ Jackson. The revelation seemed a big shock to the large team from the Inland Revenue. I guess they had made unconscious assumptions about likely processes.

Relations don’t understand time

(They would probably say the same about me.) A transaction acting across multiple tables is assumed to be instantaneous. This worried me. A complex calculation requiring reads could not be guaranteed to be consistent unless all accessed tables are locked against writes, throughout the transaction. Jackson also confirmed that the Relational Model has no concept of time. A dirty fix is data warehousing which achieves consistency without locking by the trade-off of guaranteeing the data is old.

The Object Model doesn’t generalise

I’d stopped developing software by the time I heard about the Object Oriented Programming paradigm. I could see a lot of sense in OOP for simulating real-world objects. Software could be designed to be more modular when the data structures representing the state of a real-world object and the code which handled state-change were kept in a black box with a sign on that said “Beware of the leopard”. I couldn’t grasp how people filled the space between the objects with imaginary software objects that followed the same restrictions, or why they needed to.

A new wave of Functional Programming has introduced immutable data structures. I have recently learned through Clojure author Rich Hickey’s videos that reflecting state-change by mutating the value of variables is now a sin punishable by a career in Java programming. Functional Programmers have apparently always agreed with me that not all data structures belong in an object

There are others I’m still waiting for everyone to catch up on:

The Writable Web is a bad idea

The Web wasn’t designed for this isn’t very good at it. Throwing complexity bombs at an over-simplified model rarely helps.

Rich Hickey’s Datomic doesn’t appear to have fixed my entity:attribute issue

Maybe that one is impossible.

Advertisements

Vacuous Thoughts

A minute ago, I juxtaposed 2 phrases on a Slack chat:

I listened to Rich Hickey’s video on Hammock Driven Development a couple of days ago. It’s about modification of mind mode without resorting to chemicals. There’s a long tradition in hacker-lore that points to Zen and the martial arts too. I find showers, lawn-mowing and writing what i think I know so far (a variation of the cardboard coder trick) all help. The poets seem to prefer long walks. ‘Empty Mind’. “Nature abhors a vacuum”.

As a result of my subsequent wanderings, I learned a new word, “plenist” and “plenism” http://englishdictionary.education/en/plenism (the usual suspects)

and I saw the word “idiom”. I’ve heard “idiomatic” a lot recently, in relation to styles associated with programming languages but I wasn’t sure precisely what it meant:

I think the intended meaning is Google’s 2nd choice:

a characteristic mode of expression in music or art.

but the alternative is interesting too:

a group of words established by usage as having a meaning not deducible from those of the individual words (e.g. over the moon, see the light ).
How often does a ceremony gets associated with an idea, long after anyone remembers why? I ask this after reading a thought provoking comparison of the functional and object paradigms that only partly agrees with the ideas I mapped out in stickies on a paper table-cloth yesterday.
I’m “still not working”, as people say. My Dad kept a dictionary beside his chair. I continue his work with ‘tear-off here’ computer science. At least my inherited etymology is idiomatic of the Clojure community.

Concerns

I learned to write ‘computer code’ in the era of Structured Programming. In the last few months I have come to question how much science I was exposed to in my Computer Science education. I was taught facts and current best practice but that wasn’t enough.

I’d stopped writing code professionally by the time Software Engineering became trendy, so I skipped relational databases, object orientation and coding for the web before I decided to reconnect with software development via the Business Analysis, UML modelling and Scrum Agile, Product Owner route. I THINK I know what objects are now.

When I decided to do some coding again, I at first decided to learn Python but quickly jumped ship to Clojure. I’m finding the functional model new and exciting but also unfamiliar and strange. I’ve made a huge leap into the dark, from a direction that that the text books I’m reading weren’t expecting. This post represents me taking a breath of air.

I thought I had my head around ‘separation of concerns’ into code modules, in a world made of objects. An object is a model of a real-world entity in a software simulation of reality. It represents the state of an object’s data and via calls to its methods, implements message passing between objects. What functional programming texts have shown me is that OO also invented objects that had no equivalent in the real world. In the functional world, concerns are implemented in stateless functions and state is represented by the flow of change over data structures, outside the functions.

What I haven’t yet worked out is what the “logically discrete functions, interacting through well-defined interfaces” of ‘Top-Down Design’ and ‘Step-wise refinement’ were supposed to represent. Anything we liked, I suspect, because no-one else knew either. I feel now that I was equipped with excellent knowledge of woodworking tools and the idea of furniture without being shown any woodworking joints. At least I recognised at the time that I was clueless and stopped. Many didn’t. OK, I think I’m ready to carry on.