Android Programming

Android Architecture 1

Advertisements

Programming Paradigms

Main paradigm approaches 1

Imperative

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

Structured

A style of imperative programming with more logical program structure

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

Imperative

C, C++, Java, Python

Procedural

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

Functional

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

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

Declarative

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

Object-oriented

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

Declarative

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

AsmL

Programming Principles

Programming Principles 1

Generic

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

Inter-Module/Class

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

Module/Class

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

Logging

https://docs.python.org/2/howto/logging.html

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