Adding constraint on a foreign key with node-pg-migration

node-pg-migration is a useful library. You can add a constraint of a foreign key with a simple references property on the column. For example, you have table client_session with publishable_key column and you want to reference publishable_key column in workspace table where it is not a primary key (just a unique key). The following usage with object: schema, name, won’t work:

 pgm.createConstraint({
    schema: "seam",
    name: "client_session",
  }, "client_session_publishable_key_fkey", {
    foreignKeys: {
      columns: "publishable_key",
      references: {
        schema: "seam",
        name: "workspace",
      },
    },
  })

 If you write a migration for Postgress and Node.js using node-pg-migration (e.g., table 1) and want to create a foreign key reference / constraint (createConstraint or references on createTable) on a non-primary key of the other table (table 2), then references by an object containing schema and table name, do not work. This is probably a bug in node-pg-migration. It tries to match primary keys only, but our publishable_key is not a PK in workspace.

It looks like node-pg-migration is not smart enough to add the column/field name like it does for primary keys. You can use a string (seam.table2(col)) as the references value, not an object, or just use raw SQL to bypass node-pg-migration behavior, e.g.,

 pgm.sql(`
    ALTER TABLE seam.client_session
    ADD CONSTRAINT client_session_publishable_key_fkey
    FOREIGN KEY (publishable_key) REFERENCES seam.workspace(publishable_key);
  `)

Or in the node-pg-migration method:

 pgm.createConstraint({
    schema: "seam",
    name: "client_session",
  }, "client_session_publishable_key_fkey", {
    foreignKeys: {
      columns: "publishable_key",
      references: "seam.workspace(publishable_key)"
    },
  })
},

How to show all constraints on a Postgres table

I recently needed to update the check constraint on a Postgres table column. This check does format validation similar to regex. This check was part of the CREATE TABLE statement meaning it was created with the table.

However, ALTER COLUMN is not supporting updates of checks. So what we need to do is to drop the constraint and create a new one. dropConstraint requires the name of the constraint, but the name is not obvious. This is because check was create with createTable. To find the name, there’s a SQL query we can run:

SELECT con.*
       FROM pg_catalog.pg_constraint con
            INNER JOIN pg_catalog.pg_class rel
                       ON rel.oid = con.conrelid
            INNER JOIN pg_catalog.pg_namespace nsp
                       ON nsp.oid = connamespace
       WHERE nsp.nspname = '<schema name>'
             AND rel.relname = '<table name>';

📱💬Leveraging Messengers for MVP Validation and Sales in Your Tech/IT Startup

As a startup founder, you might think that building an app, whether it’s for the web or mobile, is the only way to validate your business idea. However, that’s not necessarily the case. In fact, using messenger apps like WhatsApp or Telegram can be a great way to test the waters and validate your concept with minimal resources.

In most cases, startup founders don’t need to build apps (web nor mobile) to validate their ideas. For a minimum viable product (MVP), it’s good enough to “fake it till you make it” with a manual service by a human over a messenger. This is because even non-MVPs use it.

I’ve ordered cakes, cigars, flowers, meat, taxi, nanny, cleaning and many other products and services over WhatsApp. I’ve paid in my banking apps, after I got the payment info via WhatsApp. I’ve scheduled personal trainers, car services and others via WhatsApp and then paid cash.

In fact, there are already many industry use cases where messenger apps are being used to provide products and services. If you think about it, Uber, Rappi and Instacart often rely on messages to confirm destination or replacements of grocery products. The core of their app is catalog and messaging which can be done in WhatsApp or Telegram. Catalog can be done for the MVP with a PDF or just images sent over the messenger.

Let’s say your MVP is not an e-commerce where clients pick a product form a catalog and make an order. It’s something more complicated. Then you do the complex thing manually by a human and get results via messenger.

In the end, don’t waste time and money on building web or mobile apps. Just validate and make sales with WhatsApp or Telegram first. 💡🚀

What’s new in React 17: new features and improvements

React.js version 17 was released in October 2020 and introduced several new features and improvements. In this blog post, we’ll explore the major updates in React.js version 17.

No More Event Pooling

One of the most significant changes in React.js version 17 is the removal of the event pooling optimization. Previously, React.js used a technique called “event pooling” to reduce the number of event objects created by the browser. However, this technique had some drawbacks, such as preventing the use of asynchronous event handlers and making the code more difficult to reason about.

With React.js version 17, the event pooling optimization has been removed, and every event object is now a unique instance. This change allows developers to use asynchronous event handlers and makes it easier to reason about the behavior of event handling in React.js.

Continue reading “What’s new in React 17: new features and improvements”

MMAT: My Teaching and Learning Approach

In our day and age, learning is more important than ever because things change so rapidly. I learned a taught a lot of things during my career which led me to discover that the best and the most effective learning method is to use MMAT: Motivation, Methodology, Action and Time.

Continue reading “MMAT: My Teaching and Learning Approach”

Why I’m Getting a Second Master’s Degree from HEC Paris

Two months ago, I applied and was accepted to a master’s program at a prestigious business school (ranked #2), HEC Paris. The degree is title Master of Science in Innovation and Entrepreneurship (MSIE). It has 10 normal courses, 10 practical project-based courses and one large team project. The master’s program lasts about one year and a half. Thus the program ends in 2020. However the graduation will be in 2021, because HEC has only one graduation ceremony which is held in its beautiful Paris campus.

Continue reading “Why I’m Getting a Second Master’s Degree from HEC Paris”

Acquisition of Node University by DevelopIntelligence

After 2.5 years of starting my online school for software engineers Node University and growing it to one of the best resources on Node.js, APIs and AWS, I’m happy to announce the acquisition of Node University by the tech training company DevelopIntelligence. 💰😎🍾 I’ve known and worked with DevelopIntelligence for many years. They deliver outstanding in-person tech training to Fortune 500 companies. The synergies and future of combining in-person with online training are massive. I’m sure the new team will take Node University to the next level! 🚀

Azat’s Management Philosophy

Have you ever wondered what your manager is doing all day? Are you guilty of secretly thinking he/she is playing Candy Crash and attending endless stream of useless meetings? If yes, then you are normal. Management is often invisible and hard to understand. We have tons of books and courses on management but too few good leaders. Sadly, many of us had a bad boss and too of us had a great boss. This post will share my approach to being a good leader.

My management philosophy revolves around three things but one of them is the most important because if we get it right, then all other parts will fall into place. One thing that I care about the most, and which is my main job, is people. I coach, mentor and help people to grow in their careers. I find their strengths and talents. Most people are not that great at self awareness and self observation because their insecurities, desires or emotions interfere with the clear perception of reality. Observing people from outside as a manager or peer gives much better results—a much cleaner and fuller picture.

Continue reading “Azat’s Management Philosophy”

Why GraphQL is Taking Over APIs

A few years ago, I managed a team at DocuSign that was tasked with re-writing the main DocuSign web app which was used by tens of millions of users. The APIs didn’t exist yet to support our new shiny front-end app because since the beginning the web app was a .NET monolith. The API team in Seattle was taking the monolith apart and exposing RESTful APIs slowly. This API team consisted of just two engineers and had a release cycle of one month. Our front-end team in San Francisco released every week. The API team release cycle was so long because a lot of (almost all) the functionality had to be tested manually. That’s understandable. It was a monolith without proper automated test coverage after all—when they modified one part, they never knew what can go wrong in other parts of the application.

Continue reading “Why GraphQL is Taking Over APIs”

Practical Node.js, 2nd Edition: Colored Print Book is Ready

The Practical Node.js, 2nd Edition print book is finally ready. It turned out the biggest thickest book I ever wrote (500+ pages). Practical Node, 2nd Ed. is even thicker than React Quickly.

The Practical Node.js, 2nd Edition print book is finally ready. It turned out the biggest thickest book I ever wrote (500+ pages). Practical Node, 2nd Ed. is even thicker than React Quickly.

Continue reading “Practical Node.js, 2nd Edition: Colored Print Book is Ready”

Triage vs. Planning

A discussion came up in at my work about distinction between a triage and planning meetings. My take on this is that triage reactive whereas planning is active.

Let me illustrate this with examples. Imagine a customer-facing app like a WordPress CMS. Users use the CMS, encounter bugs, and curse. They sometimes report the bugs. An engineering team or a product manager will triage the incoming bugs and issues to sort out what need an urgent fix and what can be deferred. Bugs tend to be urgent but not always important (at least not important for the majority of users).

On the other hand, there is an important task. The CMS has a roadmap to add a paid feature that should increase company revenue and make the next year profitable. The paid feature needs to be implemented. It’s the top priority. Its implementation must be planned actively, separately and before any bugs. If not planned, bugs can take up all the time.

Thus, my suggestion is to plan and plan the priority first. Then plan the triaged work on bugs and tech debt. Focus on important first, not urgent.

Breaking Into IT and Tech as a Beginner

I got an email from a person frustrated that he can’t get an entry-level job in IT/tech. He knows PHP, HTML, CSS and MySQL, but he is tired of all the companies rejecting him and requiring a “perfect” expert (as he put it). That’s true that there are not that many entry-level jobs in tech. It’s hard break into tech. Most companies only interview senior engineers with at least five (5) years of industry experience.

Continue reading “Breaking Into IT and Tech as a Beginner”

Tricky English Grammar for Programmers

As I was editing my new book Practical Node.js, 2nd Edition, I found a few recurring mistakes that my publisher’s editor was correcting. I wrote over dozen of books but I still don’t know some of English grammar. Do you know some of these tricky rules?

  • Front-end app vs. frontend
  • Which vs. that
  • While vs. whereas
  • May vs. might
  • Login vs log in

Front-end is an adjective while frontend is a noun. For example, “I build front-end systems”, but “I work on the frontend”.

Which needs comma and it is less important than that, which is used without a comma. The which clause can be removed but the that one cannot be removed without the loss of the meaning. For example, “I like Node.js, which is JavaScript on the server”, but “Create a file that starts the Koa server”.

While and whereas are similar when you contrast two things, but whereas is a bit more formal (and less used in spoken language). While can be used for timing but whereas cannot. For example, “window is a global variable in browsers while/whereas global is in Node”, but “When it’s noisy in cafes, I write code while listening to Spotify”.

May has more probability than might. For example, “I may go to Japan next quarter”, but “I might quit Node.js and move to Denmark to study Artificial Intelligence”.

Finally, login is a noun and log in is a verb. For example, “Implement login using OAuth 2.0”, but “You need to log in to AWS console as admin first and only then create a new user”.

5 Habits of Highly Successful Software Engineers

There are multiple ways how software engineers can achieve a successful career. Some can be early employees at Google while others can be a life-long employees of IBM. Some can build side projects while other can get equity. But there are only five common habits and traits:

  1. LEARN: Find balance between learning and doing. Have a solid knowledge of fundamentals either from college degrees or from educating yourself with books and online courses. Constantly apply your knowledge to practice.
  2. WORK: Find balance between productivity and rest. Consistency in productivity is better than burnout.
  3. CONTRIBUTE: Learn the business side of things. Produce highly valuable products which are useful for customers and beneficial for the business.
  4. INNOVATE: Invest in a forward-thinking technology that a reasonable person would expect to become more in demand and desirable over tie.
  5. THINK LONG-TERM: Treat others with respect, honestly and fairly. Think and act long-term. Contribute to open source or teach because it helps you and others.

Programmer vs. Software Engineer vs. Software Developer vs. Coder

Hello everyone! In this post, I want to contrast the terms with which other people and we ourselves call us. There are a lot of confusion around the names for our trade. People use terms such as software engineer, software developer. Some people even use programmer or coder, etc., etc. And some event go as far as ninja, guru, or rock star. So let’s take a look at the differences. Of course, it’s all just my opinion but I’ve been in this industry for 15 years. I know a bit or two. So let’s go ahead.

Continue reading “Programmer vs. Software Engineer vs. Software Developer vs. Coder”

5 Reasons Programming is Awesome

Let’s start from the smallest to the biggest five reasons why programming and software development is awesome.

The reason number 5 (smallest) is programming can pay really well. The average income in the USA is somewhere along $50K per year per household. Programmers typically starts their careers with $80K/year salaries. In major metro areas the salaries are way higher than that. They can easily be in the $120–150K/year range.

The reason number 4 is that you are never bored. There’s always something new. Sometimes new technologies come out before you even release your product. Thus, you are never out of things to learn and update. A lot of people are bored out of their minds at their jobs. Most of them perform the same mundane tasks for 5, 10, 15 years… Not you. Lucky you! Programmers can always grow, learn and master the skills by learning and seeking more challenging problems and solving them.

The reason number 3 is that it’s a real career. Some jobs are not careers. Avoid them. For example, a taxi or an Uber/Lyft driver will always be a driver. A Denny’s waitress will always be a waitress even after 40 years at her job. It’s a dead end. Avoid it. A lot of programmers start as junior developers/engineers, then they progress to associate developers. This could happen in as short as two (2) years. After that, some of them are promoted to senior developers in as short as 3–4 years. That’s not all. The path continues to principal, staff engineer, architect, manager, director, vice president of engineering and to CTO. A lot of tech companies have engineers as their senior leaders, e.g., Microsoft, Google, etc.

Continue reading “5 Reasons Programming is Awesome”

My New Book Concept and Top Qualities of a Good Software Engineers

Packt Publishing reached out to me and offered to do a book.

They pretty much want me to do any book and pre-agreed already. They gave me carte blanche on the topic.

(More or less, I doubt I can convince them to publish a vampire thriller set in a Silicon Valley startup.)

Funny thing is that I know the editor. He worked at Apress Media when I published my first book Practical Node.js with them.

I submitted to them my idea about a software engineering career book for junior developers. They liked it. It can become a book!

While thinking about the career in software engineering, I thought about top skills.

As in any profession, software engineers requires a combination of certain skills and techniques.
I’ve done software engineering for over 15 years.
I taught total beginners (in Hack Reactor) and professionals (in Fortune 500 companies).

The most important skill in a good software engineer is not smarts. No. It’s not how good he can write code.
It’s not soft skills either

Continue reading “My New Book Concept and Top Qualities of a Good Software Engineers”

Born vs Made Programmers

Are programmers born or made? It depends. In 2010s, programming is so much easier than it used to be in 2000s. More and more gurus and dev bootcamp founders proclaim that programmers can be made.

I won’t say programmers are made. My answer: it depends. Instead of thinking programmers are made, utilize whatever belief is more useful to you.

If you are starting on the programming path later in your life as a second (or third, or fourth) career choice, then thinking programmers are born is detrimental! Why would you do such a thing?

Think and truly believe that programmers are made, if you want to succeed as a programmer. That’s because every time you encounter an issue, you’ll be inclined to work through it when you think that NOW you are a programmer.

On the contrary, you will be more successful thinking programmers are born, if you has been programming from your teens and programming is the only career you ever had. The reason is when you encounter a problem, you’ll be forced to find a solution because that’s what you do. You are a programmer and alway was. You have to come up with the answer because you are a programmer. You’ll value your job and think it’s your missing to write great software, because you won a lucky lottery.

If we dig deeper, programmer are not born. No one in the hospital looks at a child and says “congratulations, that’s a programmer”, “you are luckliy, that’s a QA engineer”, “sorry, that’s a designer”. No. Most likely it’s a dumb luck. The kid got a computer as an early age and tried programming and liked it. Then he got more experience and made himself into a programmer. So born is actually made just at an earlier age.

In any case, think and believe whatever is more useful to you in your career and life. Not what someone else tells you.

IT Consolidation

IT Consolidation

I’ve been working on the new edition of my best selling book Full Stack JavaScript. I was updating references, links and names of the services. A lot of libraries are dead and the links are unreachable. A lot of services are dead or being bought by big companies. The list is huge. Compose which was MongoHQ is now part of IBM. StrongLoop is part of IBM. Heroku is part of Salesforce. Parse.com was bought and discontinued. Firebase is part of Google. Joyent is part of Samsung.

It’s kind of depressing. Take a look at this page. Nodejitsu, which was one of the first Node PaaS solutions, says it joins GoDaddy which is just an hiring of the team. They refer to Modulus which you think is another PaaS, but it’s not. It’s a very poorly-done website for what looks like some consulting company in the trading space or like some scam a 14-year old kid put together to get money for video games. The link to the blog post announcing Nodejitsu closure is 404 Not Found.

The previous edition of Full Stack JavaScript was published in 2015. In three years, a lot of companies either sold for scraps or closed or both (sold then closed the projects). It’s very refreshing to see this trend in a long span of several years.

Every market goes through cycles. First there’s an expansion with various offerings and then there’s a retraction with just a few major players dominating. It’s a winner takes all economy. Amazon, Google, Microsoft and IBM are serving major cloud services now. Startups are hard and most of them don’t know how execute. VCs are pushing for startups to spend more to acquire marketshare. The big companies have more leverage and more room for mistakes. They can just buy the best startup in the end.

Is it still worth trying to start your tech startup in 2018? Probably not unless it’s something completely new. You can’t drive forward while looking in a rear view mirror.