Ads

Ads

Translate

Tuesday, 29 October 2013

MVC Dalam Delphi Programming


Author : Muchammad Aly mBA, S.Kom      * Download (*.doc)
Dalam pembuatan aplikasi database dengan Delphi, umumnya kita menggunakan komponen-komponen database, baik berupa komponen koneksi (Misal: TAdoConnection, IBDatabase, dst),   turunan TDataset (Misal: TAdoTable,  TQuery, dst) atau kontrol databound (DBGrid, DBEdit, dst).
Dengan pendekatan pengembangan aplikasi seperti ini,  kita biasa menuliskan perintah sql, business logic, validasi input, pengaturan tampilan sekaligus dalam satu form (satu unit).
Pengembangan aplikasi ini mempunyai kelemahan dari satu sisi. Diantaranya:
  1. Sulit dikembangkan dalam suatu tim yang saling bekerja sama. Misalkan tim yang menangani desain tampilan, ketika menyisipkan/ mengedit kode-kode yang merubah tampilan sangat boleh jadi business logic menjadi ikut terpengaruh. Demikian juga ketika tim yang menangani  database, ketika dibutuhkan perubahan perintah sql, sangat boleh jadi tingkah laku form akan berubah.
  2. Sulit dimaintenance. Programmer yang meneruskan pengembangan aplikasi mau tidak mau harus memahami source code secara keseluruhan sebelum dapat ikut berpartisipasi. Hal ini disebabkan keterkaitan yang demikian erat logika pemrograman dalam satu form/satu unit. Satu perubahan yang kecil dapat mempengaruhi keseluruhan  tingkah laku form.
Untuk menghindari hal tersebut di atas dibutuhkan pemisahan penulisan source code dalam bagian-bagian tertentu. Salah satu metode pemisahan source code ini adalah dengan menggunakan paradigma MVC yang merupakan kependekan dari Model View Controller.

Pengertian MVC

Yaitu suatu istilah metode pengembangan / pembuatan aplikasi dengan memisahkan elemen-elemen penulisan source code menjadi tiga bagian, yaitu:

Model

Model di sini berperan sebagai representasi dari data yang terlibat dalam suatu proses transaksi. Setiap kali method / function dari suatu aplikasi butuh untuk melakukan akses ke dalam suatu data, maka function / method tersebut tidak langsung berinteaksi dengan sumber data tersebut melainkan harus melalui model terlebih dahulu. Secara praktis, dalam pemrograman database Delphi, model ini berwujud unit-unit yang berisi perintah SQL dan koneksi database.

View

View di sini berperan sebagai presentation layer atau pengatur user interface (tampilan) bagi user dari suatu aplikasi. Data yang dibutuhkan oleh user akan diformat sedemikian rupa agar dapat tampil dan dipresentasikan dengan format tampilan yang memang disesuaikan dengan kebutuhkan user, biasanya layer View juga bertugas untuk melakukan validasi data yang diinputkan user. Secara praktis, dalam pemrograman Delphi, view berwujud unit form  yang hanya berisi perintah-perintah yang berhubungan dengan efek tampilan dan bagaimana data itu ditampilkan.

Controller

Controller di sini berperan sebagai logic aspect dari suatu aplikasi / mengatur user flow. Controller lah yang akan menentukan bussiness process dari aplikasi yang dibangun. Controller akan merespon setiap inputan dari user dengan melakukan pemanggilan terhadap model dan view yang sesuai sehingga request / permintaan dari user tersebugt dapat terpenuhi dengan baik. Biasanya layer controller juga digunakan untuk mengatur ijin akses dan permission. Secara praktis, dalam pemrograman Delphi, controller dapat berupa unit yang berisi function / procedure yang berisi logika bisnis.

MVC dan MVP

MVP (Model View Presentation) adalah turunan dari MVC. Presentation mempunyai kesamaan fungsi dengan Controller. Perbedaan MVC dan MVP hanya terletak pada arah komunikasi  antar elemen. Pada MVC, Viewbisa langsung berkomunikasi dengan Model tanpa melalui Controller. Pada MVP, komunikasi View denganModel harus melalui Presentation.
Berikut ini ilustrasi yang menggambarkan perbedaan MVC dan MPV

Contoh PENERAPAN MVC dan MVP DALAM DELPHI PROGRAMMING

Pada contoh di atas, komunikasi antara View dan Model pada MVC  terjadi melalui penggunaan variabelSearchResult pada unit first_model.pas.
Pada contoh MVP di atas, komunikasi antara View ke Model terjadi melaui Presentation dengan kembalian nilai dari Presentation.
Karena perbedaan yang tipis antara MVP dan MVC, sebagian orang tetap menyebut MVP sebagai MVP. Untuk selanjutnya, pada tulisan ini, tidak dibedakan istilah antara MVC dan MVP

Penerapan dalam Source Code SMS Manager

Pada bagian ini saya memberikan salah satu penerapan paradigma MVC pada source code Project SMS Manager Power Logic sebagai contoh, dengan menggunakan:
  1. Satu Unit controller berlaku untuk seluruh unit view pada project, dengan nama con_SMSManager.pas
  2. Satu Unit Model berlaku dengan nama mod_SMSManager.pas.
Pada contoh kali ini source code yang akan terapkan paradigm MVC ada pada method :
procedure TfrmKirimSms.btnTampilkanClick(Sender: TObject);
pada unit ufrmKirimSms.pas  dengan source code sebagai berikut:
1     procedure TfrmKirimSms.btnTampilkanClick(Sender: TObject);
2     var
3       STampil,
4       qryWhere      : String;
5       sWaktuAwal,
6       sWaktuAkhir   : string;
7       TotalHalaman,
8       jmlData       : integer;
9     begin
10      if cbMarketing.ItemIndex=-1 then begin
11        MessageDlg(‘Isikan User ID dulu ..!’,mtWarning,[mbOK],0);
12        Exit;
13      end;
14
15      if edCustID1.Text <> ” then
16        qryWhere := ‘ and B.CUST_ID=’+quotedstr(Trim(edCustID1.Text))+”;
17
18      sWaktuAwal   := QuotedStr(FormatDateTime(‘yyyy-mm-dd hh:nn:ss’,dtTanggal1.DateTime));
19      sWaktuAkhir  := QuotedStr(FormatDateTime(‘yyyy-mm-dd hh:nn:ss’,dtTanggal2.DateTime));
20
21      //sudah digantikan model QueryCountLogSmsOut
22      if cbHalaman.Checked then
23      begin
24        SDataset := DBConn.NewDataset(‘select count(*) ‘+
25                           ’ from LOG_SMS_OUT A LEFT JOIN AKUN_CUST B on A.hp_tujuan=B.cust_hp where A.WAKTU_REQUEST between ‘+
26                           sWaktuAwal+’ and ‘+sWaktuAkhir+’ and A.USER_ID=’+
27                           quotedstr(cbMarketing.Items.Names[cbMarketing.ItemIndex])+’ ‘+qryWhere
28                           ,True);
29        try
30          JmlData := SDataset.Fields[0].AsInteger;
31        finally
32        end;
33      end;
34
35      TotalHalaman := Ceil(JmlData/PAGEVIEW);
36      lbJmlData.Caption :=’Jumlah Data : ‘+inttoStr(JmlData)+’ – Tampil halaman ‘+floattostr(edHal.Value)+
37                          ‘ dari total ‘+inttostr(TotalHalaman)+’ halaman’;
38
39      STampil := inttostr((ceil(edHal.Value)-1)*PAGEVIEW);
40
41      //telah digantikan dengan modul QueryViewLogSmsOut
42      DM.DoDataGrid(DBConn,’select first ‘+inttostr(PAGEVIEW)+’ SKIP ‘+STampil+
43                           ‘ A.URUT, A.WAKTU_REQUEST, A.HP_TUJUAN, B.CUST_ID, A.ISI_SMS ‘+
44                           ‘ from LOG_SMS_OUT A LEFT JOIN AKUN_CUST B on A.hp_tujuan=B.cust_hp where A.WAKTU_REQUEST between ‘+
45                           sWaktuAwal+’ and ‘+sWaktuAkhir+’ and A.USER_ID=’+
46                           quotedstr(cbMarketing.Items.Names[cbMarketing.ItemIndex])+’ ‘+qryWhere,
47                           sgrdLogSmsOut);
48    end;
Dari  potongan source code di atas, bisa kita simpulkan bahwa yang akan kita pisahkan menjadi
Controller dan Model ada pada source code nomor  24 – 27 dan 42 -  47. Sehingga source code untuk view menjadi seperti berikut:
1     procedure TfrmViewKirimSms.btnTampilkanClick(Sender: TObject);
2     var
3
4       TotalHalaman,
5       jmlData       : integer;
6       sDataset  : IDataset;
7     begin
8       if cbMarketing.ItemIndex=-1 then begin
9         MessageDlg(‘Isikan User ID dulu ..!’,mtWarning,[mbOK],0);
10        Exit;
11      end;
12
13
14      DoCountLogSmsOut(cbMarketing.Items.Names[cbMarketing.ItemIndex], edCustID1.Text,
15                          dtTanggal1.DateTime, dtTanggal2.DateTime, jmlData);
16
17      TotalHalaman := Ceil(JmlData/PAGEVIEW);
18      lbJmlData.Caption :=’Jumlah Data : ‘+inttoStr(JmlData)+’ – Tampil halaman ‘+floattostr(edHal.Value)+
19                          ‘ dari total ‘+inttostr(TotalHalaman)+’ halaman’;
20
21
22
23      DoViewLogSmsOut(cbMarketing.Items.Names[cbMarketing.ItemIndex], edCustID1.Text,
24            dtTanggal1.DateTime, dtTanggal2.DateTime,PAGEVIEW,(ceil(edHal.Value)), sDataset);
25
26      DM.DoDataGrid(sDataset,sgrdLogSmsOut);
27
28    end;
Procedure dengan awalan Do adalah controller. Pada contoh di atas, source code DoViewLogSmsOut adalah sebagai berikut:
1     procedure DoViewLogSmsOut(UserId, CustID: string; FromWhen, ToWhen: TDateTime;
2         NumDataPerPage, PageIndex: Integer; var Dataset: IDataset);
3     begin
4
5       Dataset:= QueryViewLogSmsOut(UserId,CustID,FromWhen,ToWhen,
6         NumDataPerPage,(PageIndex-1) * NumDataPerPage );
7
8     end;
Procedure dengan awalan Query adalah Model. Source Code untuk Model  QueryViewLogSmsOut adalah sebagai berikut:
1     function QueryViewLogSmsOut(UserId, CustID: string; FromWhen, ToWhen: TDateTime;
2         NumRecs, AfterRecIdx: Integer): IDataset;
3
4     var
5       sPeriod1, sPeriod2: string;
6     begin
7
8       sPeriod1:= QuotedStr(FormatDateTime(‘yyyy-mm-dd hh:nn:ss’, FromWhen));
9       sPeriod2:= QuotedStr(FormatDateTime(‘yyyy-mm-dd hh:nn:ss’, ToWhen));
10      LastExecuteQuery:=
11          ‘SELECT FIRST ‘+IntToStr(NumRecs)+’ SKIP ‘+ IntToStr( AfterRecIdx) +
12          ‘ A.URUT, A.WAKTU_REQUEST, A.HP_TUJUAN, B.CUST_ID, A.ISI_SMS ‘+
13          ‘ from LOG_SMS_OUT A LEFT JOIN AKUN_CUST B on A.hp_tujuan=B.cust_hp ‘ +
14          ‘ where A.WAKTU_REQUEST between ‘+
15          sPeriod1+’ and ‘+sPeriod2+’ and A.USER_ID=’+ QuotedStr(UserId);
16      if CustID<>” then
17        LastExecuteQuery:= LastExecuteQuery + ‘ and B.CUST_ID=’+quotedstr(CustID);
18      Result:= DBConn.NewDataset(LastExecuteQuery,True);
19    end;
Sumber :

Monday, 28 October 2013

Best and Free Delphi 7 Component


Download
XStringGrid.rar
6 minutes ago · Latest version by Fajar Priyadi

Sunday, 27 October 2013

Delphi for Android (alias Delphi XE5 alias RAD Studio XE5) telah muncul


Berikut adalah fitur-fitur baru yang ada di DelphiXE5 :

  • the REST client library, a new cross-platform framework for easy access of REST-based web services
  • REST debugger
  • the full integration of FireDAC
  • IDE support for MacinCloud
  • Extendible IDE mobile design devices
  • the awesome IDE Insight functionality (Ctrl+. or F6) is no longer a modal dialog but is now a search box
  • style support for the freshly released iOS 7
  • swipe to delete feature on mobile platforms
  • TListView search filtering support
  • the removal of the long defunct WebSnap and InternetExpress (with the suggestion to use IntraWeb and WebBroker instead for similar functionality)



The full Delphi target platform sekarang menjangkau:
  • 32-bit Windows
  • 64-bit Windows
  • 32-bit OS X
  • iOS Simulator (Intel)
  • iOS (ARM)
  • Android (ARM)

Mempunyai lumayan banyak compiler:

  • dcc32 – Embarcadero Delphi for Win32 compiler version 26.0 – your regular Win32 Delphi, the latest version updated over many versions since Delphi 2
  • dcc64 – Embarcadero Delphi for Win64 compiler version 26.0 – the 64-bit Windows targeting compiler
  • dccosx – Embarcadero Delphi for Mac OS X compiler version 26.0 – the Delphi compiler that generates 32-bit OS X apps
  • dccios32 – Embarcadero Delphi Next Generation for iPhone Simulator compiler version 26.0 – the NextGen Delphi compiler that builds Intel executables that run in the iOS simulator
  • dcciosarm - Embarcadero Delphi Next Generation for iPhone compiler version 26.0 – the NextGen Delphi compiler that builds ARM executables that run on iOS devices
  • dccaarm – Embarcadero Delphi for Android compiler version 26.0 – the NextGen Delphi compiler that builds ARM executables that run on Android emulators and devices


Persyaratan Android


Karena compiler Delphi menghasilkan instruksi mesin asli, output-nya adalah prosesor khusus. Dengan kata lain itu tidak menargetkan Dalvik Virtual Machine, di mana aplikasi Android biasa berada, yang pada dasarnya Java p-kode yang dieksekusi oleh varian dari Java VM. Sebaliknya menghasilkan kode mesin mentah, karena semua gelombang saat Delphi compiler lakukan (yang lama pergi Delphi untuk. NET adalah pengecualian untuk aturan umum). Jadi karena itu compiler menyusun instruksi mesin asli dukungan Android Delphi memiliki persyaratan sebagai berikut:


  • there must be a GPU
  • the CPU must be ARMv7 with NEON instruction support
  • the OS on the target device must be one of:
    • GingerBread: Android 2.3.3+ (MR1 or later), which is API level 10
    • Ice Cream Sandwich: Android 4.0.3+ (MR1 or later), which is API level 15
    • Jelly Bean: Android 4.1+ (release, MR1, MR2 or later), which are API levels 16, 17 and 18
  • you can run the app on an Android emulator if:
    • the emulator is set to use the host GPU
    • the emulator is running Ice Cream Sandwich (MR1 or later) or Jelly Bean (release or later)
    • the emulator is not running in a Virtual Machine

How do you find out if your device is supported? Well, the OS version you can find out in the Settings. The path and menu items may vary but goes roughly like this: Settings, About phone (or tablet), Software information, Android version.
To check the CPU details you’ll need to run one of the tools from the Android SDK against your connected device. Delphi installs the Android SDK and NDK if you don’t tell it you have it pre-installed. The Android SDK gets installed into a directory something like: C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk. In the platform-tools subdirectory from there is the Android Debug Bridge, adb.exe.
To run a command against your device it needs to be connected, typically by USB. This requires you to install an appropriate USB driver for your device as the ones located by Windows typically don’t do the job. Refer to the helpful The Delphi Geek blog post on the matter, XE5 and USB Drivers, for more information and links to drivers for the more common Android phone manufacturers.
When your phone is connected you’ll need to launch a command prompt and run an adbcommand. This may be easiest if you change directory to the platform-tools subdirectory (or Shift+right-click on the platform-tools folder in Windows Explorer and choose Open command window here). Firstly run the command:
adb devices
just to prove that your device can be seen by the Android tool chain. Assuming it can, run:
adb -d shell cat /proc/cpuinfo
This will show you CPU information something like this:
Processor       : ARMv7 Processor rev 0 (v7l)
processor       : 0
BogoMIPS        : 13.52

processor       : 1
BogoMIPS        : 13.52

processor       : 2
BogoMIPS        : 13.52

processor       : 3
BogoMIPS        : 13.52

Features        : swp half thumb fastmult vfp edsp thumbee neonvfpv3 tls vfpv4
CPU implementer : 0x51
CPU architecture: 7
CPU variant     : 0x1
CPU part        : 0x06f
CPU revision    : 0

Hardware        : UNKNOWN
Revision        : 0003
Serial          : 0000000000000000
Check the Processor line to ensure you are running ARMv7. In the Features line check that neon is included in the CPU feature list

DOWNLOAD DELPHIXE5 UPDATE1

DOWNLOAD OTHER DELPHI

Friday, 25 October 2013

Merubah warna editor Delphi Lazarus dan Smart mobile studio


DITE yang disingkat juga sebagai Delphi IDE Tema Editor adalah tool yang dapat merubah warna editor untuk Delphi (RAD Studio), Lazarus IDE atau Smart Mobile Studio IDE.

DITE supports Delphi 5, 6, 7, 2005, BDS/Turbo 2006 and RAD Studio 2007, 2009, 2010, XE, XE2, XE3, XE4, XE5 , Lazarus v1.0.1.3 and Smart Mobile Studio IDE v1.1.2.17

Untuk mendownload silahkan Installer of the Delphi IDE Theme Editor

Klik untuk memperbesar

Klik untuk memperbesar

Klik untuk memperbesar

Klik untuk memperbesar

Klik untuk memperbesar



Thursday, 17 October 2013

Iklan Terjangkau di ITSTIMETOSHARE.BLOGSPOT.COM

Update Traffic
1 Hari pageview mencapai 500
dan benar2 berasal dari Google Searchengine



beriklan di itstimetoshares.blogspot.com
Trafic pengunjung yang lumayan banyak

Kebanyakan pengunjung mencari keyword tentang tekhnologi dan pemrograman

Support banyak webbrowser 

Tempat2 space iklan






Space No.1 Rp.30.000,-/Bulan
Space No.2 Rp.30.000,-/Bulan
Space No.3 Rp.20.000,-/Bulan
Space No.4 Rp.15.000,-/Bulan

Jika mau langsung pasang iklan di space no 1 dan 2 langsung hanya Rp. 50.000/Bulan

Contact saya langsung ./Fajar Priyadi - 0857-876-77544

Thursday, 3 October 2013

Install Raudus 0.9.6 on Lazarus IDE v.1.0.10

 ini adalah tutorial menginstal Raudus 0.9.6 di Lazarus IDE v.1.0.10

download raudus terlebih dahulu disini

http://www.raudus.com/cu-install/raudus-0.9.6-windows.exe

temen saya mendapati ada error saat proses penginstalan yaitu

(1,1) Fatal: Can not find RaudusFPC used by Lazarus, ppu=C:\Users\robby\Documents\Raudus\bin\fpc262\i386-win32\RaudusFPC.ppu, package RaudusFPC

cara mensolvednya ... arahkan ke path instalasi raudus ..... karena lazarus saya Lazarus IDE v.1.0.10 dan fpcnya 262 (cara mengetahui fpc ke bagian about lazarus) saya masuk ke path seperti di gambar dibawah ini :


jika sudah cari welding.exe ,,,
lalu jalankan welding.exe ... tunggu sampai selesai


kemudian klik RaudusFPC ... nanti muncul window instalasi ,, klik COMPILE lalu Use>Install


kemudian kita akan menginsal raudusnya ... lihat path di bawah ini klik raudusX lazarus package

akan muncul window instalasi , kemudan klik COMPILE kemudian jika sudah klik USE > INSTALL


selesai ...
Semoga berguna

Thursday, 26 September 2013

Memperbaiki Delphi 7 WinHelp


Fix Delphi 7 WinHelp


When you are installing Delphi 7 on Windows 7, the Help system inside Delphi 7 is not working. And this is the solution to fix it.

itulah englishnya, kalo indonesianya

Jika kamu menginstal Delphi 7 di Windows 7, sistem Help untuk Delphi 7 tidak berfungsi. Dan ini cara pemecahan masalahnya.




1. Go to Microsoft website to get the MS Update Fix.
here is the MS Update Fix for Winhelp

2. Download the update, and run it, start Delphi 7, and voila the Delphi 7 Help system is working now...



=============================

jika ada error dalam proses penginstalan silahkan ikuti proses inihttp://www.youtube.com/watch?v=YPAwpAXXKw8

Best Post This Year

Install Fortesreport community Delphi 7 dan RX Berlin

Download  Pertama2 kita harus punya file installernya terlebih dahulu, download  https://github.com/fortesinformatica/fortesrepo...

Total Pageviews

© 2014 Fajar Priyadi. WP themonic converted by Bloggertheme9. Published By Gooyaabi Templates | Powered By Blogger
TOP