SEC S20W5|| Sharing resources and OOP using PHP Part -3

in #dynamicdevs-s20w52 months ago (edited)

Hi friends, after reading around I am interested in participating in an amazing challenge this week. The challenge is titled: Sharing resources and OOP using PHP Part -3 by Mr. @kouba01 and Mr. @starrchris following the contest link: SEC S20W5|| Sharing resources and OOP using PHP Part -3

Previously I also invited other friends such as Mr. @irawandedy, Mr @muzack1 , sir @sisol, sir @aneukpineung78 and my friend @cymolan.

My Business Ideas  Registration, License, and Taxes (3).jpg

Part 1: Theoretical Questions

A. Object Oriented Programming: Explain in detail what Object-Oriented Programming is, what are its uses, and some of its use cases.

Well, first I will explain a little about the definition. Object-Oriented Programming (OOP) is a programming paradigm that is indispensable in the world of software development. Object Oriented Programming (OOP) is a way of writing code where we utilize classes and objects. Well, the class is a blueprint or template, while the object is a process of creating a unique object that utilizes the module template every time the module is called or often called the instantiation of the class. A simple example is, we consider the class “Car” which can have attributes such as “speed” and “color”, as for methods we can take examples such as “run()” or “stop()”. Then the object that we suppose as “Car” can have a black or gray color, well it all depends on the instantiation.

While the uses of OOP are many, for example Encapsulation which here will make it possible to wrap data and functions with the main purpose of not being able to be accessed carelessly from outside there. Inheritance, which here will create a new class with the intention of inheriting properties and methods from different classes, the goal is to reduce code that will be repeated. Furthermore, it is utilized as Polymorphism, which here will create functions with similar names, but have different properties in other classes. After that, there are also those that are used as Abstraction, which will simplify the complexity of only displaying what is really needed and hiding unnecessary details.

Here I give an example of a use case of OPP:

  • In the scope of shopping:
    In this application, there are usually objects such as Product, Category, and User.
    In the product, there must be attributes such as price and stock.
    One will be able to add a product to the cart and then proceed with the purchase.

  • In the scope of Games:
    We can easily imagine a character in a game.
    Then we consider the object as a character, of course the character has attributes such as strength and speed.
    So that the character can make an action, for example, such as being able to jump or being able to attack enemies.

  • Within the scope of school applications
    In an application that has a school, of course there can manage student data and data from teachers.
    Objects in the application are students, teachers, schools, offices and classes.
    So in these students, of course, attributes such as name, address and age, which can create registration methods, for example, registration to become a new student. While teachers also have methods such as teaching in order to provide good and quality lessons to the class.

How to give an example in the following PHP code:
d1.jpg

  • first I created a Student Class, which in the Student class will define the blueprint for the student object. Sebanyak 3 atribut yang saya cantumkan seperti : nama, kelas, dan nilai.

The __construct() in the code is a special method with the aim of being able to set the initial value of the attribute when the object is later created.

After that, create a method which in the code above is infoSiswa() This serves to display information about students such as their names, classes, and grades. At cekKelulusan() there functions so that it can choose whether the student passes or not. Then the student passes if he has a score of >= 75.

Next, I created 2 objects, namely student1 and student2, at new Siswa("Walictd", "XII IPA 1", 85) there we create a student object named Walictd in class XII IPA 1 who has a score of for example 85. At siswa1->infoSiswa() it intends to call the method in order to display the Walictd information. siswa1->cekKelulusan() check whether Walictd passed or failed.

Here are the results:
image.png

B. Application Programming Interface: Write intensively on what you understand about APIs, Give five different examples and their use cases.

For Understanding API or Application Programming Interface, it is a bridge that will make two applications that can communicate. API can also be called a mechanism that allows 2 software components, these components communicate with each other by utilizing a series of definitions and protocols. A simple example is, an application where we will request data from another service by means of its API, for example we will retrieve weather data through the weather service.

Here are 5 examples of APIs that we often find everyday and their use cases as well:

  • YouTube Data API, which in its use case that the API here ensures an application so that it can retrieve video data from YouTube, for example, it can display a list of trending videos, video details, or even the number of likes and views as well. So this must be very useful for an application that wants to display content from YouTube directly or automatically. In addition, its use is usually on music websites that want to display a trending video from someone's favorite YouTube channel.
  • WhatsApp Business API, which here is often used by businesses with the intention of being able to send messages automatically to customers by utilizing WhatsApp. A small example, when we want to order tickets, the system can automatically send booking information directly to our WhatsApp. The easiest thing we can find is a “Chatbot” from customer service that can usually provide info on ordering goods.
  • OpenWeatherMap API, usually here will be used to retrieve info about the weather in a location. For example, the weather application will display daily weather forecasts in our city, for example in Indonesia. Usually by utilizing the OpenWeatherMap API to get data such as temperature, humidity, and others. While its use can be found in applications contained in our cellphones that often display “Today's weather in North Aceh: Sunny with a temperature of 31°C”.
  • Giphy API, here we often find cases of use to ensure an application in searching and then displaying animated GIFs from Giphy. Generally used in chat applications such as social media that add GIFs as expressions. An example of its use that we often find is the feature contained in the chat application that allows you to search for and send funny GIFs to respond to your friends.
C. Web Hosting Vs Local Host: Explain What do you understand about local hosts? What do you understand about web hosting? Give five advantages and five disadvantages of web hosting and local hosts.

First of all, I will explain that the meaning of a local host is a step to be able to run a website or an application on our computer. A simple example is when we utilize a software such as XAMPP or WAMP with the aim of being able to create a server on the laptop / PC that we have. Its usefulness is to be able to develop and test a website before going live to the public or we often demo it.

Meanwhile, web hosting is a service that will usually provide a container in order to store our website on the internet. Well, from there we can take advantage of web hosting providers such as our website will be accessible to anyone and anywhere in the world through internet access.

Here are the advantages and disadvantages of Local Hosts for us.
Benefits:

  • Free, In utilizing this Local Host we are not charged anything either monthly or annually, then we only need to install the software on the computer we have.
  • Fast, Of course in this testing and development we can do it without having to connect the internet.
  • Full Control, We can manage everything according to what we want.
  • Privacy, Here our data does not need to be uploaded to the internet, of course it will be more secure and reliable.
  • Easy to Learn, Then this is what we need most because it is suitable for learning like me.

Loss:

  • Only for us, so here it can only be accessed from our own computer, then of course it cannot be accessed by others.
  • Risk of Data Loss, Now this is the most horrifying if not backed up because if our computer is damaged then all data may be lost.
  • Unstable, because it cannot always be online so there is certainly no guarantee that our website.
  • Difficult to Cooperate, of course it will be difficult to cooperate with other people.
  • Limited to Computer Specifications, Often if we have an old school computer with low specs it will be slow, so from here it will affect development.

Next Advantages and Disadvantages of Web Hosting

Benefits:

  • Access from Anywhere, of course, with the existence of the website, it can certainly be accessed by anyone and anywhere in the world.
  • The site is always online, well with the hosting provider, of course, it guarantees that the site we have remains online and can be accessed.
  • Better Security, By having a provider will usually offer more protection with the aim of our data.
  • Data Backup, well here many providers do backups automatically, so we can make sure our data is safe.
  • Technical Support, if a problem arises, we can get help from the support team.

Loss:

  • Monthly Fees, this is a disadvantage that is mainly about the usual that we have to pay in order to get hosting services every month.
  • Depending on the provider, if the provider is experiencing a problem, our site will usually have problems too.
  • Resource Limitations, It cannot be denied that there are usually storage limits or better known as bandwidth that is feasible to use.
  • Security Risks, Our data will be at risk such as data theft, it all happens if the provider has a data leak.
  • Complicated Setup, To want the best will definitely be complicated both in the initial setup may require time and technical knowledge.
D. cUrl: Why developers use curl, list and explain all curl use cases

Well, we know cURL or what it stands for, Client URL, then cURL is a tool that allows data exchange between servers using various protocols such as HTTP, HTTPS, FTP, and others. Most fundamentally, cURL will allow us to communicate with the server by specifying a location (it's all in the form of a URL) and the data we want to send. Usually a developer will utilize cURL due to its flexibility in managing sending data to retrieve or to send, even to download information from a server. It also supports several operating systems such as Windows, Linux, and macOS, making it easy for developers on various platforms to use.

The benefits are:

  • Automation, cURL certainly allows automation in several tasks related to data transmission, a simple example is when we download or upload a file, of course there is no manual interaction.
  • Protocol Flexibility, The support of various protocols, then with cURL being a tool has many uses for developers with the aim of handling various needs in communicating between servers.
  • API Testing, Developers can actually test this API in a direct way, meaning that there is no need to embrace the entire application, but just run a request on this cURL.

The following cURL Use Cases are easy to find:

  • API Testing, here cURL is utilized so that it can try API requests (eg GET, POST, PUT, DELETE) not necessarily by creating an interface application. then it greatly helps developers to ensure that the API works as desired.
  • Downloading and Uploading Files, Surely cURL here will be utilized in order to pull files from the internet or vice versa, namely uploading files to the server by utilizing protocols such as FTP or SFTP. A simple example, downloading an installer file from an official site or vice versa, namely by uploading files to a hosting.
  • Checking HTTPS Connections and SSL Certificates, here a developer utilizes cURL to see whether the SSL certificate on the website is valid or not, thus ensuring a secure connection between the server and the client.
  • Handling Proxy Requests, cURL here is actually very supportive for proxy users so that they can send HTTP / HTTPS requests through a proxy server, which can be utilized so that they can overcome geographical restrictions.
  • Data Transfer in Email Services, Now here cURL will support protocols such as SMTP, usually sending emails directly from a server via the command line, which is useful for testing or automatic notifications.

Part 2: Practice Questions

Hosting: Hosting the registration page, login page, and the page we created last week on the hosting site. (Notes: Infinityfree or 000webhost host the pages for free, but you are free to use any site you want)

To host all the code that we have created, we have to buy the domain first, or visit a free domain. For this time I will host the page for free with Infinityfree.

We will visit https://www.infinityfree.com/ with the aim of registering first. Then we will complete the registration process there.
image.png
Next we just choose to create an account. Next we choose a free package as below:

image.png
Then we continue by choosing the domain name that has been provided there as below until it is finished:

image.pngimage.png

Next I visited the file manager to upload all the php and css files there. Then I also uploaded the database files.

image.png|

Finally the Web was finished. You can check it by clicking the following link:
http://walictd.web1337.net

image.png

API: Get news data from your preferred News API, post news on your web page.

To get the API, I visited the web: https://newsapi.org/. After registering the account then we will copy the API code then we enter it into our code.

image.png

After running the merge on the web, finally the API can run smoothly.
image.png

@walictd (11).gif

Source :
https://steemit.com/dynamicdevs-s20w5/@starrchris/sec-s20w5-or-or-sharing-resources-and-oop-using-php-part-3
https://parsinta.com/articles/pemrograman-berorientasi-objek-di-php-hzcxd
https://wpwebinfotech.com/blog/object-oriented-programming-in-php/
https://aws.amazon.com/id/what-is/api/
https://herza.id/blog/kelebihan-dan-kekurangan-web-hosting/
https://developer.ibm.com/articles/what-is-curl-command/

Best Regard
@walictd
baawah.png

Sort:  
Loading...
TEAM 7

Congratulations!

THE QUEST TEAM has supported your post. We support quality posts, good comments anywhere, and any tags


postbanner.JPG

Curated by : @sduttaskitchen

Coin Marketplace

STEEM 0.26
TRX 0.21
JST 0.038
BTC 98006.84
ETH 3638.04
USDT 1.00
SBD 3.85