Programming Concepts

Cohesion is a measure of how strongly-related the functionality expressed by the source code of a software module is. Coupling or dependency is the degree to which each program module relies on each one of the other modules.

Encapsulation is a language mechanism for restricting access to some of the object's components. Object should totally separate its interface from its implementation.

class A {
    private int x;
    public int getX() {return x;}

Inheritance provides a powerful and natural mechanism for organizing and structuring the software.

class A extends B {…}

Polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. Overriding allows a subclass to re-define a method it inherits from its superclass.

class Base {void func() {}}
class Extended1 extends Base {void func() {}}
class Extended2 extends Base {void func() {}}
void f(Base b) {

Overloaded methods appear in the same class or a subclass, have the same name, but have different parameter lists, and can have different return types.

public void print(String s)
public void print(boolean b)

Object: state (attribute) + behavior (method).

Class: blueprint or prototype from which objects are created.

Interface: a contract between a class and the outside world.

Association, aggregation, composition

\begin{align} composition \subset aggregation \subset association \end{align}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License