Android Programming

Android Architecture 1


Programming Paradigms

Main paradigm approaches 1


Computation as statements that directly change a program state (datafields)

Direct assignments, common data structures, global variables

Edsger W. Dijkstra, Michael A. Jackson

C, C++, Java, PHP, Python


A style of imperative programming with more logical program structure

Structograms, indentation, either no, or limited use of, goto statements


C, C++, Java, Python


Derived from structured programming, based on the concept of modular programming or the procedure call

Local variables, sequence, selection, iteration, and modularization

Structured, imperative

C, C++, Lisp, PHP, Python


Treats computation as the evaluation of mathematical functions avoiding state and mutable data

Lambda calculus, compositionality, formula, recursion, referential transparency, no side effects


Clojure, Coffeescript,[1] Elixir, Erlang, F#, Haskell, Lisp, Python, Scala, SequenceL, SML

Event-driven including time driven

Program flow is determined mainly by events, such as mouse clicks or interrupts including timer

Main loop, event handlers, asynchronous processes

Procedural, dataflow

Javascript, ActionScript, Visual Basic


Treats datafields as objects manipulated through pre-defined methods only

Objects, methods, message passing, information hiding, data abstraction, encapsulation, polymorphism, inheritance, serialization-marshalling

Common Lisp, C++, C#, Eiffel, Java, PHP, Python, Ruby, Scala


Defines computation logic without defining its detailed control flow

4GLs, spreadsheets, report program generators

SQL, regular expressions, CSS, Prolog

Automata-based programming

Treats programs as a model of a finite state machine or any other formal automata

State enumeration, control variable, state changes, isomorphism, state transition table

Imperative, event-driven


Programming Principles

Programming Principles 1


  • KISS (Keep It Simple Stupid)
  • Do The Simplest Thing That Could Possibly Work
  • Keep Things DRY
  • Code For The Maintainer
  • Avoid Premature Optimization


  • Minimise Coupling
  • Law of Demeter
  • Composition Over Inheritance
  • Orthogonality


  • Maximise Cohesion
  • Liskov Substitution Principle
  • Open/Closed Principle
  • Single Responsibility Principle
  • Hide Implementation Details
  • Curly’s Law


Level When it’s used
DEBUG Detailed information, typically of interest only when diagnosing problems.
INFO Confirmation that things are working as expected.
WARNING An indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected.
ERROR Due to a more serious problem, the software has not been able to perform some function.
CRITICAL A serious error, indicating that the program itself may be unable to continue running.

Python: Logging module
Java: log4j