objects

Send serialised object via socket

Whats the best way to format a message to a server, at moment I'm serilising an object using the binaryformatter and then sending it to the server. At the server end its listening in an async fashion and then when the buffer size recieved is not 100% it assumes that the transfer has complete. This is working and the moment, and I can d...

mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_object

The functions are all very similar: mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_object() I have recently started using mysql_fetch_object as I am doing alot more OOP with PHP. But what are peoples opinions on which one is best to use and why, and maybe which scenario they are best to be used in. Thanks for your thoughts! ...

How to pass Client Objects to WCF Service

Hello there, I want to pass list of entitiy objects from Client to WCF Service, but my WCF Service has no knowledge of the structure of these entity objects. One way could be to pass them in an XML file. What could be the other possible ways to pass such objects to WCF service? Please guide. Thank you! ...

Issue with JavaScript object constructor where arguments are other objects

I'm writing some JavaScript with three classes, one for Roofs, one for Garages, and one for Houses. The house class takes two arguments to its constructor, a Roof and a Garage. When I run this code I get: can not construct object [Break on this error] throw new Error('can not construct object');\n in Firebug even though the objects are...

Objects in Java Reference or Value

Hi, just for my understanding. Does my example code below actually changes the the color of my Car Object in the IntHashtable or does the first line creates another instance of the car object, which contains color = red after the second line? thanks, Henrik Car myCar = (Car)myIntHashTable.get(index); myCar.setColor = red; Edit: Is...

changed object after storage or object-state used

Example: class UserStorage { public function addUser(User $user) { //saves to db } } class User { public function setName($name); } What if I add a user to the user storage and later change that user object? In this case you might argue that user objects only should be stored on __destruct. But sometimes this isn't an option ...

Easy way to concatenate list of strings into a comma-separated strings, where strings are members of an object?

Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members. Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function? Thanks! ...

C#: simple vs complex objects and memory usage

When dealing with large collections, which of the following approaches is better? Class SimpleObject with only fields/properties and class SimpleObjectController that contains all the method implementations required by SimpleObject. At runtime, I build a collection of SimpleObjects, instantiate one SimpleObjectController and call it's m...

iphone multiple NSTimer troubles

Hi, I'm still new to programming so excuse me if this is silly. I'm programming a simple game and require multiple timers to send different messages at different intervals, so when creating the game, the following is called: [self gameTimerValidate]; [self scoreTimerValidate]; - (void) gameTimerValidate { gameTimer = [NSTimer scheduled...

Array of objects on stack and heap

Consider the following code: class myarray { int i; public: myarray(int a) : i(a){ } } How can you create an array of objects of myarray on stack and how can you create an array of objects on heap??? ...

Is there a way to turn off auto-conversion of objects to strings in php 5.2?

I'm using a compiler that has a slightly older version of PHP than my dev machine (5.1.3 vs. 5.2.6 IIRC). That version doesn't do the auto-conversion, which can result in some sneaky bugs in the compiled version. I'd rather not downgrade my dev box, but if I can somehow turn that off, that might be helpful in finding those earlier. ...

In Drools Rules, how to use two different ArrayList objects,obj1 is used in rule 1 and obj2 used in rule2?

I am doing ksession.insert(list) and after that I have to fire rule 1 in the drl file, then ksession.insert(list) and fire rule 2 in the drl. Could someone tell me how to achieve this. I read about agenda filters and facthandles but do not really know how to get this to work Below is some code: ArrayList list = new ArrayList(); list....

Reference or tutorial to clarify object reference confusion

Working with my ongoing TFrames-based component set project, I'm coming across various instances where I am wanting to replace one of the TFrame's components (usually non-visual) at runtime with one that is generated dynamically at runtime. I think I've probably found the answer to my immediate problem here, but in my own digging arou...

Declaring an object at class level, problems. iPhone Objective-C

Objective C on iPhone: I am attempting to declare the following object at class level so that i do not have to re-connect this socket every time I write something to it. (Writing things multiple times a second) whenever i am writing a steady stream of live data, about every 2 seconds it freezes. I don't know why, but it does. Code: Soc...

Assigning variables to objects in JavaScript

Hey there, I am using the following method to basically create a JSON string. var saveData = {}; saveData.a = 2; saveData.c = 1; However the .a and .c don't cut it for what I need to do, I need to replace these with strings. So something like.. var name = 'wibble'; saveData.name = 2; This would get accessed with saveData.wibble ...

Maintain reference to any object type in C++?

I'm trying to teach myself C++, and one of the traditional "new language" exercises I've always used is to implement some data structure, like a binary tree or a linked list. In Java, this was relatively simple: I could define some class Node that maintained an instance variable Object data, so that someone could store any kind of object...

addEventListener only works on last object.

In the following code, it seems I only get the 'otherboxclick' call for the last box added (b1). If I change the order the boxes are added, it's always just the last one that works. How can I get it to work for all the boxes? <html> <head> </head> <body> <script type="text/javascript"> function otherboxclick(e){ alert("other...

Converting Objects to XML representations in C#

I have a dynamic linked library written in C# 3.0. This library has a small set of public classes that I want to make XML representations for. The idea is to allow "saving/loading" of objects from disc using XML as the representation. I would also like to allow users of the class library to pass these XML representations to certain funct...

JavaScript objects

What are the differences between these two codes in JavaScript? var obj = new Object(); obj.X = 10; obj.Y = 20; And, var obj = {X:10, Y:20}; ...

OO PHP protected properties not available in foreach loop?

Hi, I have a validation class which I would like to use to check all values in my application are within allowed constraints. I am passing an object to a static function within the validation class, from another class (in this case User) function validate() { $errors = Validation::validate($this); } In the validation class, I cre...