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):
								self.grades.append(0)
					

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:

							@classmethod
							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):

						pass

					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.

Dash

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


Login


Anonymous Wrote on 06/23/2017 at 23:22 UTC:
This is a comment to the Javi's Important Notions admin. Your website is missing out on at least 300 visitors per day. Our traffic system will dramatically increase your traffic to your website: http://v-doc.co/nm/jkfq0 - We offer 500 free targeted visitors during our free trial period and we offer up to 30,000 targeted visitors per month. Hope this helps :) Unsubscribe here: http://pcgroup.com.uy/2a
Anonymous Wrote on 06/20/2017 at 01:16 UTC:
This is a comment to the Javi's Important Notions webmaster. Your website is missing out on at least 300 visitors per day. Our traffic system will dramatically increase your traffic to your website: http://pcgroup.com.uy/15 - We offer 500 free targeted visitors during our free trial period and we offer up to 30,000 targeted visitors per month. Hope this helps :) Unsubscribe here: http://pcgroup.com.uy/2a
Anonymous Wrote on 06/16/2017 at 22:34 UTC:
I came across your Javi's Important Notions website and wanted to let you know that we have decided to open our POWERFUL and PRIVATE web traffic system to the public for a limited time! You can sign up for our targeted traffic network with a free trial as we make this offer available again. If you need targeted traffic that is interested in your subject matter or products start your free trial today: http://aici.cf/2t1 Unsubscribe here: http://priscilarodrigues.com.br/url/11
Anonymous Wrote on 06/04/2017 at 00:44 UTC:
I discovered your Javi's Important Notions page and noticed you could have a lot more traffic. I have found that the key to running a website is making sure the visitors you are getting are interested in your subject matter. We can send you targeted traffic and we let you try it for free. Get over 1,000 targeted visitors per day to your website. Check it out here: http://priscilarodrigues.com.br/url/v Unsubscribe here: http://tdil.co/5p
Anonymous Wrote on 05/30/2017 at 22:20 UTC:
I discovered your Javi's Important Notions page and noticed you could have a lot more traffic. I have found that the key to running a website is making sure the visitors you are getting are interested in your subject matter. We can send you targeted traffic and we let you try it for free. Get over 1,000 targeted visitors per day to your website. Check it out here: http://magc.co/7fe Unsubscribe here: http://tdil.co/5p
Anonymous Wrote on 05/27/2017 at 17:58 UTC:
I discovered your Javi's Important Notions page and noticed you could have a lot more traffic. I have found that the key to running a website is making sure the visitors you are getting are interested in your subject matter. We can send you targeted traffic and we let you try it for free. Get over 1,000 targeted visitors per day to your website. Start your free trial: http://tdil.co/3p Unsubscribe here: http://acortarurl.es/97
Anonymous Wrote on 05/16/2017 at 08:21 UTC:
I came across your Javi's Important Notions website and wanted to let you know that we have decided to open our POWERFUL and PRIVATE website traffic system to the public for a limited time! You can sign up for our targeted traffic network with a free trial as we make this offer available again. If you need targeted traffic that is interested in your subject matter or products start your free trial today: http://pcgroup.com.uy/15 Unsubscribe here: http://acortarurl.es/97
Anonymous Wrote on 05/06/2017 at 10:15 UTC:
This is a comment to the Javi's Important Notions webmaster. Your website is missing out on at least 300 visitors per day. Our traffic system will dramatically increase your traffic to your site: http://priscilarodrigues.com.br/url/v - We offer 500 free targeted visitors during our free trial period and we offer up to 30,000 targeted visitors per month. Hope this helps :)
Anonymous Wrote on 05/02/2017 at 13:35 UTC:
This is a comment to the Javi's Important Notions admin. Your website is missing out on at least 300 visitors per day. I have found a company which offers to dramatically increase your traffic to your website: http://tdil.co/3p - They offer 500 free targeted visitors during their free trial period and I managed to get over 30,000 visitors per month using their services, you could also get lot more targeted visitors than you have now. Hope this helps :)
Anonymous Wrote on 03/12/2017 at 13:53 UTC:
Hello my name is Deanna Brady and I just wanted to send you a quick message here instead of calling you. I came to your Javi's Important Notions website and noticed you could have a lot more visitors. I have found that the key to running a popular website is making sure the visitors you are getting are interested in your subject matter. There is a company that you can get keyword targeted traffic from and they let you try the service for free for 7 days. I managed to get over 300 targeted visitors to day to my site. http://s.t0m-s.be/5H
Anonymous Wrote on 02/12/2017 at 23:28 UTC:
Hello my name is Sabrina Warren and I just wanted to drop you a quick note here instead of calling you. I came to your Javi's Important Notions website and noticed you could have a lot more visitors. I have found that the key to running a successful website is making sure the visitors you are getting are interested in your subject matter. There is a company that you can get keyword targeted traffic from and they let you try their service for free for 7 days. I managed to get over 300 targeted visitors to day to my site. http://www.v-diagram.com/2syzv Sabrina Warren http://deaf.im/zyr-x
Anonymous Wrote on 02/06/2017 at 07:24 UTC:
I decided to leave a message here on your Javi's Important Notions page instead of calling you. Do you need more likes for your Facebook Fan Page? The more people that LIKE your website and fanpage on Facebook, the more credibility you will have with new visitors. It works the same for Twitter, Instagram and Youtube. When people visit your page and see that you have a lot of followers, they now want to follow you too. They too want to know what all the hype is and why all those people are following you. Get some free likes, followers, and views just for trying this service I found: http://hothor.se/2rsx5
Anonymous Wrote on 01/23/2017 at 07:54 UTC:
герпес лечить под арко http://lapidapi.xyz/index.php?topic=6099 герпес в крови лечение g6687hjhk7
Anonymous Wrote on 01/12/2017 at 12:39 UTC:
example of an abstract for a research paper http://deryugina.com/go?http://divalith.us
Anonymous Wrote on 11/29/2016 at 08:01 UTC:
Great internet websitewebsite! It looks extremely expert! Maintain the great job! Benedict http://www.wranglemath.com/wrangWiki/index.php?title=Nba_live_mobile_moves_-_A_Close_Anaylsis_on_What_Works_and_What_Does_not
Anonymous Wrote on 11/21/2016 at 19:52 UTC:
<a href="http://9zw3rwykwv70dgbj4.com">ow91rjxbf7</a> <a href="http://85hyswrh5.com">d42i69s8rc</a> <a href="http://cm7f45yn550.com">nizo62zd9i</a> [url=http://ttaoo1ylbttiob.com]j51vu8b480[/url] [url=http://vpsj8hp2.com]wvlhwkdix1[/url] [url=http://jl9qym67vq9y4.com]cqfaesc358[/url] http://zo3evpuvyfih71poij.com http://aeewciuh9queh4g2a7gh.com http://99zxq7e0yx3.com
Anonymous Wrote on 11/17/2016 at 01:45 UTC:
Did you just create your new Facebook page? Do you want your page to look a little more "established"? I found a service that can help you with that. They can send organic and 100% real likes and followers to your social pages and you can try before you buy with their free trial. Their service is completely safe and they send all likes to your page naturally and over time so nobody will suspect that you bought them. Try their service for free here: http://tapeciarnia.waw.pl/1xcx2
Anonymous Wrote on 11/04/2016 at 03:11 UTC:
Hi my name is Joselyn and I just wanted to send you a quick note here instead of calling you. I discovered your Javi's Important Notions page and noticed you could have a lot more visitors. I have found that the key to running a popular website is making sure the visitors you are getting are interested in your subject matter. There is a company that you can get keyword targeted traffic from and they let you try their service for free for 7 days. I managed to get over 300 targeted visitors to day to my site. http://brt.st/5ms0 - Unsubscribe here: http://aici.cf/3
Anonymous Wrote on 10/08/2016 at 16:45 UTC:
Hello.This post was extremely interesting, especially since I was looking for thoughts on this topic last Saturday. nike tennis donna http://www.eumill.it/victory.cfm?fg=nike-tennis-donna
Anonymous Wrote on 10/06/2016 at 21:10 UTC:
I was just looking for this information for some time. After 6 hours of continuous Googleing, finally I got it in your web site. I wonder what is the lack of Google strategy that do not rank this kind of informative web sites in top of the list. Normally the top web sites are full of garbage. nik filter http://www.eumill.it/victory.cfm?fg=nik-filter
Anonymous Wrote on 10/03/2016 at 21:14 UTC:
There is noticeably a bundle to know about this. I suppose you made certain good points in features also. Nike Air Max 90 Herr Running Skor Vit Blå Svart Apelsin http://www.dekko.se/web/hem/whole.asp?ko=Nike-Air-Max-90-Herr-Running-Skor-Vit-Bla-Svart-Apelsin
Anonymous Wrote on 10/02/2016 at 21:59 UTC:
I'm still learning from you, as I'm making my way to the top as well. I absolutely enjoy reading all that is written on your blog.Keep the tips coming. I enjoyed it! Billiga Nike Air Max Billigt Sverige http://www.fjallhusistoten.se/filarkiv/shoxnz.asp?gul=Billiga-Nike-Air-Max-Billigt-Sverige
Anonymous Wrote on 09/07/2016 at 17:57 UTC:
Hi my name is Teresa and I just wanted to send you a quick message here instead of calling you. I came to your Javi's Important Notions page and noticed you could have a lot more visitors. I have found that the key to running a popular website is making sure the visitors you are getting are interested in your website topic. There is a company that you can get keyword targeted traffic from and they let you try the service for free for 7 days. I managed to get over 300 targeted visitors to day to my website. http://rb2.in/4nS
Anonymous Wrote on 09/03/2016 at 05:30 UTC:
Great looking site. Think you did a lot of your very ownyour very own coding nba 2k17 coins http://jired1.com/boomers/forum/topic/30343
Anonymous Wrote on 09/01/2016 at 08:50 UTC:
Thank you! It is an incredible website!. buy nba 2k17 mt http://weshinemusic.com/blogs/5664/1788/nba-2k17-coins-for-sale-knowing-the-xbox-e-74-error