Tuesday, February 13, 2018

Good Developer Series - #1

Hey Developer. Can you deliver this new feature as soon as possible? This is urgent, the client needs it for a release next week. Can we estimate the time needed to implement it? Well, 10 days is so much time to deliver this, we need it before next week, let's make them 2 days and deliver, then we fix any issues that would appear. This is the fourth day and you didn't deliver the feature yet, this's unacceptable! if you have any blockers tell me to coordinate. So, your code is not working, we can't deliver the client this piece of (code), please fix these high defects before delivering.
So, this short story isn't sounding strange for most of us. It's the movie that we watch daily day and night with some extra scenes that we didn't mention here like 'Did you finish anything? Any progress? Can you manage to fix these chunk of 50 defects since the last sprint in parallel while delivering the feature? Did you finish, ha? ha? ha? ha.......'
So, the client is pushing, the manager then pushes, then PM pushes, TL pushes, and you -the developer-, the weakest part of the chain that is trying to find someone below him to push anything but cannot find. You only have the right to push your code to the repo, and nothing else.
Actually, if we think wisely in the return of all of this, we will find a feature that is delivered by the end. This's awesome by sure, but the beast actually is waiting for you by the end of the tunnel to attack and kill, believe me, I've seen him multiple times before.
While a feature is really implemented, an exhausted developer is there that his next jobs will be delivered slower or He will be divorced because of destroying his work-life balance.
It's not only about the developer life that we don't care about it, if He committed suicide we'll bring another one, but also about the product that has been delivered. Good developer, when writing the code, He writes it not only for the client but also for the developer that will come after him to complete the journey to enhance a feature, fix defects, or even implementing new features. All of these needs a readable, organized and good code to be achieved. You don't put in your mind the time will be wasted for the next developer to read these scattered pieces of code to just fix a small defect that blocks the whole application.
"Good Developer" is not about the developer only, it's about the whole process, environment, and people around him. Don't think about the short term of "Delivering a Feature", but think in a strategy that will keep your developer working good while your code looking code, so that, in anytime the developer disappeared, another one can complete the race, or you will lose it.
The beast is out there, at the end of the tunnel. Avoid it.

Read This Article on LinkedIn:
https://www.linkedin.com/pulse/good-developer-series-1-mohammed-elnekhaly/

Thursday, May 5, 2016

AngularJS - numfmt Solution

Now.. Your JSON array returns your "number" values as "string" values. For example, instead of returning you 50, it returns you "5".
While using ng-model inside a text box of type "number", you'll receive a something called "numfmt" error. You can check it here on Angular JS documentation.
The idea is that, AngularJS doesn't provide you a direct solution for it, and asks you as a developer to provide your own "directive" to resolve this issue.
So, what to do.
Easily, use angular.forEach method to parse all the "string" values you're receiving and then convert their type into "number" using Number method.

It should be something like that, assuming you JSON is "result" and your number (string) value is "numStr"



angular.forEach(result, function(value, key) {
    value.numStr = Number(value.numStr);
});


On your view, use ng-init to initialize your model with the "number" typed value resulted from this process. Please do before your <input>, It's better to do.

Cheers

Thursday, April 28, 2016

AngularJS - $compile

Have you ever was obliged to push HTML code from controller with ng-directives, and you were asking yourself why in god it doesn't work.

For example, you've used Bootstrap popover and you need to attach ng-click to a popover item. You did, but it didn't work.

Easily, your HTML needed to be recompiled again to be executable by Angular, and here's why you should $compile to do that.

Simple Example:


$("#MyPopoverDiv").popover({ 
  html: 'true', 
  title: "", 
  content: function() { 
    return $compile("<ul>
      <li id='MyProfile'>
       <span class='glyphicon glyphicon-user'></span>
       Option 1
      </li>
      <li id='Preferences'>
       <span class='glyphicon glyphicon-cog'></span>
       Option 2
      </li>
      <li id='LogOut' ng-click='logout()'>
       <span class='glyphicon glyphicon-log-out'></span>
       Sign out
      </li>
    </ul>")($scope); 
  }, 
  placement:"bottom", 
  trigger:"focus click", 
  template:"" 
}); 

So, instead of just putting your popover content into "content" attribute. You need to use $compile first to make it ready to use ng-directives

content: function(){ 
return $compile(*Your HTML content*)($scope);
}
Don't forget to pass $compile as a dependency on controller initialization.

Cheers



Monday, February 4, 2013

My Intro to technical blogging

After more than 10 years of technical experience in Software and Web Programming, strong feels appears with the need to share what you know with others, and finally, here's my technical blog for what I know about programming, media, project management, and any other emerged abilities.