22 June 2010

Baracuda - Learn Dynamic Programming Part I

Assalamulaikum wbt..

Post kali nie dedicated utk application y aku tgah wat skg nie y aku namekan Baracuda..Apps nie lanjutan daripada MediaTomyam y aku buat b4 aku blik hari tue..Ade 2 sbb knape aku wat apps nie..1st, utk isi ms lapang dikala aku boring2 xtaw nk wt mende..2nd, utk praktis programming skills utk elakkan aku tlupa n explore teknik2 baru..Kdg2 idea tue bile2 bleh dtg, time tgh mandi la, time tgah men fifa la, time ngah bwak moto..tetiba t'fikir nk wat itu la, ini la..so, stp kli idea2 canggih cmtu dtg, aku bkak lptop n write code..Baracuda nie sbenanye aku develop as a "Housing" utk sume apps2 y aku t'fikir nk wat..yela..xkan stiap kali nk wat bnde bru je kene create projek baru kat compiler ye x..


"CURRENT STATE"

Currently, module media player dh siap dh..Amik dri projek MediaTomyam y lepas, design n write code balik utk dynamic programming..Da beberapa bnde y aku nk share sal bnde nie especially cmana Microsoft wat media player die..First, nie screenshot whole module media player dlm Baracuda:


"DYNAMIC PROGRAMMING"

Ape y aku mksudkn ngn dynamic programming principle nie ialah every possible class regardless UIElement, object class, helper class or interface class have to be dynamic and flexible..Kenapa? Aku bg 1 situation..Cube tgk Microsoft Word..bleh maximize and minimize kn..kn..kn..bleh resize lagi tue..kalu korang prasan, bile resize window, sume element dlm die akn reseize and self-arranged automatically based on size window tue..same gak mcm user A da screen 20 inci, tp user B ade screen 14 inci je, tp bile bkak Microsoft Word, sume nmpak sama..Reason die adalah adanya dynamic programming..

Bnde nie kne wat dri awal software development, utk mksure apps kite highly adaptable regardless user computer's condition..Knapa dri awal kne wat? Sbb utk bg apps kte fully dynamic, kte kne identify every part dlm apps based on OO principle..nie depends on programmer..Pd aku, aku lg suke create class based on functionality and task..contohnye ade kat bwah nie:


Each part adalah 1 user control, which means sumer class asing2..pd y xtaw pe dia user control, bleh refer kat post y lama2..1st, aku ade main layout (green border) dgn static width and height. Then dlm die ade beberape different user control len (red border)..Kegunaan frame layout ni adalah utk initialize actual height and actual width apps nih (actual width n width berbeza property k)..Once user resize window, Frame layout akn raise event Size_Changed and set new size kat layout helper class, then every user control len y kt dlm die akn automatically follow, re-arrange mane2 y ptut.

Most C# newbies cm aku dulu2 tend utk ltak object siap2 dlm Expresion Blend..Slah tue sbenanyer..Itu akn mmbuatkn apps kite less dynamic since every UIElement akn jd static. Cara sebetulnye adalah cam kat bwah nie:

bdrMain.Child = (helper.ContentMover = new ContentMover(helper.PagePlaylist = new PagePlaylist(this)));

Let say la aku klik page Playlist, then class PagePlaylist akn di initialize "just-in-time" utk fill in dlm frame layout..Ape mksud this? Nie ialah current class iaitu class FrameLayout, n aku pass kn skali as a parameter (override default initialization finction)..Then code dlm PagePlaylist adalah sperti di bwah:

public PagePlaylist(UIElement Element)
{
this.InitializeComponent();
Layout = Element as FrameLayout;
FindPlayList();
}

FrameLayout y aku pass td akn di receive as a UIElement dlm class PagePlaylist, then casting blik..Then set size page playlist tue ikut size frame layout td..Haa nmpak x skag?? Tue la y aku ckpkn td, initialize user control based on parent/main user control nyer size..so, xperlu la nk rsau user nyer screen size, window resize or wht so ever..

"CONCLUSION"

In term of dynamic programming, byk lagi sbenanye..Post kali nie baru discuss sal dynamic dri segi windows size je..Ade byk lagi, database connection, static class, helper class, inter-process communication, multithreading..syok2..InsyaAllah kalu xder aral melintang, akan ade lagi Dynamic Programming Part II n new progress on Baracuda..ekekeke..










.

3 comments:

terima kasih.