ArticleslgStudy

computer science

Code on demand

Code on demand is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Code on demand rather than just read about it. In short: In distributed computing, code on demand is any technology that sends executable software code from a server computer to a client computer upon request from the client's software. Some well-known examples of the code on demand paradigm on the web are Java applets, Adobe's ActionScript language for the Flash Player, and JavaScript.

Key takeaways

  • Code on demand belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Code on demand to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Code on demand from memory before moving on to harder problems.

Reference excerpt

In distributed computing, code on demand is any technology that sends executable software code from a server computer to a client computer upon request from the client's software. Some well-known examples of the code on demand paradigm on the web are Java applets, Adobe's ActionScript language for the Flash Player, and JavaScript. The program code lies inactive on a web server until a user (client) requests a web page that contains a link to the code using the client's web browser. Upon this request, the web page and the program are transported to the user's machine using HTTP. When the page is displayed, the code is started in the browser and executes locally, inside the user's computer until it is stopped (e.g., by the user leaving the web page). Code on demand is a specific use of mobile code, within the field of code mobility.

Constraints

Client-server The first constraint is that the system must be made up of clients and servers. Servers have resources that clients want to use. For example, a server has a list of stock prices (i.e. a resource) and the client would like to display these prices in some nice graphs. There is a clear separation of concerns between the two. The server takes care of the back-end stuff (data storage, business rules, etc.) and the client handles the front-end stuff (user interfaces).

Stateless To further simplify interactions between clients and servers, the second constraint is that the communication between them must be stateless. This means that all information about the client's session is kept on the client, and the server is completely unaware. The consequence is that each request must contain all information necessary to perform the request (i.e. it cannot rely on any context information).

Cache The last constraint on the client-server communication is that responses from servers must be marked as cacheable or non-cacheable. An effective cache can reduce the number of client-server interactions, which contributes positively to the performance of the system. At least, from a user's point of view.

Code on demand Code on demand (COD) is the only optional constraint in REST. It allows clients to improve their flexibility because it is the server which decides how certain things will be done. For instance, with code on demand, a client can download a Javascript, Java applet or even a Flash application in order to encrypt communication so servers are not aware of any encryption routines / keys used in this process. However, using COD reduces visibility, hence the optionality. Also, not every API needs this kind of flexibility.

See also Remote evaluation Code mobility

References

Worked examples

Example 1 — a first encounter with Code on demand

Start with the simplest possible case. Write down what Code on demand claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Code on demand before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Code on demand ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Code on demand

In research
Code on demand appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Code on demand in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Code on demand is common in secondary-school and first-year university syllabi. It links to neighbouring topics Internet Protocol based network software, Software distribution, so understanding it makes those chapters shorter.
In everyday life
Look for Code on demand outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Code on demand” →

How to study Code on demand in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Code on demand means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Code on demand out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Code on demand in simple terms?

In distributed computing, code on demand is any technology that sends executable software code from a server computer to a client computer upon request from the client's software. Some well-known examples of the code on demand paradigm on the web are Java applets, Adobe's ActionScript language for…

Why does Code on demand matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Code on demand?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Code on demand.

Tags

  • Internet Protocol based network software
  • Software distribution

Keep exploring