loading...

My Misconception when Learning Web Dev

nodeicode profile image Lohit Aryan ・2 min read

Alt Text

Misconception

I got ready for starting my summer project which was a boilerplate for NodeJS apps. I had only finished a few courses and online tutorials on node with express routing and login features using PassportJS. It took me a while to navigate through all the docs and stackoverflow to finally finish the app and I thought gained a lot of knowledge on making and deploying a proper app, I was already celebrating that I was now intermediate level profecient in JS.
Alt Text

Realization

I was interviewing for a web dev internship. I was really excited since I was confident in what I knew. He started of basic with some troubleshooting questions, asking about myself and my projects etc. now he asked me another pretty basic question: I enter a email into a textfeild and submit it, how do check if its valid on the backend? pretty general but looking back to my project I just used a dependency and called a function to check its validity in a controller .js file I had no idea how the check actually works. I assumed its a simple loop to check for the @ and get info after that and told my interviewer the same. Well turns out that answer was not even close to being right.
Alt Text
The answer the interviewer was expecting was using regex to check the pattern which will give us a result faster and told me that looping is actually not efficient nor usable at all.

Then it hit me hard, the misconception that I knew making a nodejs app which in reality I had no idea HOW my code does what its doing. I knew I could just import a dependency for validation, sanitization and other features but did I know HOW they work? the simple answer was nope.
Alt Text

Conclusion

Always learn HOW the language/framework/dependency works and not just calling it. Even a college freshman can search up code copy paste it and learn it a bit to make it work but I want everyone to realize from my experience that you might be missing the most important and fun part of learning!

Posted on by:

nodeicode profile

Lohit Aryan

@nodeicode

Senior Ugrad currently hacking in mostly full-stack development using Reactjs and Nextjs. Looking for Full Time Jobs preferable based on full-stack Web development.

Discussion

markdown guide
 

Sorry about your luck but that sounds like a terrible place to work. You gave a sub-optimal, but completely usable answer and that seems to have tripped them up ("It's the way Google does it!") Sad and pathetic, that's not appropriate criteria for an entry level position ... I would have probably hired you. If you can tell me how a loop works and-also basic if/then logic you can do the job (I promise .. the basics are there ... you can learn as you go if you find the right place)

 

You're lucky, the interviewer was completely wrong. We should never be using regular expressions to validate email addresses. The format for an email address is so complicated, that even the most profienct regex is only 99% accurate and is absolutely not the sort of thing I'd expect any developer to be able to write out in an interview (if you're interested, they have expressions for most of the common languages at emailregex.com/ )

Just some of the many assumptions that people tend to make about emails:

  • They're only a max of about 50 characters
  • They can only have one asperand (@)
  • They only use ASCII
  • The domain only uses ASCII
  • The local part can only contain letters, numbers, and basic punctuation

The absolute best way to test if an email address is valid is to send an email to it. Even if you validate that an email address is formatted correctly, there's no guarantee the user didn't mis-type it in the first place.

 

Dude, you are checking valid email adresses, not user ability to type, that's checked when you confirm your email. Finally, 99.99% != 99% (edit: it seems that perl/ruby developers are regex purists)

 

Did you look at those regular expressions? Nobody, not even a senior, should be expected to rattle that off in an interview.

Besides, a regex like that in any codebase is a sign of something wrong. Code should be human readable. Obviously regular expressions fly in the face of that, but there's surely a limit to how far one goes with them in production-worthy code?

But you can make it human readable when wrapping it using a function, once the regex is tested in isolation, it can be used in production code without problems. I'm not auditing python regex engine each time I want to use the re module, and still that module is used in production code. If you restrict the solution space of a problem to what you can read and understand at the lowest level possible, maybe software would took ages to get into production... Of course, you can't solve every problem in sw using regexes, sometimes a simple looping solution solves the problem well enough to move on in development.

But there's still no way anyone would be able to write anything close to it in an interview.

I agree, and if you find yourself having to write that nonsense perl regex to get a job, it will be better for your mental health not getting it.

I had this funny experience once when I was applying for a Perl job and they asked me to analyse a 300 line sort routine... I guess that's their version of the regex

 

And yet, at its heart Regular Expression engines simply loop over the input. They have some extra features that form a thing called a "state machine" that allows them to have different routes depending on what characters they encounter, but it is still just a loop over each character in turn and tests of each character to see if it matches the expected pattern or not. I suspect that the interviewer was trying to prove they know more than you or to "put you in your place". Don't listen to them, they are wrong. Your answer is perfectly valid and correct!

Extra credit answer: the regex engine has the ability to step backwards when one branch fails to match any further, which is where the state machine comes into play...

 

Great article! In my early days of learning web development, I was so naive to reinvent the wheel every time I encounter a problem. Then I felt stupid when I found there was a library that already did what I develop.
After reading your article I realized they were the most learning part of my journey. Thank you!

 

Actually, it's very important to reinvent the wheel, when you start your journey of learning something new, but it doesn't make a sense to make everything from scratch.

 

Well, now I know that regexp works faster! Thank you :) And I wish you strength to continue your dev path, it gets better and much more interesting.

 

Though that regexp may not be faster (in terms of performance, compared with creating own loops and conditions), regexp is more efficient to use for comparing (using str.match() etc.) and extracting parts of strings (thanks to capture groups / {}). I also recommend learning regex as it can be used outside JavaScript such as PHP, Java, Swift, and even Python.

 

I actually never thought of using regexp even in python to comparing, before reading about example in this article. Though they are not an easy thing to master, I agree that it's a useful thing in many ways!

 

Hello, I'm new here what site can you recommend in learning programming,

 

Programming is a broad topic.And there is no website that teaches "programming ".You have to create a 'road-map' for Learning. First what field are you interested in,machine learning,mobile dev,web dev,automation the list is long.Narrow down to wha you want to learn.Then research on the languages used in that field.For example in web development python among many others is used.Then after learning python you can learn the frameworks in web dev with python scenario,django.It will make the learning process easier for you if you have clear vision on what you want to do with programming.
Goodluck.
(Don't mind my spelling,i typed that reply on my samsung a10 with a cracked screen)

 

You have to create a 'road-map' for Learning.

Disagree! Learn whatever interests you until it gets boring then move on, you'll be back sooner or later if it's a relevant subject. There's no good road-map and I strongly suggest you don't pigeon-hole yourself by specializing (i.e. 'front-end' or 'back-end').

You actually agreed to my point,"whatever interests you."I get that maybe you don't know alot in programming. We have programming languages, frameworks, libraries,dependencies, design patterns blah blah.Say you're interested in mobile dev,you can't just start from nowhere,you have to know alil bit about mobile dev,what languages are used,what platforms,what design patterns.I agree you start with what interests, but you still have to know which specific languages to use,which frameworks and so on.

Allow me o reiterate something here.I am a self taught web and mobile app developer.And it took me less than 2 years to get where i am,i am not saying i am perfect but atleast i can get a website up amd running.When i started i sketched out exactly what i wanted to chieve.I started with the common html,css and js.Then i went to Django studied it then i took crash course in react and angular.After that i started learning mobile dev with dart using a framework called flutter.And here i am.

Yeah, your right. I probably should have included this - If you want structure there's lots of places to get a general idea for one. Just look at the course order on Udemy or Coursera (or wherever). That's probably a good idea but without a formal setting to compel me (like a classroom) I'd probably use that as a "suggested order" and (mostly) do it the way I described anyway.