• 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

methods (size(), get(), indexOf(). toArray()) of a list is observers?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a simple question is this methods of an arraylist is called an observer methods ?
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never heard of "observer methods". We call methods like that "accessors". Methods that modify an object (in the case of a List, a method like add()) are called "mutators".
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try reading about observers in this old thread. When I first saw the question, that is what I thought you meant.

I have copied Christophe Verré's code with additional indentation, otherwise unchanged:-It is conventional to write public before static but not compulsory.
 
Abdullah Attia
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very Grateful for help, Thank you Stephan van Hulst
Thank you Campbell Ritchie your answer maybe what i'm looking for

But
in this link : http://web.mit.edu/6.005/www/fa14/classes/08-abstract-data-types/

he says

Observers take objects of the abstract type and return objects of a different type. The size method of List, for example, returns an int.



also he says while talking about lists

observers: size, get



and the exercise i'm solving asking me to develop a data type with minimum 3 mutators and minimum 3 observers
So i think it means what i have found in the link above
i just want to make sure
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me it seems silly to make a distinction between "producers" and "observers". Like I said, we just call them "accessors". But yes, it seems your understanding is correct.

After your classes, I would recommend forgetting those meanings of the words, because in Java, "producers", "observers", etc... are usually used for certain design patterns.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would not say that is a standard use for the word observer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic