Question about objects

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 782 Views - Last Post: 31 December 2012 - 09:58 PM Rate Topic: -----

#1 novakasss  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 352
  • Joined: 11-July 12

Question about objects

Posted 30 December 2012 - 02:30 PM

I want to ask, for example I have a server and client classes. I have a GUI components in that client class. If I would send to the server whole client object, and then server would modify smth, it will effect original object? Do I need to send it back to the client after modification? Or it will be so called 'alias', when two references refer to the same object, and changes in one object effect another?
Is This A Good Question/Topic? 0
  • +

Replies To: Question about objects

#2 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1391
  • View blog
  • Posts: 3,078
  • Joined: 05-April 11

Re: Question about objects

Posted 30 December 2012 - 03:04 PM

You will have to send the object back after you've modified it yes ^^
Was This Post Helpful? 1
  • +
  • -

#3 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: Question about objects

Posted 30 December 2012 - 06:28 PM

If the client and server are running in the same JVM, you can just send a pointer to the object, otherwise, you need serialize the object and exchange it back and forth.

This post has been edited by blackcompe: 30 December 2012 - 06:39 PM

Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7648
  • View blog
  • Posts: 12,902
  • Joined: 19-March 11

Re: Question about objects

Posted 30 December 2012 - 09:03 PM

Think about how aliasing happens: two pointers refer to the same location in memory.

Can this happen across a remote connection?
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Question about objects

Posted 31 December 2012 - 07:48 AM

No, not the same JVM.
But I wonder how blackcompe would exchange the Object pointer between the Client and the Server even if they run on the same JVM ?
Was This Post Helpful? 0
  • +
  • -

#6 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: Question about objects

Posted 31 December 2012 - 12:58 PM

Quote

No, not the same JVM.
But I wonder how blackcompe would exchange the Object pointer between the Client and the Server even if they run on the same JVM ?


Huh? Client and Server classes running in the same JVM instance, sharing the same memory, can't pass references?
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Question about objects

Posted 31 December 2012 - 04:27 PM

How ???
Would like to see a code snippet about that
A few lines will do blackcompe
Was This Post Helpful? 0
  • +
  • -

#8 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: Question about objects

Posted 31 December 2012 - 05:38 PM

Quote

How ???
Would like to see a code snippet about that
A few lines will do blackcompe


I don't you understand what I said. Note that I never implied anything about sockets being used.

Spoiler

This post has been edited by blackcompe: 31 December 2012 - 07:13 PM

Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Question about objects

Posted 31 December 2012 - 07:03 PM

I don't buy that
Completly false assesment -1 all the way :)
Was This Post Helpful? 0
  • +
  • -

#10 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: Question about objects

Posted 31 December 2012 - 07:04 PM

Quote

I don't buy that
Completly false assesment -1 all the way


What are you talking about? Nonsense pbl. Complete nonsense!?!?! :hammer:
Was This Post Helpful? 1
  • +
  • -

#11 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Question about objects

Posted 31 December 2012 - 07:08 PM

What you claim is
Show me an example of a Client and a Server using the same JVM and I'll +1 you for the rest of my life
Was This Post Helpful? 0
  • +
  • -

#12 extremeblueness  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 186
  • Joined: 22-October 12

Re: Question about objects

Posted 31 December 2012 - 07:10 PM

View Postblackcompe, on 01 January 2013 - 12:38 AM, said:

Quote

How ???
Would like to see a code snippet about that
A few lines will do blackcompe


I don't you understand what I said. This is what I said. Note that I never implied anything about sockets being used.



Where on earth do you get sockets from? He's asking for a code snippet- a small piece of your code. I think it seems perfectly reasonable.
Was This Post Helpful? 0
  • +
  • -

#13 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: Question about objects

Posted 31 December 2012 - 07:12 PM

Quote

What you claim is
Show me an example of a Client and a Server using the same JVM and I'll +1 you for the rest of my life


But you're mistaken in thinking a client/server architecture can only be applied to networking. It's a general concept. Yes, the OP may have been talking that networking, but he didn't explicitly say it and neither did I. I'm really saying you can pass a message to any object, where the object can modify it without having to pass it back. Interpret it how you want...

This post has been edited by blackcompe: 31 December 2012 - 07:12 PM

Was This Post Helpful? 1
  • +
  • -

#14 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Question about objects

Posted 31 December 2012 - 07:17 PM

You are completly eluding the question
You claimed that a Client/Server architecture can have Client and a Server running inside the same JVM into which a Client (or a Server) sends to the other one a pointer to an object that the other one can modify... so it will be modified in both application

I asked you to show me an example using a few (preferably) lines of code. You failed on providing this example
Was This Post Helpful? 0
  • +
  • -

#15 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7648
  • View blog
  • Posts: 12,902
  • Joined: 19-March 11

Re: Question about objects

Posted 31 December 2012 - 07:18 PM

I'm with blackcompe on this one. I don't really see a lot of use cases for it, but there's nothing odd about passing references when you're on the same machine.

But in fact, if we need a use case, here's one: at my office, the linux team is replacing desktop linux machines with virtual machines on a server. It's not too hard to imagine a slightly different configuration, in which we return to the original multiuser arrangement that Unix was designed for. In that case, it would be perfectly reasonable to write a chat client for communication on the local machine, and to pass client objects around on that machine. This would work more or less as blackcompe described, and it would be a good design for that purpose.


EDIT: came in a little late, but here's your example, pbl. I think I get +1 forever, no? :)

This post has been edited by jon.kiparsky: 31 December 2012 - 07:20 PM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2