You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Swapnil Patil <sw...@gmail.com> on 2015/06/01 17:03:26 UTC

What is a better way to instantiate/set a new field

Hi Devs,

I am adding a new field
in org.apache.stratos.messaging.domain.topology.Member class, called
instanceId.

For this, what would be a better approach

1. Modifying the existing constructor
2. Adding a new constructor which takes this as an additional argument
3. Just have a setter method.

In case of 2 and 3, the member may not be initialized properly.

I am confused about which to use because I am unaware of the scope of this
Member class. If this is widely used then option 1 would mean changes at a
lot of places.

If I know what is the scope of this Member class, it would help me
determine which approach to follow. Is there any way to find out in what
all places a class's object is used apart from searching it manually
through the codebase?

I would appreciate any help in deciding the approach.

Thanks and Regards,
Swapnil

Re: What is a better way to instantiate/set a new field

Posted by Swapnil Patil <sw...@gmail.com>.
Hi Isuru,

Thank you for the clarification . I will do the same.

Regards,
Swapnil

On Tue, Jun 2, 2015 at 2:14 PM, Isuru Haththotuwa <is...@apache.org> wrote:

>
>
> On Tue, Jun 2, 2015 at 12:57 PM, Swapnil Patil <sw...@gmail.com>
> wrote:
>
>> Hi Isuru,
>>
>> Thanks for suggesstions.
>>
>>
>>> Member class is used in the Topology hierarchy, to represent each member
>>> of a cluster. For me, the easiest way to find where it has been referenced
>>> is using the IDE that you are using. For an example, in IntelliJ Idea, you
>>> can right click on the Member class's constructor -> click on find usages.
>>> I'm sure you know this already.
>>>
>>
>> Yes, I am aware of it. Currently I am using Eclipse. The thing is, I am
>> new to Maven projects. I have imported all the projects in the workspace.
>> But I am not able to find references to this class. I am getting the error
>> "The resource is not on the build path of a Java project". To fix this I
>> need to configure the build path. But unfortunately, the option to
>> configure build path is disabled. Now I am not sure why is this so. This
>> option to configure build path is enabled for a few projects (which I
>> assume Eclipse treat them as Java project) but for others (many of them) it
>> is disabled (I assume Eclipse doesn't treat them as Java projects).
>>
>> I am not sure about this behaviour. Is this because I have imported Maven
>> projects? Is there anything else I need to do? like creating Eclipse
>> projects manually with command 'maven eclipse:eclipse'?
>>
> Yes, mvn eclipse:eclipse should create the eclipse project for you. Then,
> open the project from the Eclipse IDE. It should work.
>
>>
>>
>>
>>> IMO If this instance id is an optional field, its fine to use a setter.
>>> If its a mandatory field for all Member objects, the it should be
>>> initialized in the same constructor that is there currently.
>>>
>>
>> Okay. Thanks. I think this new field should be optional.
>>
>> Thanks and Regards,
>> Swapnil
>>
>> On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
>>> wrote:
>>>
>>>> Hi Devs,
>>>>
>>>> I am adding a new field
>>>> in org.apache.stratos.messaging.domain.topology.Member class, called
>>>> instanceId.
>>>>
>>>> For this, what would be a better approach
>>>>
>>>> 1. Modifying the existing constructor
>>>> 2. Adding a new constructor which takes this as an additional argument
>>>> 3. Just have a setter method.
>>>>
>>>> In case of 2 and 3, the member may not be initialized properly.
>>>>
>>>> I am confused about which to use because I am unaware of the scope of
>>>> this Member class. If this is widely used then option 1 would mean changes
>>>> at a lot of places.
>>>>
>>>> If I know what is the scope of this Member class, it would help me
>>>> determine which approach to follow. Is there any way to find out in what
>>>> all places a class's object is used apart from searching it manually
>>>> through the codebase?
>>>>
>>>> I would appreciate any help in deciding the approach.
>>>>
>>>> Thanks and Regards,
>>>> Swapnil
>>>>
>>>> --
>>>> Thanks and Regards,
>>>>
>>>> Isuru H.
>>>> +94 716 358 048
>>>>
>>>> --
>>>> <%2B94%20716%20358%20048>
>>>> <%2B94%20716%20358%20048>
>>>> Thanks and Regards,
>>>>
>>>> Isuru H.
>>>> <%2B94%20716%20358%20048>
>>>> +94 716 358 048* <http://wso2.com/>*
>>>>
>>>>
>>>> * <http://wso2.com/>*
>>>>
>>>>
>>>>

Re: What is a better way to instantiate/set a new field

Posted by Isuru Haththotuwa <is...@apache.org>.
On Tue, Jun 2, 2015 at 12:57 PM, Swapnil Patil <sw...@gmail.com>
wrote:

> Hi Isuru,
>
> Thanks for suggesstions.
>
>
>> Member class is used in the Topology hierarchy, to represent each member
>> of a cluster. For me, the easiest way to find where it has been referenced
>> is using the IDE that you are using. For an example, in IntelliJ Idea, you
>> can right click on the Member class's constructor -> click on find usages.
>> I'm sure you know this already.
>>
>
> Yes, I am aware of it. Currently I am using Eclipse. The thing is, I am
> new to Maven projects. I have imported all the projects in the workspace.
> But I am not able to find references to this class. I am getting the error
> "The resource is not on the build path of a Java project". To fix this I
> need to configure the build path. But unfortunately, the option to
> configure build path is disabled. Now I am not sure why is this so. This
> option to configure build path is enabled for a few projects (which I
> assume Eclipse treat them as Java project) but for others (many of them) it
> is disabled (I assume Eclipse doesn't treat them as Java projects).
>
> I am not sure about this behaviour. Is this because I have imported Maven
> projects? Is there anything else I need to do? like creating Eclipse
> projects manually with command 'maven eclipse:eclipse'?
>
Yes, mvn eclipse:eclipse should create the eclipse project for you. Then,
open the project from the Eclipse IDE. It should work.

>
>
>
>> IMO If this instance id is an optional field, its fine to use a setter.
>> If its a mandatory field for all Member objects, the it should be
>> initialized in the same constructor that is there currently.
>>
>
> Okay. Thanks. I think this new field should be optional.
>
> Thanks and Regards,
> Swapnil
>
> On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
>> wrote:
>>
>>> Hi Devs,
>>>
>>> I am adding a new field
>>> in org.apache.stratos.messaging.domain.topology.Member class, called
>>> instanceId.
>>>
>>> For this, what would be a better approach
>>>
>>> 1. Modifying the existing constructor
>>> 2. Adding a new constructor which takes this as an additional argument
>>> 3. Just have a setter method.
>>>
>>> In case of 2 and 3, the member may not be initialized properly.
>>>
>>> I am confused about which to use because I am unaware of the scope of
>>> this Member class. If this is widely used then option 1 would mean changes
>>> at a lot of places.
>>>
>>> If I know what is the scope of this Member class, it would help me
>>> determine which approach to follow. Is there any way to find out in what
>>> all places a class's object is used apart from searching it manually
>>> through the codebase?
>>>
>>> I would appreciate any help in deciding the approach.
>>>
>>> Thanks and Regards,
>>> Swapnil
>>>
>>> --
>>> Thanks and Regards,
>>>
>>> Isuru H.
>>> +94 716 358 048
>>>
>>> --
>>> <%2B94%20716%20358%20048>
>>> <%2B94%20716%20358%20048>
>>> Thanks and Regards,
>>>
>>> Isuru H.
>>> <%2B94%20716%20358%20048>
>>> +94 716 358 048* <http://wso2.com/>*
>>>
>>>
>>> * <http://wso2.com/>*
>>>
>>>
>>>

Re: What is a better way to instantiate/set a new field

Posted by Swapnil Patil <sw...@gmail.com>.
Hi Isuru,

Thanks for suggesstions.


> Member class is used in the Topology hierarchy, to represent each member
> of a cluster. For me, the easiest way to find where it has been referenced
> is using the IDE that you are using. For an example, in IntelliJ Idea, you
> can right click on the Member class's constructor -> click on find usages.
> I'm sure you know this already.
>

Yes, I am aware of it. Currently I am using Eclipse. The thing is, I am new
to Maven projects. I have imported all the projects in the workspace. But I
am not able to find references to this class. I am getting the error "The
resource is not on the build path of a Java project". To fix this I need to
configure the build path. But unfortunately, the option to configure build
path is disabled. Now I am not sure why is this so. This option to
configure build path is enabled for a few projects (which I assume Eclipse
treat them as Java project) but for others (many of them) it is disabled (I
assume Eclipse doesn't treat them as Java projects).

I am not sure about this behaviour. Is this because I have imported Maven
projects? Is there anything else I need to do? like creating Eclipse
projects manually with command 'maven eclipse:eclipse'?



> IMO If this instance id is an optional field, its fine to use a setter. If
> its a mandatory field for all Member objects, the it should be initialized
> in the same constructor that is there currently.
>

Okay. Thanks. I think this new field should be optional.

Thanks and Regards,
Swapnil

On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
> wrote:
>
>> Hi Devs,
>>
>> I am adding a new field
>> in org.apache.stratos.messaging.domain.topology.Member class, called
>> instanceId.
>>
>> For this, what would be a better approach
>>
>> 1. Modifying the existing constructor
>> 2. Adding a new constructor which takes this as an additional argument
>> 3. Just have a setter method.
>>
>> In case of 2 and 3, the member may not be initialized properly.
>>
>> I am confused about which to use because I am unaware of the scope of
>> this Member class. If this is widely used then option 1 would mean changes
>> at a lot of places.
>>
>> If I know what is the scope of this Member class, it would help me
>> determine which approach to follow. Is there any way to find out in what
>> all places a class's object is used apart from searching it manually
>> through the codebase?
>>
>> I would appreciate any help in deciding the approach.
>>
>> Thanks and Regards,
>> Swapnil
>>
>> --
>> Thanks and Regards,
>>
>> Isuru H.
>> +94 716 358 048* <http://wso2.com/>*
>>
>>
>> * <http://wso2.com/>*
>>
>>
>>

Re: What is a better way to instantiate/set a new field

Posted by Isuru Haththotuwa <is...@apache.org>.
Hi Swapnil,

Member class is used in the Topology hierarchy, to represent each member of
a cluster. For me, the easiest way to find where it has been referenced is
using the IDE that you are using. For an example, in IntelliJ Idea, you can
right click on the Member class's constructor -> click on find usages. I'm
sure you know this already.

IMO If this instance id is an optional field, its fine to use a setter. If
its a mandatory field for all Member objects, the it should be initialized
in the same constructor that is there currently.

On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
wrote:

> Hi Devs,
>
> I am adding a new field
> in org.apache.stratos.messaging.domain.topology.Member class, called
> instanceId.
>
> For this, what would be a better approach
>
> 1. Modifying the existing constructor
> 2. Adding a new constructor which takes this as an additional argument
> 3. Just have a setter method.
>
> In case of 2 and 3, the member may not be initialized properly.
>
> I am confused about which to use because I am unaware of the scope of this
> Member class. If this is widely used then option 1 would mean changes at a
> lot of places.
>
> If I know what is the scope of this Member class, it would help me
> determine which approach to follow. Is there any way to find out in what
> all places a class's object is used apart from searching it manually
> through the codebase?
>
> I would appreciate any help in deciding the approach.
>
> Thanks and Regards,
> Swapnil
>
> --
> Thanks and Regards,
>
> Isuru H.
> +94 716 358 048* <http://wso2.com/>*
>
>
> * <http://wso2.com/>*
>
>
>

Re: What is a better way to instantiate/set a new field

Posted by Swapnil Patil <sw...@gmail.com>.
Hi Udara,

I want to expose the instanceId in MemberContext class to other components
through topology. I have already figured out a way to do so.

Now I am adding a new field instanceId in Member class of
load.balancer.common.domain. So I just wanted to know how should I
instantiate this new field.

Thanks,
Swapnil

On Mon, Jun 1, 2015 at 4:13 PM, Udara Liyanage <ud...@wso2.com> wrote:

> Hi,
>
> Cloud controller creates a Member object which represents an instance in
> IaaS. Then it sends an event with the member details so other components
> get updated.
> Could you describe what is instanceId you trying to add so we can find a
> the most suitable approach.
>
> On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
> wrote:
>
>> Hi Devs,
>>
>> I am adding a new field
>> in org.apache.stratos.messaging.domain.topology.Member class, called
>> instanceId.
>>
>> For this, what would be a better approach
>>
>> 1. Modifying the existing constructor
>> 2. Adding a new constructor which takes this as an additional argument
>> 3. Just have a setter method.
>>
>> In case of 2 and 3, the member may not be initialized properly.
>>
>> I am confused about which to use because I am unaware of the scope of
>> this Member class. If this is widely used then option 1 would mean changes
>> at a lot of places.
>>
>> If I know what is the scope of this Member class, it would help me
>> determine which approach to follow. Is there any way to find out in what
>> all places a class's object is used apart from searching it manually
>> through the codebase?
>>
>> I would appreciate any help in deciding the approach.
>>
>> Thanks and Regards,
>> Swapnil
>>
>
>
>
> --
>
> Udara Liyanage
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> web: http://udaraliyanage.wordpress.com
> phone: +94 71 443 6897
>

Re: What is a better way to instantiate/set a new field

Posted by Swapnil Patil <sw...@gmail.com>.
Hi Rajkumar,

Thanks for the suggestion. I think this should be optional field.

Regards,
Swapnil

On Mon, Jun 1, 2015 at 4:19 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> It depends on whether the *instanceId* is mandatory or not. If it is
> mandatory, you should modify the existing constructor and have it in the
> constructor. If it is not mandatory, you should have a setter.
>
> Thanks.
>
> On Mon, Jun 1, 2015 at 9:43 PM, Udara Liyanage <ud...@wso2.com> wrote:
>
>> Hi,
>>
>> Cloud controller creates a Member object which represents an instance in
>> IaaS. Then it sends an event with the member details so other components
>> get updated.
>> Could you describe what is instanceId you trying to add so we can find a
>> the most suitable approach.
>>
>> On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
>> wrote:
>>
>>> Hi Devs,
>>>
>>> I am adding a new field
>>> in org.apache.stratos.messaging.domain.topology.Member class, called
>>> instanceId.
>>>
>>> For this, what would be a better approach
>>>
>>> 1. Modifying the existing constructor
>>> 2. Adding a new constructor which takes this as an additional argument
>>> 3. Just have a setter method.
>>>
>>> In case of 2 and 3, the member may not be initialized properly.
>>>
>>> I am confused about which to use because I am unaware of the scope of
>>> this Member class. If this is widely used then option 1 would mean changes
>>> at a lot of places.
>>>
>>> If I know what is the scope of this Member class, it would help me
>>> determine which approach to follow. Is there any way to find out in what
>>> all places a class's object is used apart from searching it manually
>>> through the codebase?
>>>
>>> I would appreciate any help in deciding the approach.
>>>
>>> Thanks and Regards,
>>> Swapnil
>>>
>>
>>
>>
>> --
>>
>> Udara Liyanage
>> Software Engineer
>> WSO2, Inc.: http://wso2.com
>> lean. enterprise. middleware
>>
>> web: http://udaraliyanage.wordpress.com
>> phone: +94 71 443 6897
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>
> Mobile : +94777568639
> Blog : rajkumarr.com
>

Re: What is a better way to instantiate/set a new field

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
It depends on whether the *instanceId* is mandatory or not. If it is
mandatory, you should modify the existing constructor and have it in the
constructor. If it is not mandatory, you should have a setter.

Thanks.

On Mon, Jun 1, 2015 at 9:43 PM, Udara Liyanage <ud...@wso2.com> wrote:

> Hi,
>
> Cloud controller creates a Member object which represents an instance in
> IaaS. Then it sends an event with the member details so other components
> get updated.
> Could you describe what is instanceId you trying to add so we can find a
> the most suitable approach.
>
> On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
> wrote:
>
>> Hi Devs,
>>
>> I am adding a new field
>> in org.apache.stratos.messaging.domain.topology.Member class, called
>> instanceId.
>>
>> For this, what would be a better approach
>>
>> 1. Modifying the existing constructor
>> 2. Adding a new constructor which takes this as an additional argument
>> 3. Just have a setter method.
>>
>> In case of 2 and 3, the member may not be initialized properly.
>>
>> I am confused about which to use because I am unaware of the scope of
>> this Member class. If this is widely used then option 1 would mean changes
>> at a lot of places.
>>
>> If I know what is the scope of this Member class, it would help me
>> determine which approach to follow. Is there any way to find out in what
>> all places a class's object is used apart from searching it manually
>> through the codebase?
>>
>> I would appreciate any help in deciding the approach.
>>
>> Thanks and Regards,
>> Swapnil
>>
>
>
>
> --
>
> Udara Liyanage
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> web: http://udaraliyanage.wordpress.com
> phone: +94 71 443 6897
>



-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com

Re: What is a better way to instantiate/set a new field

Posted by Udara Liyanage <ud...@wso2.com>.
Hi,

Cloud controller creates a Member object which represents an instance in
IaaS. Then it sends an event with the member details so other components
get updated.
Could you describe what is instanceId you trying to add so we can find a
the most suitable approach.

On Mon, Jun 1, 2015 at 8:33 PM, Swapnil Patil <sw...@gmail.com>
wrote:

> Hi Devs,
>
> I am adding a new field
> in org.apache.stratos.messaging.domain.topology.Member class, called
> instanceId.
>
> For this, what would be a better approach
>
> 1. Modifying the existing constructor
> 2. Adding a new constructor which takes this as an additional argument
> 3. Just have a setter method.
>
> In case of 2 and 3, the member may not be initialized properly.
>
> I am confused about which to use because I am unaware of the scope of this
> Member class. If this is widely used then option 1 would mean changes at a
> lot of places.
>
> If I know what is the scope of this Member class, it would help me
> determine which approach to follow. Is there any way to find out in what
> all places a class's object is used apart from searching it manually
> through the codebase?
>
> I would appreciate any help in deciding the approach.
>
> Thanks and Regards,
> Swapnil
>



-- 

Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897