1 Replies - 446 Views - Last Post: 27 June 2017 - 07:53 AM

#1 AdrianSz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-June 17

Should we apply clean code principles in JavaScript? or TDD?

Posted 27 June 2017 - 01:41 AM

Many times I have discussions with others developers about TDD and clean code. I was php programmer and now Javascript.

A couple of days I got this answer (is not exact and it was not in English): "Many things in Javascript are asynchronous and rely on events and callbacks. There are a lot of anonymous function" (I believe this is wrong.)

"We should not defined them in global (module) space just to test them."

This is more a doctrinal question. So what should we do with clean code and TDD in Javascript?

Is This A Good Question/Topic? 0
  • +

Replies To: Should we apply clean code principles in JavaScript? or TDD?

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5894
  • View blog
  • Posts: 20,114
  • Joined: 05-May 12

Re: Should we apply clean code principles in JavaScript? or TDD?

Posted 27 June 2017 - 07:53 AM

C# doesn't have any globals, and I use lamdas/anonymous functions. I have event driven code. I do TDD everyday without issues. The problem is that Javascript folks tend to write their code to be tightly integrated into the UI or UI events. It's the current accepted style of writing Javascript with jQuery code.

If you write Javascript and jQuery MVVM style, then you can do TDD once more. The downside is that contemporary Javascript/jQuery coders will look at your MVVM style Javascript and say "Yuck! That's ugly/complex/something I'm not used."
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1