Richard Bamford


Second year Computer Science student at the University of Hull. Interested in maths, physics and graphics.

Blog posts

Abstraction function, representation invariant

Abstraction Function & Rep invariantThe abstraction function is the map between concrete values and the correct abstract notion. The representation invariants are these correct mappings, and are placed as conditions on the class to give that class meaning.ExampleBelow ZeroNumber is the abstract notion we want to represent.class ZeroNumber {public: ZeroNumber(float inValue) { assert(inValue == 0.0f… Read more →

Object interface design and declarative vs imperative

An object represents a concept otherwise known as a "thing" or noun. Traditionally, we're taught that you can create an object then tell it what to do, however, this design (coming from Alan Kay) actually results in a mess of global state (which is the usual complaint about OOP). A more appropriate view is a little more complicated, we can create an object but we must define what we can do TO it.F… Read more →

Mixing DDD , OOP and Modularity

The world map is a model of the Earth, it tries to solve a specific problem of planning shipping routes. As you can see Greenland is much much bigger than it is in reality, but this is because the purpose of the map is to find angles to sail, not to display the relative sizes of parts of the world. This is the most important concept for DDD because when we write software (using OOP in particular,… Read more →

OOP Tell dont ask and SRP

BackgroundTell dont ask and SRP seem to be conflicting principles, one says to make the object do the work and the other says that each object should only change for one reason (meaning it must be responsible for 1 logical part). So how do we design our programs to conform to both of these principles when an object theoretically does more than one thing?Protected state, released stateTell don't as… Read more →

OOP Object interfaces and decomposing the blob class

An object should be defined as an ADT implementation of a Abstract State Machine. The interface of the object should provide meaningful services to clients. A problem arises when too many jobs are assigned to one class of object for example a client object:class Client { public: void Authenticate(); void SendMessageToChat(); void JoinChatRoom(); void LeaveChatRoom(); void JoinGroup(); // etc }Look… Read more →

Commands, queries and side-effects (object interface design)

Commands and queries "A machine has 2 types of buttons, command and query buttons. When a command button is pressed, the machine performs work and its state is modified. When a query button is pressed, the machine returns some information about it." - Bertrand MeyerCommand corresponds to procedures, they do not return any results. For example:class MyMachine {public: void SetName(const char * name… Read more →

ADT, type theory and set theory.

IntroType and set theory provide the formal definitions for programming today. I believe that understanding how these pieces fit together we can create "better" software; more readable, easier to debug.There is a saying that "the ideal solution for a professor to a problem was to introduce 10 classes instead of creating 1 function" and i think that this blog post might shed light on it. By disting… Read more →

Computer Science Reference List

CS Reference ListThis is a collection of papers, websites and books that I have found useful when researching into computer science. Mainly into programming paradigms and languages, focusing on understanding OOP OOP Phenomena and Concepts Websitehttp://people.cs.aau.dk/~normark/oop-csharp/html/notes/intro-oop_themes-phen-concepts-sect.html PDFhttps://drive.google.com/file/d/1FQLDJC6Kj2r7SeLZK1YnLC… Read more →

OOP Quotes 1: ADT vs Object

From: "On Understanding Data Abstraction, Revisited. William R. Cook" "in modern object-oriented languages, the issue boils down to whether or not classes are used as types. In a pure object-oriented style, classes are only used to construct objects, and interfaces are used for types. When classes are used as types, the programmer is implicitly choosing to use a form of abstract data type." "To su… Read more →

C++ Abstract Data Type

The abstract data type (ADT) is a core piece of OOP architecture. They are created/defined/declared with a class, but, unlike normal classes they have a specific purpose which is to provide/export a "type". Almost everything can be expressed as an ADT which makes choosing between a ADT or not for a class is tricky and up to the programmers discretion.A definition of a ADT follows: class Person { p… Read more →