Question: Because I am creating DOM using Jquery it was difficult to copy the output so i am adding one image of code that i have captured using one tool

![enter image description here](https://i.stack.imgur.com/TKZnp.png)

i have attached hover and mouseout event to `id='nf1'` using this code

```
$("#nf"+n).hover(function(){
    $("#nf"+$(this).attr("post_id")+"post_delete").show();
});
$("#nf"+n).mouseout(function(){
    $("#nf"+$(this).attr("post_id")+"post_delete").hide();
});

```

Here n is post\_id and i am looping all post\_id got from response.This attach events but not giving expected behaviour Like when mouse over to `id='nf1post_delete'` it is hide 

Please ask if any doubts

Answer: 
Your #1 and #2 don't really make sense: 

1. If you define a different list in every method that uses it, then you're using a different list each time. This is not sharing the list; this *doesn't* work. If you mean "call your method that creates the list from each method that uses it" then the same still applies: you're using a different list each time.
2. You don't need to use `ref ListObjects` to update a private member; a private member is just accessed by its name. This isn't bad practice; this is standard object-oriented practice.
3. Passing all required data *into* a method as parameters makes the method inherently more reusable as it reduces coupling to the class the method belongs to.

In short: #3 is good practice to an extent, as it increases the reusability of code. However, the use of #2 is fundamentally the reason we have Object-Oriented programming: to *save* you from repeatedly passing parameters into all your methods. This is exactly what private fields are designed for!
Usually a `List<T>` shouldn't belong to the state of an instance and exposed since it's mutable and you may change the state from the outside otherwise -unless your getter is designed to return a readonly list. Unless your design clearly allow such a possibility when it may occur. My reply doesn't really answer to your question is just a suggestion of good object oriented design. As someone already suggested much better than me you may pass a List back and forth each method and directly modify it.