• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MVC techniques

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I've noticed a possible issue in Java. With Model View Controller pattern the model keeps the data and it is displayed in the view. However, this seems to mean you may have the same data in two places in the application simultaneously thereby wasting memory. Usually it probably not a big deal but if there is a massive amount of data in JTable or JList it could cut performance . In C++ you can use pointers to help get around some of this issue but what do you do in Java? Does anyone know of any techniques to lessen this or am I just imagining a problem that's not there?

Thanks
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Model-View-Controller design pattern does not specify how it can be implemented, and it can be implemented in many, many different ways. In enterprise-level implementations, data is typically stored in a relational database. When data is in the Model component (in object form) during execution of business logic, it is only there temporarily, e.g. < 1 second.

When data is in the View component (in object form), it also is there for only a short time in the form of Presentation-tier data objects.

Placing massive amounts of data objects in View components may degrade performance and is a questionable design. Humans can only view a small amount of data at any point in time anyway.

Most enterprise-level MVC implementations are running on multiple machines with different memory spaces anyway.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Pantale wrote:However, this seems to mean you may have the same data in two places in the application simultaneously thereby wasting memory.


On the contrary. The two views share a reference to the same model, which is in memory only once.

In C++ you can use pointers to help get around some of this issue but what do you do in Java?


Java uses references. These act a bit like C/C++ pointers, in that they allow you to refer to the same objects from multiple places. Java variables are never objects themselves; they are references to the actual objects on the heap instead. Just like in C++, except without the dangers of pointer arithmetic.

Does anyone know of any techniques to lessen this or am I just imagining a problem that's not there?


You are indeed
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic