Behind Proxy

PIP

Run it on command line

set HTTP_PROXY=http://<username>:<password>@<host>:<port>
set HTTPS_PROXY=http://<username>:<password>@<host>:<port>

GRADLE

Edit gradle.properties

systemProp.http.proxyHost=<host>
systemProp.http.proxyPort=<port>
systemProp.http.proxyUser=<username>
systemProp.http.proxyPassword=<password>
systemProp.http.nonProxyHosts=localhost
systemProp.http.keepAlive=true
systemProp.https.proxyHost=<host>
systemProp.https.proxyPort=<port>
systemProp.https.proxyUser=<username>
systemProp.https.proxyPassword=<password>
systemProp.https.nonProxyHosts=localhost
systemProp.https.keepAlive=true

ANT

Change build.xml

  <!-- target: ivy-init ================================================ -->
- <target name="ivy-init" depends="ivy-probe-antlib, ivy-init-antlib" description="--> initialise Ivy settings">
+ <target name="ivy-init" depends="ivy-proxy, ivy-probe-antlib, ivy-init-antlib" description="--> initialise Ivy settings">
   <ivy:settings file="${ivy.dir}/ivysettings.xml" />
  </target>
-
+ <target name="ivy-proxy" description="-->Proxy Ivy settings">
+  <property name="proxy.host" value="host" />
+  <property name="proxy.port" value="port" />
+  <property name="proxy.user" value="username" />
+  <property name="proxy.password" value="password" />
+  <setproxy
+          proxyhost="${proxy.host}"
+          proxyport="${proxy.port}"
+          proxyuser="${proxy.user}"
+          proxypassword="${proxy.password}" />
+ </target>

Object Oriented Programming (a.k.a OOP)

Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A distinguishing feature of objects is that an object’s procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of “this” or “self”). In OO programming, computer programs are designed by making them out of objects that interact with one another.[1][2] There is significant diversity in object-oriented programming, but most popular languages are class-based, meaning that objects are instances of classes, which typically also determines their type.

1. A First Look 1

Procedural vs Object Oriented

Procedural Approach

  • Focus is on procedures
  • All data is shared: no protection
  • More difficult to modify
  • Hard to manage complexity

Advantages of Object Orientation

  • People think in terms of object
  • OO models map to reality
  • OO models are: Easy to develop & Easy to understand.

2. Principles 2

encapsulation, inheritance, abstraction, polymorphism

Fundamental Principles of OOP

In order for a programming language to be object-oriented, it has to enable working with classes and objects as well as the implementation and use of the fundamental object-oriented principles and concepts: inheritance, abstraction, encapsulation and polymorphism.

2.1 Encapsulation 3 4 5

Encapsulation is the packing of data and functions into a single component. The features of encapsulation are supported using classes in most object-oriented programming languages, although other alternatives also exist. It allows selective hiding of properties and methods in an object by building an impenetrable wall to protect the code from accidental corruption.


What it do? We will learn to hide unnecessary details in our classes and provide a clear and simple interface for working with them.


Example: A popular example you’ll hear for encapsulation is driving a car. Do you need to know exactly how every aspect of a car works (engine, carburettor, alternator, and so on)? No – you need to know how to use the steering wheel, brakes, accelerator, and so on.

2.2 Inheritance 6 7

Inheritance is when an object or class is based on another object (prototypal inheritance) or class (class-based inheritance), using the same implementation (inheriting from an object or class) specifying implementation to maintain the same behavior (realizing an interface; inheriting behavior).


What it do? We will explain how class hierarchies improve code readability and enable the reuse of functionality.


Example: A real-world example of inheritance is genetic inheritance. We all receive genes from both our parents that then define who we are. We share qualities of both our parents, and yet at the same time are different from them.


Example: we might classify different kinds of vehicles according to the inheritance hierarchy. Moving down the hierarchy, each kind of vehicle is both more specialized than its parent (and all of its ancestors) and more general than its children (and all of its descendants). A wheeled vehicle inherits properties common to all vehicles (it holds one or more people and carries them from place to place) but has an additional property that makes it more specialized (it has wheels). A car inherits properties common to all wheeled vehicles, but has additional, more specialized properties (four wheels, an engine, a body, and so forth). The inheritance relationship can be viewed as an is-a relationship. In this relationship, the objects become more specialized the lower in the hierarchy you go.


Look at the image above you will get a point.8 Yes, the derived class can access base class properties and still the derived class has its own properties.

2.3 Abstraction

In computer science, abstraction is a technique for managing complexity of computer systems. It works by establishing a level of complexity on which a person interacts with the system, suppressing the more complex details below the current level. The programmer works with an idealized interface (usually well defined) and can add additional levels of functionality that would otherwise be too complex to handle.


What it do? We will learn how to work through abstractions: to deal with objects considering their important characteristics and ignore all other details.


Example: You’ll never buy a “device”, but always buy something more specific : iPhone, Samsung Galaxy, Nokia 3310… Here, iPhone, Samsung Galaxy and Nokia 3310 are concrete things, device is abstract.

2.4 Polymorphism 9

Polymorphism is the provision of a single interface to entities of different types. A polymorphic type is one whose operations can also be applied to values of some other type, or types.


What it do? We will explain how to work in the same manner with different objects, which define a specific implementation of some abstract behavior.


Example: All animal can speak, but dogs woof, cats meow, and ducks quack

There are two types of polymorphism

  • Overloading (compile time polymorphism): methods have the same name but different parameters.
  • Overriding (run time polymorphism): the implementation given in base class is replaced with that in sub class.


Example 10: Let us Consider Car example for discussing the polymorphism. Take any brand like Ford, Honda, Toyota, BMW, Benz etc., Everything is of type Car.
But each have their own advanced features and more advanced technology involved in their move behavior.

3. Concepts

Learn Object Oriented Programming though Mario Game

3.1. Object 11

Objects are key to understanding object-oriented technology. Look around right now and you’ll find many examples of real-world objects: your dog, your desk, your television set, your bicycle.

In mario world,


Mario is an object. Goomba is an object. Koopa is also an object.

Even a coin and a pile are objects

Software objects are conceptually similar to real-world objects: they too consist of state and related behavior.

An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages). Methods operate on an object’s internal state and serve as the primary mechanism for object-to-object communication. Hiding internal state and requiring all interaction to be performed through an object’s methods is known as data encapsulation — a fundamental principle of object-oriented programming.

In Mario world,


Mario has some fields like position (which indicate where Mario stands), state (which indicate whether Mario alive), and some methods like walk , fire or jump.


Goomba has some fields like position (which indicate where Goomba stands), state (which indicate whether Goomba die), and direction (which indicate the direction Goomba moves). Goomba has move method, and jumped_on method (which occurs when it is jumped on by Mario) (Poor Goomba!)

3.2 Class 12

inheritance, abstract, interface, object relationships

Challenge

Object

Task 1: With boiler plate code, make an gif image (32×32) Mario fire ball and jump to get coins

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

Visitor Pattern

Intuitive

Definition 1

In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying those structures. It is one way to follow the open/closed principle.

Example Code