开发者

What is "Enterprise JavaScript"?

For web applications I've developed I tend to build up a library of functions, and for some sites I end up encapsulating them all into a single object, so say FooBar and then all the things I end up doing are within that object. My understanding is that this is part-of-the-way to "Enterprise JavaScript" - encapsulating the functionality in ways that are logical, avoid polluting the JavaScript with lots of global variables.

How do I distinguish good coding practice from what's considered "Enterprise JavaScript"?

A simpler way to as开发者_如何学运维k this might be in terms of scale -- as a web application or site grows it will include more JavaScript and organizing it gets harder, and there are patterns for doing this well and they're Enterprise? What are resources for learning about approaches to handling large libraries of functionality.

Or are people just making it up, as in this joke site?


UPDATE: I am not kidding, really, though I wonder if what I'm seeking is more along the lines of Pro JavaScript Design Patterns. Perhaps "Enterprise" encompasses some of this?


Enterprise JavaScript Is: Ensuring lines are terminated with multiple semicolons so the JavaSript parser Really Knows when a line is ending.

var helloWorld = function (message) {
    if (!message) {
        message = "Hello World";;;;;;
    }

    alert(message);;;;;;;;;;;;;;;;;;;

};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(By bentruyman)


I love the term enterprise javascript and enterprise coding. I doubt that it's a well defined term but it has a strong appeal.

As I have come to understand it; Enterprises deal with a lot of developers working on different aspects of projects. So there is a lot of communication required to make things work. Enterprise coding is a term to describe the techniques used to aid the communication of developers and modules in code but have gone wrong.

As the site shows, it's easy to over do it!

So enterprise coding results in harder to understand code that seems more robust than it needs. Quite ironic as enterprise coding is intended to ease production.

Examples of enterprise code could easily be found in

  • Generated websites using robust CMS.
  • Large library APIs (especially proprietary as the source can not be adjusted)
  • Cross browser/platform projects. With a lot of dynamic corrections.
  • Old projects that have been maintained by many people.

Writing clean good code is something that will be debated forever. As there is no perfect approach to all problems.

In a way enterprise coding is coining good practice techniques that have gone bad.

An antonym to enterprise coding might be Cowboy Coding


Indeed, there seem to be patterns and best practices when using JavaScript. For example, there is the site "Enterprise jQuery" that deals with these patterns in jQuery.

Also, there are common patterns (eg the module pattern) to encapsulate private information. Don't know if you should call them "Enterpise" though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜