DEV Community

My Misconception when Learning Web Dev

Lohit Aryan on June 16, 2020

Misconception I got ready for starting my summer project which was a boilerplate for NodeJS apps. I had only finished a few courses an...
Collapse
 
djsullenbarger profile image
David Sullenbarger • Edited

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)

Collapse
 
ashleyjsheridan profile image
Ashley Sheridan

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.

Collapse
 
jfsoft profile image
Jonatan R. Fischer • Edited

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)

Collapse
 
ashleyjsheridan profile image
Ashley Sheridan

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?

Thread Thread
 
jfsoft profile image
Jonatan R. Fischer • Edited

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.

Thread Thread
 
ashleyjsheridan profile image
Ashley Sheridan

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

Thread Thread
 
jfsoft profile image
Jonatan R. Fischer

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.

Thread Thread
 
tanami profile image
Tanami

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

Collapse
 
lucyllewy profile image
Lucy Llewellyn • Edited

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...

Collapse
 
andreacanton profile image
Andrea Canton

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!

Collapse
 
asiros profile image
Chonbashev Artyk

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.

Collapse
 
c_v_ya profile image
Constantine

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.

Collapse
 
reinhart1010 profile image
Reinhart Previano K.

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.

Collapse
 
c_v_ya profile image
Constantine

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!

Collapse
 
arquezaryan profile image
ryyyy

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

Collapse
 
mosesmbadi profile image
mosesmbadi

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)

Collapse
 
djsullenbarger profile image
David Sullenbarger • Edited

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').

Thread Thread
 
mosesmbadi profile image
mosesmbadi

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.

Thread Thread
 
mosesmbadi profile image
mosesmbadi

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.

Thread Thread
 
djsullenbarger profile image
David Sullenbarger

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.

Collapse
 
mosesmbadi profile image
mosesmbadi

Shoot!Sorry bud I don't know how i missed this.Check out Django girls they are pretty amazing.