• Post Reply Bookmark Topic Watch Topic
  • New Topic

Method overriding  RSS feed

 
Chandhrasekar Saravanan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would first explain, what I have done. I have a class called SessionCollectionDemo which holds the Main() method.

There are two classes SessionCollection and Session. I am creating instances of session and I am adding session objects. I wanted to change the values of session object using a method.

I am using updateSession method() in session collection. it is where I am getting problem. I need to update various variables so what is the best way to do i
t. I like to have the updateMethod() in SessionCollection class and I should be able to change all the variables of session like constructors.
(just to keep the code neat)

for testing I also created an UpdateSession class, but I am not satisfied with it.

basically what I want is a better way of doing updateSession() method in SessionCollection class.

 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you're abstracting a bit too far by having a seperate UpdateSession class. I would look at it this way:

Your Session class should control the functionality to update a Session, right? Think about it, if a Session needs to make some changes to itself, who should ultimately be responsible to ensure how the changes are performed? The Session class. you should not abstract this functionality to some external class like UpdateSession -- it doesn't make sense to take that control away from the Session class.

Now, you have a Session class, and a SessionCollectionClass (which is responsible for managing multiple Sessions). Your SessionCollectionClass might have its own updateSession method, which might take a track id as a parameter, for instance, search the collection to find the appropriate Session, and then once that Session object is retrieved, you can use that Session object to call the update method and update itself.

Hope it makes sense.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!