473,666 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collection type javascript library (equivalent to using Blocks) ...

I'm wondering how expensive and (in)efficient is to use Collection
type javascript library functions (similar to using Blocks), instead
of repeating the 'for' iterator over and over across a large
application.

I'm afraid that instantiating javascript Functions to act as Blocks in
these cases might require many more internal javascript resources
(time / memory) compared to using the 'for' statement - ?.

I would not want this to be the cause for my apps to eventually run
much slower (and consuming more memory).

For reference, define the following Collection type javascript
function:

function array_do (theArray, theBlock) {
for (var i=0; i<theArray.leng th; i++) {
var eachElement = theArray[i];
theBlock(eachEl ement);
}
}

.... and use it as follows:

array_do (testArray, function(each) { ... do something with
'each' ... } );

As you can see I would have to create a new javascript function each
time I need to execute the array_do function.

Thanks in advance.
Feb 7 '08 #1
1 1576
VK
On Feb 7, 6:54 pm, Lobo <carlosgali...@ gmail.comwrote:
I'm wondering how expensive and (in)efficient is to use Collection
type javascript library functions (similar to using Blocks), instead
of repeating the 'for' iterator over and over across a large
application.
Collections and blocks (as defined in your post) are from ol' good
linear programming. In OOP you are having a set of objects with
particular methods and properties and you are calling the necessary
method. If you don't need to keep particular data in each method for
each object instance then we define the method as static so no matter
how many object instance are created, they all will be using the same
scavenger (heap?)
In your case (if it is your case) that might be:

function MyObject {
// per-instance
// methods and properties
}

MyObject.protot ype.staticMetho d = function() {
// this.doSomethin g
}

and then could be

for (var i=0; i<myObjectsArra y.length; i++) {
myObjectsArray[i].staticMethod() ;
}

this way if cannot tell before runtime what kind of staticMethod you
may need and either it can be static or not: that would mean that your
OOP schema has a failure in it or not ready yet so it needs more
thinking over before implementing.

There is nothing criminal in using the old linear programming
approach, I just wanted to stress out that what you are doing is not
OOP.

<snip>
As you can see I would have to create a new javascript function each
time I need to execute the array_do function.
Not in OOP

Feb 9 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10296
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I get a servlet error "cannot find collection". Not usre if my issue is HTML, JSP, WebSphere or ??? Any help is very much appreciated. HTML file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
7
16873
by: Jon Davis | last post by:
I'm managing "collections" / "lists" (??) of objects that are internally bound by an XML document, but I do NOT intend to offer an IEnumerator interface. For instance, with a root XML document, I might have: <employees> <employee><name>bob</name></employee> <employee><name>carl</name></employee> <employees>
0
17775
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico Mariani, performance architect for the Microsoft® .NET runtime and longtime Microsoft developer, mentioned to Dr. GUI in an e-mail conversation recently that a fairly common practice (and one that's, unfortunately, described in some of our...
5
1686
by: Jeremy Ames | last post by:
I have run into a major road block with my page development projects. I am trying to add a literal control to my asp.net page and I got an error stating that the control could not be added because of code blocks (<% %>) on the page. Most of these blocks can be handled by adding a label control to the form so it is not that big of deal, but one of the things being posted is the page title. I am not sure how I can access that from the code...
6
13407
by: Scott M. Lyon | last post by:
As I mentioned in my other post, I'm attempting to, using COM Interop so I can update existing VB6 code to (for several specific functions) return a Hashtable from a .NET library. I've had very little luck processing the Hashtable itself in VB6 (I can add a reference to the project so it knows what a Hashtable is, but I'm not having much luck looping through all objects in the Hashtable), so I decided to try a different idea.
8
1825
by: JAL | last post by:
Here is my first attempt at a deterministic collection using Generics, apologies for C#. I will try to convert to C++/cli. using System; using System.Collections.Generic; using System.Text; namespace DeterminedGenericCollection { // I got tired of copy and pasting IDisposable
4
1752
by: Robert Schneider | last post by:
Hi, the msdn documentation provides an Dinosaurs example that uses the objectmodel.collection class. Just have a look on the help page for this class. I don't understand what happens here. Or I cannot find more detailed documentation for this behavior. What I mean is the invocation of the Dinosaurs.Add method which is derived from Collection(of String). The method seems to invoke the overridden InsertItem method. Can this method be...
142
6780
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory chunks and recycles them. This memory allocation strategy has been adapted to C (and C++) by the library written by Hans J Boehm and Alan J Demers. Why a Garbage Collector? -----------------------
6
1637
by: cppnow | last post by:
Hello. I have a strange conceptual problem I'm trying to think about. I would like to build a library that allows the user to do the following: 1) User defined types: The user defines their own types as needed for their particular application and registers them with the library. class ClassA {};
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.