OOP Notions that are Important

OOP ( Object-oriented programming) is Object Power

Python has a Standard Library consisting of several built-in functions and many modules. Built-in functions provide programmers with abstracted functions for common programming tasks, like returning the length of an object(len()), or, like open() for opening a file, one can simply type the function: open(“< file_location >”). A module has to be imported before a program can use the classes and functions of that module. An import statement should be written at the top of a program. For example: import turtle. You can import only a part of a module, like a certain function or class, you can use the 'from' keyword. For example: from < module > import < Class_name > . We can also import our own modules and classes with the import keyword.

Is the act of representing essential features without including the background details or explanations. There is no need to necessarily understand how a module or a built-in function works at a low level in order to use it or experiment with it, so long as we carefully read the documentation.

An exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program's instructions. When a Python script raises an exception, it must either handle the exception immediately otherwise it terminates and quits.

More info:

Python Exceptions Handling

A Classputs functions and variables together in a way that they can see each other and work together, be replicated, and altered as needed, and not when unneeded.A class is like a Blueprint. It describes how to make something. Supposed you want a car with different color and bigger wheels. We could use a class to describe the attributes and functions as guide to make a new car. Then you will create an instance or a new car that will use this attribute to add the different color and bigger wheel. It will still be a car but with unique attributes and functions.

A class is a block of code including a constructor which defines how an object or instance of that class will be created and what variables it will have, and also functions (referred to as methods) defining the available behaviors of objects of that class. The class definition code serves as a model and does not really do anything -- it is only when an object of that class is initialized that any functions of a class actually get used

Example of a Class & Instances structure:

Class and Instances structure:

When a new instance of a class is created, the __init__() function (constructor) defined inside of the class initializes new space in memory for the object (or instance) of that class to run. You can create lots of objects from that blueprint also known as an Instance. The instance will have the attributes and variable from the class blueprint. Instance variables are defined inside a method, normally __new__ or __init__, and they are local to that instance. Instance variables are always prefixed with the reserved word self. They are typically introduced and initialized in a constructor method named __init__. Object with (self) self is an example and can be call anything: Even though self is not a keyword, it is a convention that is used by most Python programmers.

					class Student:
						NUM_GRADES = 5
						def __init__(self, name):
							self.name = name
							self.grades = []
							for i in range(Student.NUM_GRADES):

The PVM (Python Virtual Machine) automatically calls the constructor method when the programmer requests a new instance of the class, as follows:

s = Student('Mary')

The constructor method always expects at least one argument, self. When the method is called, the object being instantiated is passed here and thus is bound toself throughout the code. Other arguments may be given to supply initial values for the object’s data Constructor.

When creating an instance method, the first parameter is always self. You can name it anything you want, but the meaning will always be the same, and you should use self since it's the naming convention. self is (usually) passed hiddenly when calling an instance method; it represents the instance calling the method.

					class Inst:

						def __init__(self, name):

						    self.name = name

						def introduce(self):
						    print("Hello, I am %s, and my name is "
						    %(self, self.name))

Now to call this method, we first need to create an instance of our class. Once we have an instance, we can call introduce() on it, and the instance will automatically be passed as self:

myinst = Inst("Test Instance")
otherinst = Inst("Another instance")

myinst.introduce()# outputs: Hello, I am < Inst object at x >, and my name is Test Instance

otherinst.introduce()# outputs: Hello, I am < Inst object at y >, and my name is An other instance

As you see, we're not passing the parameter self, it get's hiddenly passed with the period operator; we're calling Inst class's instance method introduce, with the parameter of myinst or otherinst. This means that we can call Inst.introduce(myinst) and get the exact same result.

The idea of class method is very similar to instance method, only difference being that instead of passing the instance hiddenly as a first parameter, we're now passing the class itself as a first parameter.

						class Cls:

							def introduce(cls):
								print("Hello, I am %s!" %cls)

Since we're passing only a class to the method, no instance is involved. This means that we don't need an instance at all, we call the class method as if it was a static function:

Cls.introduce() # same as Cls.introduce(Cls)

# outputs: Hello, I am < class ' Cls ' >

Notice that again Cls is passed hiddenly, so we could also say Cls.introduce(Inst) and get output "Hello, I am < class 'Inst' >. This is particularly useful when we're inheriting a class from Cls:

					class SubCls(Cls):


					SubCls.introduce() # outputs: Hello, I am <class 'SubCls'>

Similar to the idea of inheritance of visual properties in CSS -- except that in CSS inheritance is assumed to be true for any new statements/objects unless explicitly stated otherwise. In Python, there is a particular syntax, described below, for defining the child-parent relationship of classes. In both languages, inheritance offers similar benefits, in that can be used to eliminate unnecessary code (in Python, this has to do with the fact that we are reusing the parent class code), and can enhance readability.

Here is an example involving inheritance:

					class Parent():
						def __init__(self, last_name, eye_color):
							self.last_name = last_name
							self.eye_color = eye_color

					class Child(Parent):
						def __init__(self, last_name, eye_color, number_of_toys):
							Parent.__init__(self, last_name, eye_color)
							self.number_of_toys = number_of_toys

subclass ("child" class) that inherits attributes and behaviors (i.e. class variables, instance variables, and methods) of an already existing class ("parent" class).

Servers in More Detail

Network is a group or system of interconnected people or things. They are not connected directly. The idea of a network is over 3000 years old. A Node: a point at which lines or pathways intersect or branch; a central or connecting point. Latency: How much time it takes for a packet of data to get from one designated point to another. Measure in milliseconds. 1000 mls = 1 sec. Bandwidth: refers to the amount of information that can be transmitted over a network in a given amount of time, usually expressed in bits per second or bps. It is often confused with speed. Unit information divided by units of time. mbps = million bits per second. Bit: The smallest unit of computer memory. A bit holds one of two possible values, either of the binary digits 0 or 1.

Language of communication among computing devices. A network protocol facilitates device identification and data transfer. The TCP/IP Internet protocols, a common example, consist of: Transmission Control Protocol (TCP), which uses a set of rules to exchange messages with other Internet points at the information packet level. Internet Protocol (IP), which uses a set of rules to send and receive messages at the Internet address level. HyperText Transfer Protocol, HTTP is the underlying protocol used by the World Wide Web. HTTP defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands.

A cache (pronounced like cash) is something that stores data so that you don't have to retrieve it later. It can be used to make data requests faster.

An HTTP client sends an HTTP request to a server in the form of a request message which includes following format: The Request-Line begins with a method token, followed by the Request-URI and the protocol version.

Example: http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/(The request header looks like this):

Request Header

The first line of the HTTP request is called the request line and consists of 3 parts:

  • The "method" indicates what kind of request this is. Most common methods are GET, POST and HEAD.
  • The "path" is generally the part of the url that comes after the host (domain). For example, when requesting "http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/" , the path portion is "/tutorials/other/top-20-mysql-best-practices/".
  • The "protocol" part contains "HTTP" and the version, which is usually 1.1 in modern browsers.

Request and Response Example:

Server Request and Response

After the browser sends the HTTP request, the server responds with an HTTP response excluding the content, it looks like this:

Request & Response
Note: Server in the header could potentially give this info to a hacker The first piece of data is the protocol. This is again usually HTTP/1.x or HTTP/1.1 on modern servers. The next part is the status code followed by a short message. Code 200 means that our GET request was successful and the server will return the contents of the requested document, right after the headers.

We all have seen "404" pages. This number actually comes from the status code part of the HTTP response. If the GET request would be made for a path that the server cannot find, it would respond with a 404 instead of 200. This is a list of HTTP status messages that might be returned:

  • 200's are used for successful requests.
  • 300's are for redirections.
  • 400's are used if there was a problem with the request.
  • 500's are used if there was a problem with the server.

You can find the complete list of HTTP status codes with their explanations here.

In computer science, data validation is the process of ensuring that a program operates on clean, correct and useful data. It uses routines, often called "validation rules", "validation constraints" or "check routines", that check for correctness, meaningfulness, and security of data that are input to the system. There are several reasons that servers should validate data received by clients. One reason is site security: in order to prevent web applications and databases from being hacked, manipulated, or broken by malicious clients, servers should be able recognize bad input and deal with it appropriately. Bad data may take the form of any user input, including HTTP GET parameters in a URL or HTML form data. As a countermeasure to malicious activity, web applications should verify all data inputs on the server-side to make sure that it is of the correct type and within the constraints expected by the web application.

An equally important reason to validate user input is to ensure a favorable user experience of web apps. For example, the payment form of an online store should check the format and length of a credit card number to ensure that it is a valid card number. Imagine what happens when a user accidentally omits a number from her credit card -- the server should be able to return the form to the user with a message to re-enter the card number (in many cases the returned form should also preserve the data previously submitted by the user, although this may not be good practice for credit card numbers). If a customer is met with a blank form or has to make a phone call to the online store to confirm that their order was received, chances are they’ll simply take their business elsewhere.

Avoiding repetition is important for two main reasons: First, it reduces the opportunity to make a mistake when writing code because there is less code to write and second, like CSS, it allows us to more easily make changes while keeping the content consistent. Programmers use HTML templates for a couple of reasons: they allows us to avoid repetition and inforce consistency. Templates are libraries that allow programmers to efficiently build complicated strings, most commonly HTML strings. HTML Templates also allow programmers to keep HTML separate and avoids repetition from the files containing their web app code, as this is generally considered a best practice.

Go Explore!

Responsive Web Design (RWD) is an approach to web design aimed at crafting sites to provide an optimal viewing and interaction experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from desktop computer monitors to mobile phones).

More Resources:
Dash by General Assembly is an online tutorial to help you learn HTML, CSS, and JavaScript and create websites from scratch. I was able to learn a lot about RWD from this website.


JavaScript is the programming language of HTML and the Web. Is an object-oriented programming language that is used to make the web browsers neat and more interactive. Javascript is an interpreted language so no special program is needed to run the code. Just a text editor and web browser is enough, thus making javascript one of the easiest languages to learn and code. In fact, JavaScript's power comes from its ability to manipulate the DOM, which is essentially a JavaScript object. When JavaScript makes something interesting happen on a website, it's likely the action happened because JavaScript changed the DOM.

More Resources:
The first lesson of JavaScript Basics from Udacity was a great resouce on how to implement some of these scripts.

JavaScript Basics (you've already taken the first lesson)

jQuery jQuery is a common JavaScript library for reading and making changes to the DOM and the DOM can change. jQuery is fast and easy to use, but it doesn't do anything you can't accomplish with vanilla (regular) JavaScript.

More Resources:
A great place to find out how to hide, show, or toggle your div with jQuery

Random Snippets

User Comments


Anonymous Wrote on 12/14/2017 at 10:02 UTC:
help essay writing <a href=https://buyessays.us.com>order essay</a> buy essay papers <a href=https://buyessays.us.com>order essay online cheap quick</a>
Anonymous Wrote on 12/14/2017 at 10:01 UTC:
ecgqex <a href=http://viagralbc.com>alternatives to viagra</a>
Anonymous Wrote on 12/14/2017 at 09:57 UTC:
scyksn <a href=http://cialislbc.com>cialis online</a>
Anonymous Wrote on 12/14/2017 at 09:36 UTC:
v <a href= http://levitralbc.com >generic levitra</a> conversation of <a href=http://levitralbc.com>buy levitra online</a> levitra for sale http://levitralbc.com
Anonymous Wrote on 12/14/2017 at 09:33 UTC:
h http://cialislbc.com cialis canada <a href= http://cialislbc.com >buy cialis online</a> trees <a href=http://cialislbc.com>buy cialis online</a> tadalafil for sale
Anonymous Wrote on 12/14/2017 at 09:28 UTC:
a <a href= http://levitralbc.com >cheap levitra</a> see directly <a href=http://levitralbc.com>levitra cost</a> viagara cialis levitra http://levitralbc.com
Anonymous Wrote on 12/14/2017 at 09:26 UTC:
<a href="http://pokpokkokosingle.ru/">pokpokkokosingle</a>
Anonymous Wrote on 12/14/2017 at 09:20 UTC:
Слышали о сайтике <a href=http://kompleks-parking.ru/>http://kompleks-parking.ru/</a> обалденный ресурс
Anonymous Wrote on 12/14/2017 at 09:19 UTC:
<a href="http://pokpokkokosingle.ru/">pokpokkokosingle</a>
Anonymous Wrote on 12/14/2017 at 09:18 UTC:
i http://cialislbc.com cialis online canada <a href= http://cialislbc.com >cialis online</a> gentle <a href=http://cialislbc.com>buy cialis</a> cialis canada
Anonymous Wrote on 12/14/2017 at 09:16 UTC:
http://nqjehit.ynemy.ru/93061.aspx http://qmbuxrdl.ynemy.ru/foto-golyh-krasavic-na-more.html <a href=http://fcmljt.ipekito.ru/2017/12/14-3AXrspK.php>KecubMib obtait ves</a> <a href=http://qmbuxrdl.ynemy.ru/foto-seks-jenshchina-35-let.html>unreami Lodadeandy Engarphag</a> <a href=http://abir.iwemybif.ru/2017-12-14-72270.htm>Renuenenue Absofiz helve</a> Inhelvege peal Sego
Anonymous Wrote on 12/14/2017 at 08:59 UTC:
rgnxur <a href=http://levitralbc.com>generic levitra</a>
Anonymous Wrote on 12/14/2017 at 08:49 UTC:
bhhigq <a href=http://levitralbc.com>cheap levitra</a>
Anonymous Wrote on 12/14/2017 at 08:46 UTC:
<a href="http://mangabrazin.info">игровые автоматы бесплатно</a>, http://mangabrazin.info - игровые автоматы играть бесплатно, http://mangabrazin.info - игровые автоматы на реальные деньги
Anonymous Wrote on 12/14/2017 at 08:31 UTC:
y http://viagralbc.com generic viagra <a href= http://viagralbc.com >buy viagra</a> eat <a href=http://viagralbc.com>buy cheap viagra</a> herbal viagra
Anonymous Wrote on 12/14/2017 at 08:28 UTC:
cash advance <a href="https://cashadvance.us.org">cash loans</a> loan cash <a href=https://cashadvance.us.org>cash advance</a>
Anonymous Wrote on 12/14/2017 at 08:24 UTC:
a <a href= http://cialislbc.com >buy cialis online</a> while such <a href=http://cialislbc.com>generic tadalafil</a> cialis patent http://cialislbc.com
Anonymous Wrote on 12/14/2017 at 08:20 UTC:
comment6, http://levitralbc.com cheap levitra, 8[[[,
Anonymous Wrote on 12/14/2017 at 08:16 UTC:
y http://cialislbc.com cialis canada <a href= http://cialislbc.com >buy cialis online</a> expression <a href=http://cialislbc.com>additional reading</a> cialis for prostate
Anonymous Wrote on 12/14/2017 at 07:57 UTC:
pbklbk <a href=http://levitralbc.com>levitra</a>
Anonymous Wrote on 12/14/2017 at 07:55 UTC:
comment4, http://cialislbc.com cialis online, 8-DD,
Anonymous Wrote on 12/14/2017 at 07:45 UTC:
<a href=http://sporteshop.eu/>http://sporteshop.eu/</a> HexFeenBeill, <a href="http://sporteshop.eu/puma-herren-carson-2-knit-outdoor-fitnessschuhe/">Puma Herren Carson 2 Knit Outdoor Fitnessschuhe</a>
Anonymous Wrote on 12/14/2017 at 07:44 UTC:
vowtdq <a href=http://cialislbc.com>cheap cialis</a>
Anonymous Wrote on 12/14/2017 at 07:31 UTC:
http://dpqg.ipekito.ru/30713.aspx http://usoh.ipekito.ru/2017-12-14/96726.php http://hohomutuz.tosopeni.ru/2017/12/14_onlayn-zayavki-s-plohoy-kreditnoy-istoriey.asp http://ifor.guvobyme.ru/2017-12-14_67369.html http://ghfzcn.ynemy.ru/2017-12-14_vostochnoe-porno-chitat.php <a href=http://gyfa.wigyz.ru/2017/12/14-lesbiyanok-stanovitsya-blagodarya-porno.aspx>SAWN tep wellInjentCot</a> <a href=http://osyqujida.sisox.ru/90207.asp>lataky Wonagianda intams</a> <a href=http://ewor.ipekito.ru/AhSg.aspx>emBelty choify squimb</a> Nox bab heseeronry
Anonymous Wrote on 12/14/2017 at 07:29 UTC:
comment4, http://levitralbc.com buy levitra online, 22060,