objects

How to find keys of a hash?

I know in javascript Objects double as hashes but i have been unable to find a built in function to get the keys var h = {a:'b',c:'d'}; I want something like var k = h.keys() ; // k = ['a','c']; It is simple to write a function myself to iterate over the items and add the keys to an array that I return, but is there a standard cl...

Build a Basic Python Iterator

How would one create an iterative function (or iterator object) in python? ...

Web framework programming mindset

I am just starting to play with Django/Python and am trying to shift into the MTV mode of programming that Django asks for (insists on). Deciding on what functions should be methods of a model vs simple being a function in a view has so far been confusing. Does anyone know of a book, website, blog, slideshow, whatever that discusses We...

How can I simply inherit methods from an existing instance?

Hi, below I have a very simple example of what I'm trying to do. I want to be able to use HTMLDecorator with any other class. Ignore the fact it's called decorator, it's just a name. import cgi class ClassX(object): pass # ... with own __repr__ class ClassY(object): pass # ... with own __repr__ inst_x=ClassX() inst_y=ClassY() ...

Arbitrary Naming Convention Question About Business Objects

Ok, do you do Business.Name or Business.BusinessName SubCategory.ID or SubCategory.SubCategoryID What about in your database? Why? I'm torn with both. Would love there to be a "right answer" ...

Patterns for the overlap of two objects

I'm sure this has already been asked and answered so I apologize in advance for that but I'm not figuring out the correct keywords to search for. Searching for "Pattern" hits way too many Q & A's to be useful. I'm working on a regression testing app. I'm displaying a form on the screen and according to which user is logged in to the a...

Test an object for NOT being a type

I know how to test an object to see if it is of a type, using the IS keyword e.g. if (foo is bar) { //do something here } but how do you test for it not being "bar"?, I can't seem to find a keyword that works with IS to test for a negative result. BTW - I have a horrible feeling this is soooo obvious, so apologies in advance... ...

Creating objects driven by the database to populate a Treeview - very slow

I have an application that reads a table from a database. I issue an SQL query to get a result set, based on a unique string value I glean from the results, I use a case/switch statement to generate certain objects (they inherit TreeNode BTW). These created objects get shunted into a Dictionary object to be used later. Whilst generat...

Object initialization in C# (.Net)

Is there a difference (performance, overhead) between these two ways of initializing an object: MyTypedDataSet aDataSet = new MyTypedDataSet(); aDataSet .Merge(anotherDataSet); aDataSet .Merge(yetAnotherDataSet); and MyTypedDataSet aDataSet = anotherDataSet; aDataSet .Merge(yetAnotherDataSet); Which do you recommend? ...

Python dictionary from an object's fields

Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this: >>> class Foo: ... bar = 'hello' ... baz = 'world' ... >>> f = Foo() >>> props(f) { 'bar' : 'hello', 'baz' : 'world' } NOTE: It should not include methods. Only fields. Thanks ...

How to check if a variable is an object in Javascript?

I would like to see if a certain object has been loaded, if not, i want to load it like this: if (!isObjectLoaded(someVar)) { someVar= loadObject(); } ...

How do you declare an object of a class before the class is created in C++?

Is there anyway to declare an object of a class before the class is created in C++? I ask because I am trying to use two classes, the first needs to have an instance of the second class within it, but the second class also contains an instance of the first class. I realize that you may think I might get into an infinite loop, but I act...

Finding Cell Range With Excel Macros

I have an many embedded objects (shapes) in a worksheet and the icons is displayed inside a cell. How do I know the Cell range in which the shape object is displayed. for eg : When I select a Cell B2 and then select the object(shape) in the cell B17, and I query on the Cell.Address it shows B2. How will I get the cell address as B17. ...

What is the most efficient way to clone a JavaScript object?

What is the most efficient way to clone a JavaScript object? I've seen: obj = eval(uneval(o)); but that's not cross platform (FF only). I've done (in Mootools 1.2) things like this: obj = JSON.decode(JSON.encode(o)); but question the efficiency. I've also seen recursive copying function, etc. I'm pretty surprised that out-of-the-bo...

Mysql results in PHP - arrays or objects?

Been using PHP/MySQL for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using mysql_fetch_object() vs mysql_fetch_assoc() / mysql_fetch_array(). ...

PHP: Storing 'objects' inside the $_SESSION.

I just figured out that I can actually store objects in the $_SESSION and I find it quite cool because when I jump to another page I still have my object. Now before I start using this approach I would like to find out if it is really such a good idea or if there are potential pitfalls involved. I know that if I had a single point of e...

How do you implement audit trail for your objects (Programming) ?

I need to implement an audit trail for Add/Edit/Delete on my objects,I'm using an ORM (XPO) for defining my objects etc. I implemented an audit trail object that is triggered on OnSaving OnDeleting Of the base object, and I store the changes in Audit-AuditTrail (Mast-Det) table, for field changes. etc. using some method services ca...

What is a component

I listen to the podcast java posse, on this there is often discussion about components (note components are not (clearly) objects). They lament the fact that Java does not have components, and contrast with .NET that does. Components apparently makes developing applications (not just GUI apps) easier. I can figure from the discussion...

What can it mean if an object is scriptable?

Exactly what the title says. Note, this is not about "subscriptable" objects. ...

How to detect the current sharepoint pages from the client machine?

On the client machine I need to be able to somehow detect which sites the current user are looking at right now. I know the base URL of the sharepoint app, say sharepoint.thecompany.net but how the hack do I get the last requested url from the server? I have hit a dead stop when trying to iterate the current processes and the casting the...