Houssain Benzourry

~codes + kwave + jpop + foods = life~

Things I wish I knew before starting an Angular project — June 1, 2015

Things I wish I knew before starting an Angular project

Well, aku ni xla master sgt pasal Angular(just self-taught). Tp since the first time using Angular, aku dh rasa xboleh klu xpakai. Especially bila develop RESTful application. Til the moment, aku dh develop 4 project menggunakan Angular ni. Syiokkk oo… But then, ada beberapa perkara yang aku harap aku tau lebih awal before start pakai Angular.

1) John Papa’s style-guide

Sesiapa yg develop pakai Angular konfem kenal ngan mamat John Papa ni. Recently, dia nyer style-guide has been endorsed by the core team dlm ng-conf. Mamat ni gak dh publish dia nyer style-guide (in collaboration with the core team) kt github:

https://github.com/johnpapa/angular-styleguide

Klu untuk personal project maybe xpenting sgt nk pakai style-guide ni. Tp kalau develop in team, this is a must follow guide utk memudahkan development. Trust me. His style-guide has been adopted by majority and that will ensure easier reference in the future. And so, banyak point dlm post aku lepas ni actually berkisar dari style-guide beliau. Untuk itu, aku belanje video mamat ni kt recent ng-conf.

2) Controller As vs $scope

Okay, this is quite debatable, tp the team encourage the use of controller-as syntax for a reason. Personally, aku lebih suka dgn syntax controller-as ni sebab lagi senang nk baca, lagi nampak macam javascript, n aku dpt buang dependency dengan $scope.

Dulu, maybe aku buat macam ni:

function UserController($http, $scope){
$scope.bindedVar = "yooo";
}

Skarang aku lagi confortable buat ni

function UserController($http){
this.bindedVar = "yooo";
}

…dan dlm template…
<div ng-controller="UserController as vm">
{{vm.bindedVar}}
</div>

There’s few reason why it’s good.

  • Controller lagi senang nk baca
  • Xde dependency dgn $scope, n because of that, kurang temptation utk abuse $scope
  • Force dotted binding dlm template (there’s horror story pasal variable yg xde dotted ni, because of prototyping nature of javascript)

3) Relaxed a bit on the Angular concept

Dulu masa mula2 kenal dengan declarative nature of Angular, n dh pandai buat directive, habis suma benda aku nk buat directive. Benda yang actually simple dlm javascript aku complicate dengan gobs of directive declaration. Oh gosh… dan bila masa nk debug, DAMNN, that was a nightmare. Kalau bende tu lagi senang nk buat dalam javascript biasa, buat pakai javascript biasa. Kalau bende tu involved closely with DOM operation n highly reusable, then opt for the-angular-way. Untuk itu, let me share a great video here.

4) DON’T $http’ing in the controller

Ini mistake aku yg paling besar n nmpaknya aku kene hidup dgn masalah ni. Sekarang controller yg aku buat mostly fat n bulky. Once dh pakai $http dlm controller, you are tempted to perform the logic on the promise block, which is really, really wrong. LEARN about service, TRY code the service & utilize the service. I know that it is a much troublesome things to learn just to code, but it will definitely help you to write a better, testable codes. With $http in the controller, it’s a bizarre experience once your application getting bigger and larger. A nightmare.

5) Dont mix AngularJS dengan jQuery

I know that there’s a few plugin that you love. And the plugin dependent on jQuery. In fact, beribu2 plugin utk web pakai jQuery. But once you dh pakai Angular, try to look for Angular alternative. Kalau xjumpa, rethink balik, is the feature really needed?

I know that actually if done right, Angular can play nicely with jQuery. In fact, Angular ada include jqLite (simplified version of jQuery).

But here’s the story anyway. Previously, aku ada pakai date-picker jQuery. I’ve been using it for multiple project previously without any issue. The comes Angular. The date-picker was initialized with jQuery dan input yg aku bind dengan ng-model wasn’t returning any value because the changes wasn’t picked up by angular. Naively, aku declare watcher utk dptkan value tu until I’ve realized that I have an alternative in Angular.

That’s all aku rasa nk cakap time ni. Happy coding wooo.

Persepsi SALAH berkenaan Spring Development — May 31, 2015

Persepsi SALAH berkenaan Spring Development

Well, for a strater maybe aku boleh rant dulu. Sekarang most project aku develop dengan Spring Boot, klau **server mengizinkan** (last freelance invite however suggest on php framework, Laravel to be specific). Jangan takut dengan statement **server mengizinkan** tu. Sebab requirement server tu actually just asalkan ada Java (in which most server at least ada run JRE).

Aku asyik mention Spring & Spring Boot, tp maybe ada yg maseh kurang familiar apa kejadah bende tu.

The Spring Framework is an application framework and inversion of controlcontainer for the Java platform. The framework’s core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Although the framework does not impose any specific programming model, it has become popular in the Java community as an alternative to, replacement for, or even addition to the Enterprise JavaBeans (EJB) model. -Wikipedia http://en.wikipedia.org/wiki/Spring_Framework

Dan Spring Boot pulak:

Spring Boot is Spring’s convention-over-configuration solution for creating stand-alone, production-grade Spring based Applications that you can “just run”.[14] It takes an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration. – Wikipedia

So, senang cakap, Spring ni framework utk buat Java webapp, while Spring Boot ni versi simplified, convention-over-configuration utk Spring.

Before aku teruskan dengan puji-pujian terhadap Spring Boot ni, aku rasa ramai maseh menyimpan prejudis berkenaan Java webapp dan aku akan try debunk each yg aku rasa kurang tepat. Antara prejudis populer tu, meh aku listkan.

  1. Spring deployment is expensive and difficult
  2. Spring is slow (being heavyweight)
  3. Java/Spring susah nk blaja
  4. Java is old

Spring deployment is expensive and difficult

Previously, yes. Terdapat bermacam2 configuration yg nak kene buat. Ramai jugak yg confuse java webapp ni dengan Java Enterprise nyer application. Actually, dengan most application container sekarang, proses utk setup server java dan deploy application is actually straight-forward. With tomcat, anda cuma perlu extract the package n run catalina script. Then anda boleh masukkan WAR file dalam folder webapps. That’s all we need. Dengan Spring Boot lagi simple. By default, Spring Boot package it’s application with embedded tomcat. As long server anda ada Java(JRE), anda boleh simply java -jar path/to/app.jar anda untuk deploy. No tomcat, or application container needed. Trust me, it’s far more eaasier than php to deploy enterprise-grade application in java.

Spring is slow (being heavyweight)

To some extent, this is quite true with those bulky JEE. However, bg yang dh start develop dengan Spring, things is quite fast actually. Most application develop with java is being a big, large enterprise application. Of course it will be a bit bulky klu nk compare dengan average php application. I’ve done both and I can tell u how well is the performance of java web application. + JVM performance has drastically improved over the years.

Now, enter the world of micro-framework, Spring Boot. Sebab most configuration has been auto-configured utk anda, peluang utk misconfigured the framework dan menyebabkan performance issue adalah begitu kecil. Why dont u try it first?

Java/Spring susah nk blaja

Syntax java is actually quite similar with php. But instead of loose typing, Java language is using the strict data-type. So, for most part bila nk compare, assign variable, instantiate class (might be something new utk php, though it’s actually there in php) maybe some adjustment is needed. I believe the most difficult part with java is to grasp the object-oriented nature of Java. It’s more of the conceptual side when learning Java. But if you are able to adapt with OO mentality, you are good to go.

In case of Spring framework, there’s a few concept that you have to learn such as Inversion of Control, Dependency Injection. You can learn it over time. With Spring Boot, you can start by fiddling with the guide project from http://spring.io/guides. The tutorial was designed to be done in 15-20 minutes.

Java is old

Yes, it’s true. Bila buat Java, mau tak mau, anda perlu adopt OO principle behind it. And bila dh buat pkai OO, there’s load of benefit comes after. Walaupn Java ni kdengaran agak lama, tapi spec Java sentiasa dikemaskini dan diimprove oleh komuniti yang disar disebalik Java. Even more, banyak language baru improving and retrospect to the Java’s language properties. Things such as strict data-type, multithreading, object-oriented features, hampir semua tambahbaik menjurus kepada design-apect yang sediaada pada Java. HHVM/PHP7, ES6 to name a few. Bezanya, feature tersebut sudah lama dlm Java and improved over-time. There’s also new features dr language lain yang diserapkan dalam Java(ie. lambda expression) and we know it’s always improving.

And so, I will start writing on how to start with Spring Boot easily and building your first Hello Word application.

Spring

Akan menjadi blog berkaitan programming 98% —

Akan menjadi blog berkaitan programming 98%

Sudah lama x check blog. Been couple of years, probably. Ok, so now I’ve decided utk tuka blog ni jadi blog utk saya share berkenaan programming dan development, mostly. Bahasa pn boleh relax skit dh.. Hehe..

Pasal KPOP? Mehhh, dh x minat sgt. Maybe dh matured skit kut.

Anyway, I’m looking for a new topic on programming. Maybe saya akan bermula dengan Spring-Boot. My passion at the moment. Dan akan masuk skali pasal Spring in general, Java development, PHP, front-end development (Angular), Android development dan macam2 lagi.

Harap boleh membantu geng utk lebih mendalami subjek ni dengan penggunaan bahasa yg lebih santai.

Kalau ada apa2 topik yg anda berminat nak saya share, silalah komen utk request (saja nk mintak org komen).

PHP projects sourcecode giveaway (NetFolder, ARMS) — March 24, 2012

PHP projects sourcecode giveaway (NetFolder, ARMS)

I’ll be giving out sourcecode of my PHP projects for free with hope that I will gain some input from you all.

There are around 10 php projects which will be shared. Okay, the first project will be NetFolder, which is an online efiling system.

NetFolder (online f-filing)
Demo : http://efiling.reeq.my
Username : testing
Password : testing23

I have made two customized version based on this project which is currently being used by my customers.

If you are interested with the project, inform me and I’ll give you the latest updated source code, because I might update the code now and then.

The coding is fairly simple, if you ever read on my previous post regarding oneFace.🙂 The database itself is only consist of 31 tables. The brand “NetFolder” is reserved, thus you are encouraged to put your own branding if you plan to derive another fork of it.

*Update as of 25th March 2012

Download link :  http://goo.gl/JWcID
Database : /efilingv4/efiling.sql

*Update as of 27th March 2012

ARMS (fixed asset record management system)
Demo : http://reeq.my/arms/
Username : testing
Password : <no password>

There is also customized version of the system which concentrate more on the asset movement and telecommunication equipment record.

If you are interested with the project, inform me and I’ll give you the latest updated source code, because I might update the code now and then.

Download link :  http://goo.gl/AENE8
Database : /arms/arms.sql

This morning, I’ve learned about myself — September 20, 2011

This morning, I’ve learned about myself

Mimi
Mimi

I was late for my work today. Just… because..

On my way to my workplace this morning, I came across a dead kitten at Jalan Baru. It’s sad, and since it’s soo sad, I can’t move further. The sadness made me return to the place where the dead kitten is.

It’s soo sad, yes, true. The kitten was dead. His small, frail body was probably hit by a car (or motorcycle) and lying there, motionless. He looks like he’s deep asleep, except that he’s badly injured and all his organ was messed up.

It’s soo sad. Many things come across through my mind at the time. His fur color is similar with my kitty, mimi.

Is it my kitty’s sibling? If sooo, then he’s dead without having to spend time with his sister(which is my kitty). My kitty was originally a stray kitten, when I pick her up, afraid that she might be hit by a passing vehicle. Then I’m at fault cause I took his sister and left him behind, wandering, then dead hit by a car.

Then sorry mimi(my kitty), for split you with your brother and left him dead hit by a car. I’m humbly apologize, on behalf of my guilt-self and manbeing.

The dead kitten was probably few months years-old. Just when he is able to see the world, experience living, proud and greed human taken his life for good.

Jalan Baru
Jalan Baru

Something crossed my mind.
Few month ago, they were born together. Then a proud and greed man took one of them, showing off of his kindness, without thinking of the consequences. Just to re-assure his reputation as ‘kind human’, he messed up everything. And just because of that, they were split apart from each other. Can’t bear the sadness, the other kitten walk his disappointment on his lonely path. Living for other months thinking of his sister, until one day while crossing the road in search for foods, he was hit by a car and left dead on the road with nothing left in the world for him. Not even a memory of him in others mind. And yes, that useless and greed man was me. I’m that man that think highly of himself, thought that I’m kind enough, but in the end I’m just nothing… if he’s really my kitty’s sibling.

It is sooooo sad, that his life not even acknowledged by other living things.

Made me think of my other kitten which has lost for about 4 days now. How’s he doing? Is it fine for him, or is he already dead? In the same fate as this one?

Dear God the Maker, it’s me, humbly as Your servant, I’m just a humble creature. Thinking of my superiority to other creature that You’ve made is totally ridiculous, now that You’ve shown me how small and fragile the life that You have given us. We are nothingness, in front of You.

My Shot — September 7, 2011
Selamat hari raya aidilfitri — August 28, 2011