Tag Info

Hot answers tagged

10

XML : XSLT :: JSON : x. What is x ? The most facile answer would be x = JavaScript. Though you could make a case for this, it feels unsatisfying. Even though XSLT is technically Turing complete, there is a poor correspondence between the declarative style of XSLT and the more imperative or functional styles seen in JavaScript. There are a few standalone ...


9

As @MainMa has well pointed out, the technical problem might can be solved with a certain effort, but not easily without the risk of introducing some hidden bugs into your codebase (and the risk is high if the codebase is large, and you would probably not have asked such a question for a small codebase). See this in contrast with the fact that this coding ...


7

It revolves around the principle of Unobtrusive JavaScript. The modern approach dictates that there should be a separation of functionality from presentation. I hate to cite Wikipedia, but give Wikipedia's article on Unobtrusive JavaScript a read. On a personal note there are three things about Unobtrusive JavaScript I quite like: Separation of ...


7

JavaScript is a multiparadigm language that you can approach from a pure OOP point of view, but most people don't, for various reasons I'll describe in a bit. In my experience, idiomatic JavaScript tends to be around 50% functional, 30% OOP, and 20% procedural. However, that mix varies a lot depending on what you're doing and who you work with. Some ...


5

You are thinking like a programmer. Instead, try to think like a Human Resources Director. Senior Developer to Human Resources Director: We need to hire a web developer. HRD: Okay, what skills do they need to have? SRD: Well, PHP, Javascript, MVC frameworks, git... HRD: Anything else? SRD: Well, experience with AJAX would be a plus... ...


4

This reminds me of a recent question on http://cs.stackexchange.com/questions/35385/for-small-values-of-n-on-can-be-treated-as-if-its-o1. And the answer is really the same -- yes, for small values. What is small and will you be dealing with small? That sorta floats, based upon experience and your domain. But you go to experts for their expertise, absence ...


4

In order to attach your own license to code, you must own the copyright. Generally speaking, that means that it must be code that you have written. As an example, there are libraries out there already that provide some capability I want in my program. I have two choices: I can either live with the license that the library provides, or I can write my own ...


4

Your code needs to be released under the GPLv3 as you believe it is a derivative work of the algs4.jar implementation. Other projects utilizing your code will likely need to be released as GPLv3. Most larger applications just incorporate code from smaller projects, and treat the smaller code base as part of the larger. That will trigger the "viral" aspect ...


4

I would imagine that he was asking whether you're able to separate an application into components. The opposite would be a monolithic JavaScript app—frequent case in JavaScript world (with a small script growing over time). The answer then could: Explain the benefits of components (better architecture, ability to reason in terms of interfaces, ability to ...


3

What you need to understand is that the C++ standard library quite possibly has the worst implementation of futures conceivable by man. What C++ does is little more than a weak wrapper around a semaphore. Most future implementations encourage use of callback lambdas extensively, to chain several futures together asynchronously using then, and allow you to ...


2

Both solutions can make sense. Using functions as parameters is useful in many cases, and this generally makes it easier to write correct code because you're forced to provide callbacks for all circumstances. However, an API that requires callbacks tend to create unnecessarily deep indentation. This becomes more obvious when we have more than one validation, ...


2

In the context of an SGML language where DOM is typically used (i.e. HTML, XML), a node is the smallest piece of text that has semantic meaning. Nodes are arranged in a tree structure, with the document as the root node. Each node can have zero or more children. There are several types of nodes: Document: this is the root node of the whole document. It ...


2

While it would result is much more code, there's nothing inherently wrong with adding "nextLeft, nextDown, etc." to your keys. You'll be able to 100% ensure which key is next when navigating, so all of the guess work is gone. If you insist on a solution that uses solving, give each key an x offset and width, then when down is pressed, move to the key whose ...


2

Etymologically, a "node" is a "knot": think of a fisherman's net as "holes tied together with string", and then nodes are where the string is knotted. The term comes from graph theory in mathematics. If you think of a graph as a collection of points connected to each other by lines ("arcs"), then the points are called nodes. A tree is a special case of a ...


2

Given your example, specifically the part where single quotes are not replaced, I don't think any off-the-shelf solution will do the job for you. I imagine that writing a custom tool which uses a JavaScript tokenizer would be too complicated as well. On the other hand, you may replace automatically single quotes by double quotes. With regular expressions, ...


2

You can also deliver the app from a website. Either just use the files on the website like a typical web app or you can create a manifest file and the browser will cache the files to the local system and will automatically check if the files need to be refreshed. http://www.codeproject.com/Articles/467724/HTML-Offline-Capabilities-Using-the-Cache-Manifes


2

What they probably meant is that manipulating the DOM is slow and that you can avoid injecting HTML through jQuery. What you can do, instead, is to have A/B variants both in your original HTML. Then, you hide the B variant by default, and switch from A to B by simply hiding the one and showing the other. An even better alternative is to have two HTML ...


1

I'd recommended a great book JavaScript: The Good Parts by Douglas Crockford as a good guide. JavaScript AFAIK does not have (in practice) a single approach to object-orientation. Also as mentioned in previous answers it is probably more useful to learn functional paradigm mindset, unless you are going to design large frameworks like OpenLayers, jQuery or ...


1

Javascript is more different from Java than a surface comparison might suggest. An object-oriented approach can get you a long way, but it is not in itself sufficient to become a good javascript programmer, because a few of the critical patterns of javascript are not really object-oriented in nature. You will find that judicious use of closures is as ...


1

I've done some similar things (migrating a VB3 app to VB4, for example) with some perl scripts. The scripts would take the original file and produce two new files: one the output file (with the corrections) and the other a list of the changes/substitutions performed, as well as messages indicating that something unusual was seen and wasn't changed. I found ...


1

While Jonathan largely talks about the nature of XSLT as a language in his answer, I think there's another angle to consider. The purpose of XSLT was to transform XML documents into some other document (XML, HTML, SGML, PDF, etc). In this way, XSLT is frequently used, effectively, as a template language. There is a vast array of template libraries out ...


1

You can safely compare it to a map of a subway system, e.g. the London Underground: (http://it.wikipedia.org/wiki/Mappa_della_metropolitana_di_Londra) A node is a stop, an edge is the connection between stations. That's about it with general graphs. However, there are special graphs with more, interesting properties, like Trees: ...


1

I am a fan of using data attributes: HTML: <div class="ajax-widget" data-endpoint="/api/some-endpoint"> ... </div> JS: // Or whatever your initialisation logic is. $('.ajax-widget').each(function() { // Grab the endpoint and use it for something. // e.g. AJAX call, assigning to a property for later etc. var endpoint = ...


1

What you want to do is start with a config object: myApp.config = { myUrls: { someUrl: "http://default.com"; }, someSharedPropAcrossAllEnvs: 'something' }; And then create environment specific versions that override the appropriate values: var envs = {}; var envs.dev = { myUrls: { someUrl: "http://localhost:8080"; } }; var envs.test = ...


1

For single-page apps, the advantages are pretty clear ... having explicit, structured dependency declarations and using an async script loader seems like the way to go. Those aren't the only advantages, though. AMD-style modules don't just remove the need for namespaces, they provide other benefits, like eliminating hard-coded dependencies and ...


1

The first part is pretty common, it's just a way to get the constructor of the subtype to share the functionality of the supertype's constructor. Notice that Person.call doesn't invoke Person as a constructor here, it invokes it as a regular function using the this binding from the Student being constructed. It's probably a bit more common to see it ...


1

One technique (using Event-Based Systems with a Mediator): I take advantage of the Mediator Pattern quite a bit -- one way to control event-flow is to instantiate different Mediator objects per-module, and pass only a specific Mediator to each module (as a, or in a sandbox) -- this will allow each module to only communicate through that specific medium, ...



Only top voted, non community-wiki answers of a minimum length are eligible