Subject
- Make a comparison of object-oriented and non-object-oriented programming concepts.
- In developing a property function class, when is a function overridden? Give an example of the case with a PHP script
- What impact does documenting a function or class that you develop have on software development?
- Create a superclass circle that contains a function to calculate the area. Then create a subclass to calculate the volume of the cylinder.
- Give your reasons for implementing the MVC (model view controller) pattern in web programming development.
- PHP Framework Interop Group on its website http://www.php-fig.org/psr/psr-1/ reviews the standardization of code writing. Give reasons why there needs to be standardization in code writing?
1. Comparison of OOP and Non OOP Concepts
Object Oriented Programming or OOP for short. In this paradigm, all data and functions/methods are packaged in classes or objects so that the documentation is neater. The following are the differences between OOP and Non OOP.
| OOP | NON OOP (Prosedural) |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Modularity, source code suatu class dapat ditulis dan dikelola secara independen dan tidak bergantung dengan class lainnya. Setelah dibuat, sebuah objek dapat dengan mudah melewati objek lainnya dalam sistem yang sama. | Tidak Modularity Tidak Independent |
| Informasi-bersembunyi, cara berinteraksi hanya dengan metode obyek, rincian implementasi internal tetap tersembunyi dari dunia luar ( Data tersemmbunyi dan tidak dapat diakses oleh fungsi eksternal ). | Informasi-terbuka, cara berinteraksi dengan fungsi atau method dan data bebas bergerak di sekitar sistem dari satu fungsi lain. |
| Code re-use, jika sebuah class sudah ada, Anda dapat menggunakannya kembali untuk obyek lainnya (inheritance). | Code-solid, |
| Debugging mudah, jika ada masalah pada objek tertentu, maka programmer dapat menghapusnya dan menggantinya dengan objek baru, konsep seperti ini sama halnya dengan seorang mekanik mengganti mur-baut yang sudah rusak pada mobil. | Debugging sulit, untuk skala besar Debugging mudah, untuk skala kecil |
| Fokus utama pada data yang sedang beroperasi. | Fokus utama pada fungsi dan prosedur yang beroperasi pada data. |
| Program besar terdiri dari unit kecil yang disebut class | Program besar terdiri dari unit kecil yang disebut fungsi/method |
| Data dan fungsi diperlakukan sebagai entitas terpisah | Data dan fungsi diperlakukan sebagai entitas terpisah |
| Program didesain untuk melakukan perluasan “Buttom Up” yaitu memuat prosedur-prosedur untuk menyelesaian tugas-tugas yang sederhana, kemudian menggabungkan prosedur-prosedur tersebut dalam prosedur yang lebih kompleks, sampai fungsionalitas yang ingin tercapai | Program didesain untuk melakukan pendekatan “Top Down” yaitu tugas-tugas kompleks dipecah menjadi bagian yang lebih kecil, sampai sub-tugas tersebut mudah diimplementasikan |
2. Using Override Function in Property Function Class Development
Overriding is used when we use the same method but have different implementations.
Case Study Using PHP Script
<?php
// Parent Class
class Hewan {
public $namahewan;
public function Jalan ($namahewan){
echo $namahewan." : hewan ini berjalan.";
}
}
// Child Class
class Burung extends Hewan {
public $namahewan;
public function Jalan ($namahewan){
echo $namahewan." : hewan ini terbang.";
}
}
}
//Mengeksekusi Object
$merpati = new Burung;
$merpati->Jalan('Merpati');
?>
3. The Influence of Documenting a Function or Class on Software Development
- Makes it easier to learn (understand the concept of the program being developed).
- Documentation is neater and more organized
- Makes debugging easier
- Makes it easier for programmers to develop both as a team and individually.
4. Implementation of Super class and Sub class
By creating a super class of a circle which contains a function to calculate the area. While the sub class is used to calculate the volume of the cylinder.
Example:
<? //super class
class lingkaran{
public $jari2;
public $luas = 0;
public function luasLingk(){
$luas =3.14 * $this->jari2 * $this->jari2;
return $luas;
}
}
//sub class
class tabung extends lingkaran{
public $tinggi;
public $volTabung = 0;
public function volume(){
$volTabung = $this->luasLingk() * $this->tinggi;
return $volTabung;
}
}
//object dari class lingkaran
$Lingkaran1=new lingkaran ();
echo "Jari-jari : ".Lingkaran1->jari2=27;
echo "<br>Luas lingkaran : ".$Lingkaran1->luasLingk();
echo "<br>";
//object dari class tabung
$tabung1 = new tabung();
echo "<br>Jari - jari : ".$tabung1->jari2=8;
echo "<br>Tinggi : ".$tabung1->tinggi=6;
echo "<br>Luas Alas : ".$tabung1->luasLingk();
echo "<br>Volume Tabung : ".$tabung1->volume();
?>
Output:
5. Reasons for Implementing the MVC (Model View Controller) Pattern in Web Development
The use of the MVC writing method makes it easier for developers to develop websites. In addition, by using the MVC structure, developers will easily trace the website if there is a programming error during the website development process.
MVC is a basic concept used by CodeIgniter. If you want to develop using this framework, it would be good if we first get to know the concept of MVC in Code Igniter. MVC stands for the terms Model, View, Controller. The supporting components of MVC include.
Model
Models are closely related to data that interacts directly with the database. In the model structure, the files contained in it are mostly text, XML files and web services. In this structure there is also a class that functions to create, update and delete data on the website
View
Unlike the model, the view is closely related to the appearance of the website displayed to the end user. The display can be a web page, rss, javascript and so on. Usually we are more familiar with the terms HTML, CSS and Javascript, well more or less the concept of View has a function like that. In the View structure, it is recommended that there is no logic process and data calculation process.
Controller
The controller functions as a liaison between data and view. In this process, there is a class that processes requests from the view into the data structure in the model. Similar to the provisions in the view, in the controller structure it is highly recommended that there is no logic process and data calculation. The controller itself has the task of providing variables to be displayed on the view and connecting the model to the database.
6. Why is it necessary to have code writing standardization?
Based on the PHP Framework Interop Group Review on its website http://www.php-fig.org/psr/psr-1/ , try to explain!
The reason is, because:
- Standardization is needed to facilitate development and quality improvement from generation to generation.
- Provides a guarantee of validity so that it is worthy of being studied.
- Have a reference for debugging the standard programs we use.
- To avoid conflicts of perception between programmers.
Reference
Difference between OOP and NON OOP:
- http://www.ctp.bilkent.edu.tr/ russell /java/LectureNotes/1_OOConcepts.htm
- http://www.slideshare.net/wahyusubuh8/pbo-perbandingan-antara-pemrograman-procedural-dengan-pemrograman-beroriantasi-produk?from_action=save
Implementation of the Override function:
- https://www.academia.edu/9435306/Laporan_Pemprograman_Berorientasi_Objek_INHERITANCE_
- http://diaryawal.blogspot.co.id/2013/05/mengenal-overriding-pada-komp-oop-php.html
Implementation of MVC in web programming development: