My approach to leadership even when you’re not The Team Lead, Or how to minimize resistance to change in your company

Recently I have been asked a few times about how to become recognized as a leader when you are not officially appointed a Team Lead title, or even worse, when the particular team you are working on is too small, or you are even working solo on an independent piece.

Another common question I see people around me ask is: how to introduce new practises to a team that still doesn’t recognize what’s holding them back or what they are missing out on, without having too much resistance, especially from senior people. It’s interesting to note that this question is often asked out of a specific struggle, and that leadership is not usually mentioned when the question is framed.

But “how to lead” and “how to drive change” are very related

This blog post was motivated by a question I answered recently on Quora, and another one I answered in a tech group on facebook.

The Quora question is just an example of how this works, so do not mind the specifics.

How can I ask a senior developer to learn Git properly as he always commit code directly on the master branch?

The other question is what I’m sharing with you here. Let’s look at what it says:

What are your tips for developing company performance in Agile, clean code, unit testing, good software design, etc.?
Habits are usually a problem, and there’s difficulty of persuasion

Below I answer the question from my observations working as a consultant for 7+ years, and as a software developer for over 12 years.

The Answer

It depends on your role, your power, how much buy in you got from leadership, etc.
But…

This is the general framework I apply as a consultant whenever I go to a new place (usually every 4 – 14 months):

I keep my ears open all the time, looking for opportunities to help people technically etc.

I like to help, but it’s also good to have people recognize you as someone who helps and come to you directly for help after that. When they come to you for help, they develop habit of listening to what you say, and accepting it.

I ask tough questions from day 1, although only when a relevant topic comes

Questions have always been key to how I function. Asking the right question gets you a very good idea on where the team / company stand relative to what you are asking, and much more.

It tells you whether they already do things better than you thought, or otherwise, how close they are, and whether they acknowledge that they are missing something.

The question also communicates to the team what to expect you to push, what you stand behind. If you ask the question in a neutral tone, and only focus on understanding their position (via few follow up questions as time and situation permit) instead of enforcing a suggestion solution at the time, it also signals to them that you are not a perfectionist who wants to move everything upside down in their comfort zone.

Small talk, coffees, etc.

I have room for improvement here, but small talk, chatting to people about their lives, their kids, their favourite sport / movie, without being judgemental of course, really helps make you a friend.

If your time permits, join in the coffee trips and sit with them for lunch if applicable. This one is optional, but it helps deepen the “one team” feeling.

I embrace coming as honest / vulnerable, do not act like “I know it all”

Stating the obvious, but, I do make mistakes, and that’s OK. When you push for change, even by just asking innocent questions, people hold you to a higher standard, and that’s also OK. Actually it’s a good thing.

When you create a Pull Request, and other people point at a mistake you did, and you smile and fix it. What happened in here? Two things: They put on their “What’s the right thing to do” hat, and you put on the “I hold myself to the same values I ask you to stand for” hat.

This really helps in getting people to have a development mentality, and also helps them own the improvements. It’s not about you anymore, we are all peers, and we all hold each other to what we agree is correct.

It also works in non tech areas, like applying a process etc. When you make the rule become how they judge you, they stand more for it.

I look for opportunities for small wins.

A small Agile or tech practice that people can apply without much effort and can appreciate the results. There is always one if you keep your ears and eyes open, and ask the right questions. The whole point here it to get them to appreciate that change (a small change in this case, that they don’t feel a strong urge to resist) is actually beneficial, which helps when you start pushing bigger changes.

Now that I built enough credibility, I start making the case for the bigger items

This works because I’m often injected into teams as a developer and a mentor, or leading a smallish team of 3-4 developers. It’s different when I’m expected to be an advisor to the leadership.

I watch what we agree on, to decide whether to keep asking or start making statements

Asking works most of the time, but telling / making firm statements is needed too. When people say they don’t want to do something, quite often they ignore the result of their old approach vs the new approach. Your friend in these objection time is the word “Why?”.

If you keep asking “Why?” and “What will happen if…”, people will stop answering at some point, and you’ll have to “tell” them what you think the answer is, and get them to agree or make their own answer. That’s one kind of telling.

When you reach to a point where the flaw of some approach is stated, then it’s time to put on your firm face and “tell” them that we should avoid this problem using the change you are suggesting (detailing the change not using words like “my change”, you don’t want it to be them vs you), and “tell” them that unless they find a bigger flaw in it, that’s what we should follow

At the end of the day, quite often most decisions are trade-offs. You just need to agree on which trade-off has higher cost.

When you do this, you should also sense the air to see if it’s better to make your statements use a neutral tone, or sound a bit more firm, which still should not mean shouting!

Praise and recognition, lots of it, but keep it genuine

Recognition

I make sure to give people credit for everything good they do, no matter how small. I repeat it in front of more people, and in front of other teams.

Side note: en you do this, you don’t worry about others taking credit for what you did. Because when you keep giving credit to other people around you, external people and management DO see that you are a common factor in these, and while the people you praise get the credit, you too get extra credit!

This plays well with the old leadership playbooks: When talking about good things, name people in every occasion. When talking about bad things, always name facts and avoid naming people, use “we” instead of specific person’s name. If you really have to mention a name, say it neutrally and quickly.

Praise

When someone does something good, whether related to the changes you suggest or not, make sure to praise them, in public, loudly. Praise for small things. And do not make up praise.

I learned an interesting secret: when you look for good things that people do, you always find them. Even people that your might consider a negative net producer will do good things and if you look for them you’ll find them (handling negative net producers is a whole topic on its own).

People love praise. It always strengths your relationship with them. They also feel the urge to do better. It also helps you (me in this case) find positives in the relationship with the team when you are looking for genuine reasons to praise them.

Be warned though: It’s VERY important to keep your praise genome and about good things you found NOT made up. Why? Besides being dishonest, people will see that you are just giving them empty praise. While empty praise still works on others, it reduces your creditability, and it sure still does not work on those who resist change the most (and hence recognize they have the most conflicts with you). It’ll just lead them to disrespect you and fight you harder.

People often recognize me as someone who is approachable and respectful, which I think is mainly due to vulnerability and positivity (which praise is part of), even though I’m also someone cites concerns in the form of questions or statements when required. This leads to them describing me in my LinkedIn profile recommendations as someone who is they enjoy to work, but not afraid to speak up.

The good news is that there’s no secret about it. It’s not too hard to recognize all people for the good work they do when you are actually looking for it.

Finally

When you are already recognized as leader / coach, you don’t have to go through all these steps. You might be better off asking the existing leadership about their priorities and the work conditions, and directly start addressing the low hanging fruit from these.

Do you have any experience / tip you’d like to share on this?

Bring on your own version / perspective

Little Known Angular XSRF Protection Support In Http & HttpClient APIs (v2.0+ vs 4.3+)

This post is about a new feature / code restructure in Angular v4.3+ that is pretty well documented, yet, hardly talked about in posts, and worth drawing special attention to.

The feature we are talking about here is Angular helpers for guarding against XSRF attacks in its old and new HTTP modules.

What Is XSRF? (Cross Site Request Forgery)

XSRF (Also knwon as CSRF) is a form of web security attack that can allow others to impersonate your identify and perform some actions on websites that you are already logged in to. Let’s start with an over simplified version of how the attack and protection work (as I understand them).

XSRF Attack

  • You login to website A and get a session cookie, maybe use it a bit
  • You open website B in a new tab or even the same tab, you are still logged into website A
  • The owner of website B (or someone who hacked it) happens to be a user of website A too, and knows what calls it sends to the server to perform different tasks
  • Website B loads a hidden form with the submit URL going to website A
    . It could be sending an email on your behalf, deleting many important items, whatever that is you can perform in website A
  • Website A takes the request and performs it, because you are still logged in

XSRF Protection

There are many ways to protect against this attack. Mainly you’d use server-generated token stored in somewhere that’s not a cookie.

A classic server side application with a single form each page that submits back to the server can generate a token as a hidden field in the form, and then validate it on submit, and generate a new token for the next page etc. Website B will not have a way to generate a valid token when trying to simulate the server form.

A client side application (SPA) could do the same with headers, sending the token in a header when making any API request (A.K.A AJAX call), and getting the new token in the response of that API / AJAX call.

The initial token may be obtained via a call to a known API, or in a cookie that’s downloaded when the HTML page is loaded. Since the other site can only do only put a form on its own page, it cannot modify headers to inject the token, or call the API directly due to CORS (Cross Original Resource Sharing) policy.

Angular HTTP APIs & XSRF Protection

By default the Angular v2+ Http service (from angular/http HttpModule) had builtin support for the Cookies To Headers XSRF protection technique we just mentioned.
If it detects a cookie with the name XSRF-TOKEN, it adds an HTTP header named X-XSRF-TOKEN with the same value to the next HTTP request you make.

Since the support is so transparent, I have seen developers who did not even realise it’s there. If you are a front end developer who had someone else on the backend implement the server issuing and validation of the tokens, you may not even realise it’s there.

But things changed slightly in Angular v4.3, that you probably need to be aware of.

HttpClient

In Angular v4.3, a new library for creating HTTP (AJAX) requests was added to Angular.

Instead of injecting an Http object from @angular/http as you did since v2.0, you inject an HttpClient from @angular/common/http. The new HttpClient has several new features but most notably:

  • Automatically maps responses to JSON by default (configurable)
  • Added a pipeline for injecting middleware to requests/responses (called interceptors, like those of AngularJS v1.x)
  • Has some really cool testing utilities that are much simpler than the old v2.0 Http module

Whether you like it or not, you’ll probably end up using the new HttpClient in your Angular applications. This is because starting Angular v5.0, the old Http will be deprecated (so it may be removed entirely in v6).

For the record, the relatively quiet introduction of the new module in v4.3 and the deprecation of the old in v5 still makes me feel anxious regardless of how good the new one is. The old one generally just worked, and the way it’s replaced reminds me of the 3 router versions that were written during Angular v2.0 pre-releases.

XSRF Interceptors

Since the new HttpClient came with proper support for request and response interceptors, it made total sense for the XSRF support in it to be implemented as interceptors as wel, not as part of HttpClient itself.

This is all cool and good design, but there is a catch, which although is well documented, it’s not having enough people talking about on Medium and Twitter etc.

The XSRF in HttpClient is an opt-in feature. It’s NOT enabled by default, unlike the Http service. This means that you could easily migrate your code from Http to HttpClient and not realise that your builtin XSRF support has been lost, until you test the application and you start getting 403 Unauthorized errors from your API of course.

Luckily, all you need to do to get the support back is just import another module, like:

// import { HttpModule } from '@angular/http';
import {
  HttpClientModule, HttpClientXsrfModule
} from '@angular/common/http';
// ...

@NgModule({
  declarations: [
    AppComponent,
    // ...
  ],
  imports: [
    // Now this one is gone:
    // HttpModule,

    // New replacement
    HttpClientModule,
    // Restore Xsrf support
    HttpClientXsrfModule,
    // ...
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Gotcha

The old HttpModule supported sending the XSRF-TOKEN header for all HTTP requests. While the new HttpClientXsrfModule made sure it doesn’t send the header for GET or HEAD requests.

GET requests don’t make much sense for XSRF attacks anyway because the attack is about changing data while impersonating you (the attacker cannot get the result anyway because of CORS rules). GET requests by definition should not change data.

However, if your API relies on this, your app might break when you move to HttpClient. In that case you might want to look at this Github issue I created and apply the workaround github.com/angular/angular/issues/19885

More Goodies

The HttpClientXsrfModule also makes it easy to change the cookie & HTTP header keys separately if you require that.

Of course you have to remember that both XSRF protection and JSONP require server support as well from the API server you are calling for them to function.

Finally, the same support is also included as opt-in for JSONP requests as well, by adding HttpClientJsonpModule (also from @angular/common/http) to your imports. This utilizes the power of interceptors that allows them to avoid sending an HTTP request completely and do something completely different instead.

As I said, the usage of HttpClient in general, as well XSRF support (and what is XSRF in general) is well documented by the Angular team.
Check it out at https://angular.io/guide/http.
I still noticed that not enough people are talking about this feature and the actual change, so, hopefully this post can bring some awareness to it.

Angular 4.2, TypeScript 2.4, Amazon AWS, Node / Webpack Updates, & .NET Core Tutorials

Hello,

This is Meligy from GuruStop.NET, and this is a special letter celebrating Angular 4.2… Actually, Angular 4.2.1 already!

Let’s see what good content I have found on the Internet since last letter, that you should find super useful as well. Of course it’s not just going to be about Angular, but also AWS, Node, .NET Core, and more…

Angular Releases

Angular 4.2

As mentioned, Angular 4.2 is here already. In addition to the Changelog which describes what’s new in every new beta/final build, here’s also a good write up on the release highlights.

Reading through the post, I think the most exciting features for me are the new fake async helpers for tests, allowing to test async code while not having to wait for real setTimeout() calls, etc, which helps tests run faster! There’re also enhancements for animations, and more features relying on TypeScript 2.3+ strict features.

ng-sydney

The Angular usergroup I run in Sydney is experimenting with recording sessions simply by using a mobile phone. While there’s a lot of room for improvements, this approach allowed capturing some very good content. Like a session about Angular 4 from an official Angular team member in April, and these sessions from May:

Amazon AWS Getting Started

[Video] Create Your Personal Website with Angular & Deploy to Amazon AWS

If you are like me, you might have heard several people talk about AWS.

Everything is going to the cloud, and Amazon is the biggest player in this field. But how do you get started? What would you build in the first place? Would you use Angular for it? And once it’s ready, how do you get it to the cloud?

Well, that’s exactly what this video talks about!

The speaker’s challenge was quite the opposite. She is fairly comfortable with AWS, and still learning Angular. So, she decided to build herself a new personal website to show her work and more. She used Angular and the Angular CLI, and of course she deployed it to AWS.

In the video, she explains why this is a good idea you should try too, and goes through all the different options that make sense for getting started, with demos covering both Amazon CLI tools and UI console.

She also wrote a very good tutorial on how to do it, with a lot of links to learn about specific topics. Highly recommended.

I’m referring to it myself to learn this stuff.

Angular Modules & Lazy Loading

[Video] Angular Modules, Lazy Loading, & Analysing Your Bundle Content

In this video by Aliaksei Kuncevic, an Angular expert, and a frequent ng-sydney attendee and speaker, we go into the lesser known official Angular guidance around Core Modules, Feature Modules, and structuring your real world Angular projects.

It covers even less known tools that help you analyse the size of the JS files that tools like Webpack etc generate, to see what JS modules take up the most space and make them big. He shows some interesting cases with RxJS, lodash, momentJS, and other libraries.

Aliaksei also made both the talk slides and demo sources available for download.

You might also want to check my earlier very quick blog post on shared modules.

TypeScript Releases

TypeScript 2.4

While still a pre-release version, which you can npm install as typescript@next, TypeScript 2.4 is already some awesome features that I’d love to mention here. Also it doesn’t seem to pose any breaking changes that prevent you from experimenting with it in your Angular 4+ projects (which officially support TypeScript 2.3 already).

The first feature, as explained in wiki, is native support for lazy-loaded imports, which promises to make lazy loading much easier in future applications (although will probably need to wait for tools like Webpack to support fully).

This is going to be a big deal soon I hope, as now people often rely on complex solutions for lazy loading that’s often encapsulated by routing tools (like Angular CLI routing support) because it’s just too much.

There’s also better type inference all over the place. That’s something you can take advantage of today, and it basically means less places where you don’t have to specify the types manually thinking “Grr.. the compiler should’ve known that by itself already”, and still get proper typing support.

If you are not familiar with what’s new in TypeScript 2.3 itself, or other earlier versions, check the same wiki page, What’s new in TypeScript, which explains almost all the TypeScript features as of the versions they were added to the language, and also explain what real world scenario tempted the team to add each feature, and how you case use it for your own uses.

Node & Build Tools

Node 8 & Canary

In case you missed the news, Node 8 is a final release now. This is an important update mainly because it’s an even number release, which in Node ecosystem means after a few more minor versions, it’ll become the next Long Term Support “LTS” release, most suitable for production apps (Node 8.1 is already out!).

It also includes some performance improvements, and new APIs. Although most of the new APIs are low level ones, this means that as native modules etc start relying on them, more and more tools will require moving to Node 8. Luckily, it doesn’t seem to break anything noticeable if you are already using Node 6.

And in other news, there’s also a Node Canary release channel, which uses the most bleeding edge version of Chrome’s V8 engine!

NPM 5

With Node 8, we also get NPM 5. The release seems to be heavily influenced by alternative NPM client, Yarn.

The biggest feature of the release IMO is much faster package installs (comparable to Yarn), Using --save by default (like, err, Yarn), and better npm link workflows for open source developers (not the same as Yarn, but this area is not ideal with all current tools anyway, and only affects those who play with non releases open source tools).

And yes, no surprises, should be a straightforward update from NPM 4, with a single exception that you’ll NPM local package cache will be cleared, but the speed of installs should make up for that anyway.

Webpack 3

Although not final yet, Webpack 3 seems to be moving fast. For the vast majority of us, it’s going to be a mostly backwards compatible version with Webpack 2 that gives us free performance and saves all the time we spend waiting for the build to finish!

For plugin creators, there might be a bit more fiddling. If you are using the Angular CLI, they arealready working on a version that works with Webpack 3.

.NET [Core]

.NET Fringe Conference Videos

One thing to love about .NET is that no matter what time of the year it is, there’s always some good .NET conference going on! This time it’s .NET Fringe.

[Video List]: .NET Fringe 2017 Conference Videos

The conference took place a few days ago, and the videos area already available. There’re many good topics like this and this on Open Source in .NET, this on what on earth does .NET Standard mean, this on whether Mono is dead, this on DotNetCoreKoans C# exercises, this about the A Wider .NET initiative, and a lot more.

And of course it wouldn’t be a recent .NET conference without talks about Docker and F#!

There are many lightning talks as well. They don’t have the titles in the YouTube list for these unfortunately, but the entire channel is worth browsing.

Other Worthy Content

[Article] MSDN Blogs: Performance Improvements in .NET Core
Performance is obviously a big thing in .NET Core, and this details some of the specifics.

[Opinion] The Coming .NET Renaissance
While there’s some crazy fun with .NET Core versioning and tutorials and all, it seems to be all for the good. Or is it?

[Article] Scott Hanselman: .NET and Docker
A lot of the docker tutorials around .NET focus on Visual Studio integration etc. This one covers a wider view, including realistic production workflows.

Gotta Stop Here…

Alright, there’re many more things I’d like to share with you here, but then the email would go forever, and a lot of the really good things here would be lost. So, gotta stop somewhere.

Feel free to reply directly to this email and tell me which resource you liked the most, and what topics you’d rather I mention or reference more info about in the next letter to make it more useful for you.

Until then!

Cheers,

A Very Long Tale of My Career, Or How Teaching NHibernate & Other Backend Stuff Got Me Into Readify

I told a few people how I joined Readify, but I never wrote it down. Here’s more than you ever wanted to know:

Before The Beginning

I didn’t have a computer when I was a kid, until I was 14 or something. I only had access to DOS computer in the mid-to-late 90s in a community center, where I was not allowed to run Norton Commander, because “you won’t learn anything like that”. I learned DBASE III, at the time my teacher was using Windows 95 or 98.

Then I got a computer. Internet came later. I noticed I could be a web developer. PHP was the craze at the time. I jumped on it, and learned some C and Visual Basic too. I didn’t get so far with either.

Then my family moved into another house. My new neighbour who attended a Computer Science college said they had free lectures on Visual Studio 2002 beta during summer, and I couldn’t have missed them! I got the software with a help of the public library I used to go to. The IT manager there was so helpful, even though I was barely allowed in the “grownups” section at the time. That reminds me of something else that’s useless in this context, which is how for over a year I used to note “useful URLs” in a small book, until an affordable Internet Cafe was open in the same library, and I was able to surf like a guru!

My First Company

I started work when I was at uni. I attended a international Microsoft developers conference in Egypt on 2004 and was picked as a best attendee by one of the speakers, to win a Microsoft MCAD training track (8 courses). I was in my first year of 5 years engineering uni.

It wasn’t easy doing a 4 hour training 3 days a week plus uni, but it paid off. I was lucky that most students were senior developers at the time, and all somewhat new to .NET.

A friend recommended me as a trainee in her company in the summer. She left the company, and shortly after, the other 2 developers left on the same day. It was funny. I had to handle this little company myself, with an interesting technical founder who at the time only knew classic ASP. I was interviewing both junior and senior hires technically while still called a trainee!
I also wrote a PoS Windows app that sync’ed with my web app’s SQL DB via Access and DataSets!

My First Move

Then one of the 2 developers who left invited me to work as a freelancer in her company, for a month, with 6 times my full time trainee salary. It was a custom CMS written by someone who left and no one else could wrap their head around the code, and the company needed to extend it in ways it was never meant to work.

That was flattering, and I was crazy about CMSes at the time. I took it, and after a few weeks of day and night work, I decided to dedicate my day to the new work.

It was uni time again (September 2005). My work was successful and led to more work. Eventually someone else left, and he was taking care of a system that nobody wanted to touch for a very different reason. It was in VB.NET! I didn’t know VB.NET at the time, but I took it, and it had some interesting business challenges, and .. em .. KSA remote client management challenges.

I decided to continue working as a part-timer during uni. It was the beginning of crazy era.

The Work – Uni Balance

A New Life

I’d go to uni, finish and head to the company, through a very crowded road (about 2 hours long, including 45 minutes in a single crossing), finish work so late I’m too tired to go home, pull in some chairs together to sleep on, to wake up early enough before anybody comes, and go to uni.

I’d go back home every 2-3 days to change my clothes. I also would take 2-4 weeks off before and during exams. I was so proud I was so rich I could order food whenever I wanted, and was being treated just like all the “big developers”.

Officially A Full-Timer

Then the same person who brought me to the company told me about this American company opening in Egypt, that is always working with pre-release technologies. She said she failed their test because she didn’t take it seriously as the company didn’t seem to have a proper office or anything. She told me she thought she was wrong, as it’s just a different culture. She told me the UX designer I liked the most in our company went to work there.

So, right after finishing a uni final test, I went to this other company for a tech test. It was a horrible idea. I think I did too bad, but having been blogging for a while about tech events in Egypt and other tech stuff, when .NET bloggers were relatively rare at the time (talking 2006), especially in Egypt, I was a well known person to the guys who worked there. Also one of them knew me from a tech forum we both used to help people in.

So, I got to the interview with the tech founder. He’s an Indonesian from a Chinese background, who I think holds a degree from Australia, and is partnering with an American in founding a company in Egypt! He was a legend!

These maybe were some of my best times in life. I worked as a full-time junior developer for pretty much the same salary as my previous company. I worked in the same way I did in the other company plus 10 hours a day in weekends to have 40 hours total. That was doable because our main account was in the U.S., and the time difference was in my favor as I was working mostly by night during uni.

A Senior Title

I really enjoyed the company. The founder made it ever better. He was an awesome geek. He stayed late with me, came on weekends, and sometimes we both would go out to eat or just walk. That was life!

I was the only junior developer at the time. A year later they started hiring junior developers and I was promoted to a senior developer. I was proud I got the title while still a student, even though that didn’t include a pay rise. That came a few months later though.

The company also encouraged me to start public speaking. I was a semi-frequent speaker at the only .NET usergroup in Egypt at the time, and the company itself held its own conference every year, having me as a speaker twice. That was cool, and helped more people recognize me.

The “Experts” Team

After graduating (2008), a friend from the MCAD courses told me his friend left his well-paying online freelancing work to go back to their old company, which was re-opening. It was a part of a very large well known brand in Egypt. He called me to join him in an architecture team they called “The Experts Team”.

It also had the guy I liked the most from the usergroup organizer team. I was getting ready for marriage at the time, and for those who don’t know, marriage costs tens of thousands in Egypt — that’s IF you have an apartment, and I was lucky that my parents suffered from paying loans for many years to ensure I had one before I understood why that was important.

Flying To Abu Dhabi

The Decision I Never Considered

So, I moved to the same team as that friend. I got married. I was happy where I was, working with nice people in a big company. Then the same guy who got me in the company told me about a senior position in a big company in Abu Dhabi. He told me he was called for the opportunity but he felt it was small for him, but OK for me. At first, I rejected the idea. I was still new in my company and wouldn’t want to leave so quick. I also never thought about traveling, but -let me admit- mostly because I never thought I’d be able to do it.

Then someone else from the company encouraged me to take it. My father, whom I thought would say don’t go, encouraged me to go abroad in a way that was very touchy. We are talking 2009. Things weren’t that bad in Egypt, but they were still definitely not good. Having recommendations from the company I didn’t want to leave, and also because the phone interview with my team leader was so nice (He was sure a geek I’d enjoy working with), all led me to go ahead with the offer.

That was the best decision I have taken in my life. Not just because the Egyptian company closed again in a year or two (the parent company thought software was lengthy and expensive compared to integration like SharePoint etc), but also due to political issues later, etc.

Life In Abu Dhabi

I arrived to Abu Dhabi. First time to travel by air. I got freaked out in Abu Dhabi airport when they couldn’t get a scan of my “eye print” and kept me held for an hour. But I was let in! And I started work. I was well respected and had my fame with me, which was nice at first. It wasn’t an oil company but the closest to that (half owned by government). I didn’t have the best salary, but had the highest medical insurance etc.

The Real Beginning

Meligy, The Backend-Focused Speaker

At this time I was all about design patterns and framework design. I had already spoken in the usergroup about all of these. I was being followed by Scott Hanselman on Twitter!

I also went too fast with Entity Framework when it was very new and it screwed me up. I turned to NHibernate, and after joining their mailing list looking for help, I myself became someone who helps others, and someone who interferes with some of the maintainers for how they’d make fun of some of the questions etc. I made good friends with some NHibernate core members. And this was how I heard about Readify.

In February 2010, I was invited by the .NET usergroup I used to speak in, to speak in a big conference they organized, called Cairo Code Camp. It was the 2nd one and I had already spoken at the first. I couldn’t miss it. Scott Hanselman was there. I’ll see him for the first time, AND, as a speaker, both of us, WOW!

I was delivering a session called “Framework Design Guidelines”. That is, stuff inspired by MSDN Patterns and Practices, and Design Patterns and Domain Driven Design.

Someone else was in there, Mitch Denny, the Readify CTO at the time (now in Microsoft U.S.). I enjoyed a nice conversation with him during speaker dinner party, although I didn’t know where he was working at the moment.

My Friend, From The NHibernate Core Team

Now, back to Abu Dhabi. Work was getting boring. I was hoping for some challenging work in U.A.E (Abu Dhabi or Dubai), again, not thinking about travel. It wasn’t very successful. I chatted to my NHibernate core team member friend, and he pointed me to someone he knew, who blogged about his interview process at Readify.

I was pretty impressed. I thought they’ll never take me. There were so many celebrities who worked there that I just knew I won’t be good enough to work there. I tried anyway!

And guess what? They called me back! I learned that Mitch actually remembered me, and knew where he works! I still had to go through a tough interview, and I passed! Hooray!!

The Foolish Call That Made Me Decide To Join Readify

But I wasn’t sure whether I want to make such a big move myself. Fun fact: when they asked me: “which state would you be interested in going to?” I said Sydney only because it was the only city I knew its name (and didn’t remember how I knew it). I wanted to get something extra to weigh the decision.

I DM’ed Scott Hanselman. Didn’t I tell you he was following me on Twitter and knew me in person? I asked for someone who can tell me in all fairness whether Readify was a good company. He pointed me to Tatham Oddie, our current Delivery Lead today :D — He had his phone number on his blog at the time. He picked up the phone once to find an anonymous international caller saying Scott Hanselman recommended him for asking whether Readify was a good company. Of course he wouldn’t say anything bad about his company to a stranger! It was a foolish call, but it was all I needed to get going.

Making The Move

My annual-paid rent was expiring — I had to borrow 60% of my salary to pay that rent (Not having a good enough eyesight for driving made cheaper out of the city options impractical for me). I had to live in a temporary apartment that had legal issues and could have had me kicked out any time because it was cheap and had nice furniture for me and wife. The visa took from April to August, which was very unusual, but it came, and I arrived in Australia!

Since I arrived, so many things happened. I hated Sydney at first because Abu Dhabi was so fancy (I used to move around in latest-model taxi cars, for 6 Dirhams or so — the city was so small). I learned to see the beauty of Sydney only a few months later. My son spoke his first words here, and I and him call it home today.

It’s been long time since arrival in September 2010. During the time I only left Sydney to one-day company annual events in other states, and a one week holiday in Melbourne earlier this year.

Life At Readify

I joined Readify and worked in the same company as so many celebrities I used to fancy, and so many great other people I discovered while working here.

I saw the company go through several growing stages, every time feeling a worry about losing the culture I love in the company, then feeling happy that it is as awesome as ever.

It is definitely an awesome place to work. There’s countless number of great people around here, and I also more than often get to either work at great customer sites with great people I loved to go back to and help with the great work they are doing (my current client is one of them), and other sites that are not as great as I’d hope to see them yet, but instead of feeling feeling bad, I feel inspired to help them make things better bit by bit. Because that’s why you’d hire a Readifarian :)

Yesterday And Today

I got to work with so many clients in different industries, from finance to media to charity to met and livestock handling(!), and many others. I got to play different roles, as a team member, as a mentor, as an appointed tech lead, etc. etc.

I spoke at ALT .NET and SydJS usergroups, and DDD Sydney and NDC Sydney conferences.

And I learned a lot more, not just at work.

I attended several workshops, like Distributed Software Architecture and Messaging by Greg Young, and International Domain Driven Design Tour workshop by Vaughn Vernon. I attended workshops on being a Scrum Product Owner, and a Scrum Master (and learned that I cannot be both at the time time, before they are different interests).

And then I somehow became known as a JavaScript guy. That’s me, who in 2007 was very happy that UpdatePanel in Webforms could abstract AJAX, and thought that people who could write code with Scriptaculous (before jQuery) were magicians. I even run a usergroup for one of popular JavaScript frameworks in Sydney!!!

I’m very proud of what I have done so far, and am still hungry for more learning and achievements. This is a journey that will hopefully never end before I die. One that I wanted to document the past pieces of before I start losing some of the important details.

Thanks for sticking with me till the end. in this long post :)

Cheers,

My Experience Running Jest In A Real Angular CLI Project On Windows

Jest is an alternative test runner by Facebook. It’s popular in React world. I was wondering how it’ll be like in an Angular CLI app. I knew a new semi-empty app won’t be a good enough test, so, I checked it in a real private project I’m working on, so see if it has any benefits for the project and the team.

While I cannot share the project codes, I can still share how the experiment went, as I talked about it yesterday at the ng-sydney Angular usergroup April gathering, also, as I logged it in a related Angular CLI github issue by a friend ng-sydney attendee.

Introduction

For the record, I tried Jest with instructions from @thymikee‘s post (which uses jest-preset-angular), and it worked just fine.

Let me share my findings:

Result Summary

  • It works!
  • It took some small changes.
  • It seemed slower in my case.
  • It caught more errors than Webpack/Karma/Jasmine, which I was very grateful for.
  • The experience is quite different though that I won’t make it the default my team yet.

Required Changes

  • I started with all the steps in the post above.

  • For some libraries I had to follow this github guidance, which made the jest property in my package.json look like:

    The transformIgnorePatterns is the most interesting here. I used \\ because I’m on Windows, and I used ^<rootDir>\\ to try to speed things, although it didn’t make a big difference. There’s also "allowJs": true in "compilerOptions" in src/tsconfig.spec.json.

  • I also had to change the tests. The post mentions all the changes needed (mostly only changing jasmine. to expect. in a few places).

    But there’s another change I had to do, which is removing any expectationFailOutput, which is when you give a custom error message for when a matcher fails to match. Seems Jest does not support that.

Gains

  • Jest seems to run tests in more isolation than the current Webpack/Karma/Jasmine combo, which showed me some errors in my tests that somehow didn’t show before.

  • Jest is reporting which tests are taking too long, the slowness warnings were useful smells to identify not-greatly-written tests.

  • The watch mode is very nice, even though it seems to work off git changes not file watching, which can be confusing at first when you see slightly more files than expected, but it’s still very useful.

Issues

  • As mentioned in Required Changes above, now I cannot use custom error messages in my test matchers (that said, it’s true that default matcher errors are very beautiful and obvious, but still).

  • At the moment, it seems the jest-preset-angular initialization code needs optimization. It doesn’t call polyfills.ts and instead calls its own set, even though it’s optimized for Angular CLI (for example, it uses src/tsconfig.spec.json).

    More importantly, it imports the entire rxjs library, which might hide errors when you forget to import some operators.

  • It’s surprisingly slower than the Webpack/Karma/Jasmine combo!

    For my 196 tests, the Angular CLI v1.0.0 default test runner (with Angular 4) takes ~ 55 seconds, while Jest takes ~100 seconds.

    Update: That conclusion might not be accurate. The time I quoted for each test runner is what the test runner reported. This might for example not include Webpack compilation and browser opening in Karma and might be total time in Jest. If so, then the total time would be the same.
    Thanks @hugoccampos for bringing this to my attention.

  • No browser tests debugging apparently (It might be my ignorance here). A bit harder maybe for those starting testing.

    The Angular CLI does a great job at making testing easy for those not used to it.

  • When Jest itself fails to run, for example if I put a badly formatted regex for transformIgnorePatterns shown above, or mess up something in my src/tsconfig.spec.json file, the errors it shows are very cryptic and tell you nothing that can lead to the real issue (unlike matching errors in tests, which are very nice).

Angular 4.0 Final Is … Here! And Angular CLI 1.0 Is Final Too!!

Update (March 24)

Angular 4 Final Is Out Already

Check out the official announcement, and github changelog.
After that, check the updated documentation for Angular 4 at angular.io.
If you need access to Angular 2 docs, check the black-and-white official docs archive at v2.angular.io.

Update 2

And, on the same day, just as mentioned earlier in the post below…

Angular CLI 1.0 Final IS Out Too

Checkout the changelog, README / Docs.
And if you ever used Angular CLI before v1.0 final, check the official upgrade guide.

Hello, This is Meligy from GuruStop.NET.
Good news, we are expecting Angular 4 final any hour now!

How Do We Know?

During the ng-sydney Angular meetup gathering last Wednesday, Stephen Fluin from the Angular team repeated a couple of times that Angular 4 final is expected this week.

A quick look into the latest Angular team meeting notes also confirms that Angular 4 is due on Thursday, March 22 (although they mentioned there are a couple blocking issues, so, it might be on Friday or so).

Angular CLI, the best tool to create, develop, and test Angular applications, is also going to be released as 1.0.0 final alongside Angular 4.

P.S.
If you prefer to add server-side rendering, you might check Angular Universal fork of the CLI fork for Node, and `dotnet new Angular` for ASP .NET Core. If you need to build an Ionic app, check Ionic CLI 3 beta. They all would come with Angular 2 support by default only though, while the official Angular CLI supports generating Angular 4 projects by running `ng new app-name –ng4`.

[Video] Angular 4 And The Angular CLI

If you want to learn more about Angular 4 and the Angular CLI, see Stephen Fluin`s video here:

[Video Playlist] More Recent Talks, NG-NL

If you are interested in more free up-to-date Angular videos, the NG-NL Angular Netherlands conference also took place last week, and many session videos are available now in this YouTube playlist:

https://www.youtube.com/playlist?list=PLQi8NNYCH8TDFnOhjrIsjZGMD6Ks8SQid

Angular 4? (Not 3!!)

Just for those who don’t know, the reason there is no Angular 3 is that the Angular router for Angular 2 has been rewritten 3 times, and the NPM package for Angular router is now 3.x, while all other Angular packages are 2.x.

To make all the packages the same version again, the Angular team skipped version 3 entirely, and jumped directly to version 4.

It’s worth reminding though that Angular 4 is mostly backwards compatible with Angular 2. You should expect most if not all your applications to continue to work with it.

And a final reminder, it’s “Angular”, for Angular 2+, and “AngularJS” for Angular 1.x. These are the names that the Angular team prefers, and that’s what you’ll see me use more often going forward.

What’s Next?

Once Angular 4 final is out, I’ll send you a follow up email, with a very customized writeup of what I personally find most exciting about Angular 4, and can’t wait to use in all my production projects.

I’ll also share some awesome resources for RxJS and TypeScript.

Stay tuned!

Cheers,

– –

Meligy

ng-sydney | Usergroup Founder & Organizer

Shared Modules In Angular Apps: Providers Best Practices And What Does `forRoot()` Do?

When you write a shared module for your application, that contains stuff you use in other modules in the same app, you typically want all the services in that module shared only once.

If you just put the services in the providers property of the shared module’s NgModule() decorators, you might get weird cases, especially with lazy loading, when it feels like there’s more than one instance of the service. This is bad if you want to have shared state.

So, there is a better way to write your shared modules:

import {NgModule, ModuleWithProviders} from '@angular/core';
import {CommonModule} from '@angular/common';
// ... other imports

export const providers = [
    // ... your shared services here
];

@NgModule({
    declarations: [...],
    imports: [
        CommonModule, 
        SomeLibraryModule,
        ...],
    exports: [
        SomeLibraryModule.forRoot()
        ...
    ]
})
export class SharedModule {
    static forRoot() : ModuleWithProviders {
        return {
            ngModule: SharedModule,
            providers: [...providers]
        };
    }
}

The forRoot() pattern / convention is very common in libraries, and you’ll see it in things like ng-bootstrap and others. The name isn’t special for the compiler / framework, but it’s a common pattern.

When using these, in the imports section you can just import the module itself (which gives you any declarations needed like directives etc), and in the exports use the forRoot() version of the module so that it’s available for consumers of your shared module.

Then in your other application modules you can add SharedModule to their NgModule‘s imports normally, except for the AppModule.

The AppModule will be the only place where you add SharedModule.forRoot(), like:

Then in your AppModule, import it as:

@NgModule({
    declarations: [...],
    imports: [BrowserModule, SharedModule.forRoot(), ...],
    ...
})
export class AppModule {

}

There is one exception to this though. Your tests.

If you are writing any unit tests where you are importing the SharedModule, you will probably need to import the module with its providers, because there is no AppModule in the test.

Something like:

TestBed.configureTestingModule({
    imports: [ SharedModule.forRoot(), ... ]
})
...

If you haven’t already, have a look at the NgModule official documentation. There’s a main guide, and an FAQ page.

And of course let me know if you have any questions / problems.

Successfully Upgrade Your angular-cli App (Beta 28 & Below) To The Latest @angular/cli Beta


Have you had issues moving from angular-cli beta 28.3 or earlier to the newer versions of the CLI?

Try these steps then!

Global Dependency

This one is as easy as:

npm rm -g angular-cli @angular/cli
npm cache clear
npm i -g @angular/cli

Specific Project

Note: You do NOT need to have the CLI installed globally for this (although it’s a good idea).

First, ensure you have an npm script in your package.json file that looks like:

"scripts": {
    "ng": "ng"
    // ....
}

In this tutorial I’ll replace ng calls with npm run ng -- (note final space ) for those people who may not be able to upgrade their global package.

Now, let’s get to real work.

Commit everything you have in git, then:

npm rm angular-cli @angular/cli
npm cache clear
rm -rf node_modules
npm i -D @angular/cli
npm run ng -- update

Accept all files from update (which used to be called init) other than app module and component, especially (but not limited to) angular-cli.json, polyfills.ts, package.json and main.ts.

Then go to git undo any unwanted change (deleted packages from package.json, missing scripts or files from angular-cli.json, etc). Undo entire app module and component files if you accepted them by accident.

Then

npm install
npm run ng -- build

And you can go roll with npm start / npm run ng -- serve.

All good!

Use Yarn Package Manager In Your Angular CLI Projects

Yarn is an awesome tool to reduce the time it takes to install large NPM packages like the Angular CLI. And the Angular CLI is the best tool to kickstart and manage your Angular 2+ projects.

You can use them together, and it’s very easy.

Initial Setup

First, you install Yarn. If you have it installed already, ensure that you have version 0.19.x at least to avoid issues with global packages. You check your Yarn version by running:

yarn --version

Then you need to ensure that the folder where Yarn writes the global packages executable files.

On Windows, the MSI installer should do it for you. For Mac, check the “Path Setup” part in the installation page.

Once done, ensure to open a new terminal after the installation, and test it.

To find what folder to look for:

yarn global bin

Then run echo $PATH (Mac) or echo %PATH% (Windows command prompt) to get the PATH variable and check it.

Installing Angular CLI

OK, so yarn is installed, and it’s installed correctly. Let’s get Angular CLI:

yarn global add @angular/cli

That’s it!

Adding To A New Angular CLI Project

Starting from beta 31, Angular CLI added native Yarn support.

When you create a new project, the CLI goes and runs npm install for you by default. You can tell it not to by passing a --skip-install flag (-si for short) like:

ng new test-project --skip-install

Note: The option was called --skip-npm / -sn before beta 31.

But then you’ll have to go run Yarn yourself

cd test-project
yarn

Running yarn by itself is similar to npm install. It’ll read your package.json file and add the packages to node_modules as needed.

Or… you can just tell the CLI to use Yarn instead of NPM!

ng set --global packageManager=yarn

This way, you don’t need to do anything special when creating new projects. Just go with ng new test-project with no special flags, and the CLI will use Yarn to install the project packages, unless you specify --skip-install.

This is a user-level setting. It does not affect the generated project in any destructive way. It still has a package.json file (because Yarn works just fine with that), and anyone who doesn’t have Yarn can just run npm install.

More on that below. Before that, let’s ensure that everything worked correctly by running npm start or ng serve etc.

All good? Awesome!

Bonus: A Note About Git

When the Angular CLI creates the project, it initializes it as a git repository and git adds all the files it generated. After the Yarn install, you’ll find another file yarn.lock that’s not yet added.

Yarn team recommends adding the file to git, so, you can do just that, and then commit the result as the new project.

git add yarn.lock
git commit -m "initialize new project with Yarn and Angular CLI"

When you push your repository to a remote server, and someone else pulls it, they can run yarn, or simply npm install (because the package.json file is still there and updated), and get going with the project.

Conclusion

Hopefully that was as simple as you expected it to be. If you have any questions, you can just drop me a comment here, or use any alternative way mentioned in the video.

Don’t forget to sign up for my newsletter so that I can share with you all the resources I use to learn this stuff and more.

Cheers,

Angular 4 Beta is out 🔥 Everything you want to know!

Hello there,
Have you heard the news? Angular 4 beta is here!

Yes, Angular 4!

Update: December 15, 2016

Angular 4 Betas have started coming out already.

Check out out from here.

This post started on December 12, 2016, and has been actively updated since.
Each update has its date marked.

Have I managed to make you panic yet?
Hopefully not. You might be raising questions already still, like:

What about Angular 3?

There won’t be any Angular 3. Right now the Angular Router version is using the 3.x space already, and is not in sync with the rest of Angular, which is still at 2.x.

So, the easiest way to bring them back in sync is to skip v3, and jump directly to v4.

Angular 4? Another Big Bang Release?

Not really:

Angular 4 will be released in March 2017. The first beta will ship in December (sometime this week as mentioned above). The intention is to release a new major version every 6 months.

Each new version is allowed to mark APIs from the last previous major version as deprecated, but NOT to break them. So:

  • Angular 4 might deprecate APIs from Angular 2, but not break them
  • Angular 5 might only deprecate APIs from Angular 4, but not break them (might break APIs from Angular 2 though)

The team has confirmed that Angular 4 will be a backwards compatible upgrade from Angular 2. You might expect a few deprecations at worst (until now that’s none BTW). But no API change / breakage.

So, what is Angular 2 and Angular 4 called now?

The team says: Just call it “Angular”. This should be more future proof.

Given Angular 4 is a backwards compatible upgrade, people searching for solutions to issues, etc., might find an Angular 2 answer, and that answers should just work with their Angular 4 app.

How about Angular 1?

Someone asked me on Twitter: “How would I avoid Angular 1 results showing up for my search then?”. I think the closest thing is adding “-angularJS” to your search (or “NOT angularJS”, without quotes in both). Angular 1 articles tend to use this way more than Angular 2 ones.

When was that announced?

There was a new Angular conference in Belgium last week. During that, the team made the Angular 4 announcement in the keynote.

Watch the full video from here

The conference team did not announce anything about releasing more videos, but when I asked them they confirmed that they’ll be available soon.

Update: December 12, 2016

The information has also surfaced in the official Angular team meeting for December 4:

Update: December 14, 2016

The team has also created an official blog post about Angular 4:
Ok… let me explain: it’s going to be Angular 4

How about … ?

If you have any more questions, just reply to this email. If I know the answers, I send it to you right away. If I don’t, I’ll do my best ti find it and send it to you.

Until next time!

Cheers,

– –

Meligy

Readify | Senior Software Consultant
ng-sydney | Usergroup Founder & Organizer

Email: eng.meligy@gmail.com
Mobile: +61 451 835006
Twitter | Blog | Linkedin | StackOverflow

 

P.S.

If you are in NSW Australia, the ng-sydney usergroup is holding its December gathering on Wednesday this week:

Check it out from here

If you noticed, it’ll be on December 14. This is the same day to expect Angular 4 beta 0 — how exciting!