SLIDE 1
Object-Oriented Analysis and Design
One of three programming paradigms
We can identify three paradigms: functional programming, imperative programming and object
- riented approach. Object orientation is comparatively young compared to the other two. Use
the paradigm that suits the problem. If the problem do not supply any suitable objects - do not use object-orientation, use another approach. Program into the language - and use a suitable
- language. Find a language where you can express your thoughts clearly.
Quotes from the book “Code Complete” by Steve McConnell: “Programmers who program “in” a language limit their thoughts to constructs that the lan- guage directly supports. If the language tools are primitive, the programmer’s thoughts will also be primitive.” “Programmers who program “into” a language first decide what thoughts they want to express, and then they determine how to express those thoughts using the tools provided by their specific language.” Object-orientation is a way of thinking. C++ class features support that way of thinking, but C++ can equally well support the imperative way of thinking, and to some degree the functional way of thinking.
Functional programming (Lisp, Scheme, Python)
Solves a task by means of “mathematical” functions, or expressions, that depend purely on
- input. There is no global state. Execution is recursive in nature, and functions should have no
side-effects, just return a result. The program have no “state”. Lambda calculus and recursion are central. Functions are treated as any data, and can be created on the fly, and passed around just like any variable to adapt the behaviour of other functions.
Imperative programming (Ada, C++, Python)
A program consist of statements, functions and procedures that manipulate a program state. Execution of the statements are sequential, and focus on how the program should achieve something in a step by step manner. It is common that functions and procedures cause side effects rather than just calculating a result from the given inputs.
Object orientation (Java, C++, Ada)
A program consist of loosely coupled objects that cooperate to solve a task. The objects are
- ften modeled to represent some real-world “thing” or abstract “concept”. Each object should
provide a cohesive interface that other parts of the program can use, but no details of how the
- bject works internally. Emphasis is on abstraction to name and easily access a possibly
complex behaviour model, encapsulation to be able to update, replace or modify object internals without affecting other parts of the program, and association, composition, aggregation and inheritance to easily reuse functionality in similar objects. Internally, objects
- ften use the imperative paradigm.