Lanky Dan Blog

Abstraction, do I need to know this?

January 29, 2017

theorygeneral

Abstraction is a concept that is that is not only relevant to software engineering but also to many scenarios in the world. According to Wikipedia “The essence of abstractions is preserving information that is relevant in a given context, and forgetting information that is irrelevant in that context”. In a very simplified way this means that you don’t need to know how everything works.

Examples always make these sort of things easier to understand, if you are driving a car you just need to know things like how turning the wheel turns the car and pressing the accelerator makes the car’s speed increase, but you don’t need to know how the engine works. You will know that you need the engine and that it is what produces the power that drives the car, but do you need to know how the air and petrol mix in the engine to produce power? No you don’t and that’s where abstraction comes in. This way you can stop trying to figure out how everything works and just accept somethings as fact.

So how does this apply to software engineering / programming? Your code should be written to consider abstraction so that your code has different concerns properly separated. This makes each layer or class of code to be much more specific only needing to know about what is directly below it so that it can make use of the methods they expose. Private methods are also a form of abstraction as they are only visible to the current class meaning that you expose a selection of public methods to be used by other classes but they cannot see the private methods that will most likely contain a large amount of the workings of the class.

Abstraction is also a useful concept when designing a user interface that is separated from the business logic. A button press should trigger a method to be called from the business logic instead of containing the workings itself. This also allows the logic to be reused as it is in a appropriate place in the code base that it can be used by multiple user interfaces and also allows the original user interface to be changed visually but retain the main chunk of functionality.

In conclusion you don’t need to know everything. You need to know enough to implement the functionality that you require, but you don’t need to know how every single method you call and the methods they call work. If you tried to understand all of this you would probably never reach the end point and you will undoubtedly forget a lot of it after a while…


Dan Newton

Augmenting a Spring Data repository through delegation

September 14, 2019
springspring datakotlinjavar2dbcspring data r2dbcreactivereactive streamsspring boot

I have recently written several posts about Kotlin’s delegation. In doing so, I realised a useful way to apply it to Spring Data…

Implementing multiple interfaces through delegation

September 05, 2019
kotlin

In Kotlin, a class can implement multiple interfaces. This is common knowledge. A class can also use delegation to implement numerous…

Streaming live updates from a reactive Spring Data repository

August 29, 2019
springspring datakotlinjavar2dbcspring data r2dbcreactivereactive streams

This post details a naive implementation of streaming updates from a database to any other components that are interested in that data…

The potential traps in Kotlin's Data Classes

August 17, 2019
kotlin

The aim of this post is not to point out some massive flaws in Kotlin’s design of data classes and show you how to get passed them. Actually…

Connecting a Ktor web server to a Corda node

August 12, 2019
cordakotlindltdistributed ledger technologyblockchain

The preparation for this blog post began several weeks ago (probably over a month by now). Before I could write about melding Corda and Ktor…