Instant Generator and Association

Hi, I’m having a small issue with the instant generator when using using the association tool to link to classes together.

In the code generator it gives you the option to add a prefix to the attribute and parameter variable names when generating the code. However these prefixes are not applied to attributes created due to associations. Also it would be nice to have the option to capitilise the first letter of the variable name created from an association.

An example:
I have 2 classes, one called SecurityEngine and another called Account. I use the association tool to create a composition link between them (the SecurityEngine contains an Account instance). I run the Instant Generator to generate C# code but apply a “m_” as an attribute prefix (which is the convention in C#) but the code results in:

 private Account account 

instead of:

 private Account m_Account 

which is what I’m aiming for.

I’m also wondering whether VP can generate getters and setters for C# properties, so instead of:

 public int GetAccess() {
	return m_Access;
}

public int SetAccess(int access) {
	m_Access = access;
} 

it generates:

 public int Access {
	get {
		return m_Access;
	}
	set {
		m_Access = value;
	}
} 

Am I overlooking something? Is there a simple way to get this functionality?

Looking forward to a reply :slight_smile:

Jargon

Hello Jargon,

Thanks for your bug report. We will fix the two issues, and come back to you as soon as possible. Concerning your suggestion:

Also it would be nice to have the option to capitilise the first letter of the variable name created from an association.

May I know the reason of this suggestion? Isn’t the convention use lowercase for the first letter? Besides, why not just enter the correct name in the role? Sorry to ask so many questions.

Best regards,
Jick

It is, but if applying a prefix to the attribute or parameter such as “m_” then the first letter of the actual attribute/parameter name will need to be capatilised to follow convention.

Example:
I have an attribute called account, the attribute prefix should result in m_Account instead of m_account.

As for entering in the name as the role, I was unaware you could do this :slight_smile: however, the prefix still is not applied.

Ok, I have just been playing with the roles on the associations and spotted another anomaly.

In the role properties you can assign the attribute it references or create a new attribute for it to reference in the appropriate class, which is excellent. However, the role name is derived either from the name of the attribute it references or if that is left blank, then it uses the name of the class. But it still does not use the prefix information supplied in the Instant Generator options, so you end up with:

private Account m_Account

at the top of the generated code (above the constructors and methods)
AND

private Account account

at the bottom of the generated code ( below the constructors and methods)

My question is, should the role name even by generated into code? It seems to me that this is just descriptive and is not needed since you can link the association to a specific attribute in the role properties. This would also stop the code generator creating an attribute in the class at both ends of the association instead of just in the “Association End From”, which a composition association should do.

Hello Jargon,

I am glad to inform you that the 2 issues you reported were fixed. You can download the patch at:
http://files3.visual-paradigm.com/200706/Patch/sp2_20070605d/vpplatform.jar

To install the patch:

  1. Shutdown any running instances of VP
  2. Replace $vp-suite-install-dir/lib/vpplatform.jar with the downloaded jar file
  3. Run $vp-suite-install-dir/bin/VP Suite.exe to install the patch
  4. Restart the application

Note:

  1. If you are going to download with Internet Explorer, you may need to rename the file from .zip to .jar manually
  2. Please do not run Product Update after applying the patch. Otherwise the update will replace the patch with the previous version (I will inform you to run the update when the next release is ready)

Please let me know if it works.

As for entering in the name as the role, I was unaware you could do this however, the prefix still is not applied.

I do not quite understand. Weren’t the two problems you reported earlier both related to code generated from roles? :?:

Best regards,
Jick Yeung

Hi Jick, thanks for the fast response and patch!

However, the patch is causing me issues. It will not generate the code any more, reporting the error in the Generator Output:

ResourceManager : unable to find resource ‘v.ipzr@c91629/generic.vm’ in any resource loader.

In regards to your question. Yes, they probably were related but at the time I wasn’t aware it was using the information from the roles properties. I only identified the problem from the output it gave.

Hopefully this error can be fixed as fast as the patch was released :slight_smile:

Jargon

Hello Jargon,

I am so sorry for the failure of the patch. I will prepare another one for you. Sorry once again.

Best regards,
Jick

Hello Jargon,

Please try this one:
http://files3.visual-paradigm.com/200706/Patch/sp2_20070605e/VP_Suite_Windows_3_0_sp2_20070605e.exe

Please reinstall by overwriting the original one.

Best regards,
Jick

Hi Jick

Everything works wonderfully, thanks ever so much. This will make my life a lot easier :slight_smile:

One last thing though, is there a way to have the getters and setters appear below all the attribute declarations? Basically group them all together?

Hi Jargon,

Glad to know that everything works fine. Concerning your request, I will discuss with our developers and come back to you with more information.

Best regards,
Jick

Hello Jargon,

Concerning your requests of having the getters and setters appear below all attribute declarations, we have updated the template to make it work for your request. Please find the template files attached. Please replace the templates inside ${vpsuite-install-dir}\resources\instantgenerator\csharp with those attached. After that, run the tool and run Instant Generator of C#. The code should be generated in the way you expected.

Please notice that when you perform product update, you have deselect to update the template files. Otherwise they will be replaced by the original files.

Best regards,
Jick
attribute.vm
class.vm

Hi Jick,

I have a small problem trying to download the files. From what I can tell the class.vm file is incomplete. I had a look inside and it seems to end abruptly, in the middle of a word. It’s odd though as Internet Explorer and Firefox end up with different, yet incomplete files.

Possibly an error while uploading?

Regards,
Jargon

Hi Jargon,

I have zipped them up. Please try again.

Best regards,
Jick
templates.zip

Much better, thank you Jick!

Your continual prompt response and fixes never cease to amaze me. Some of the best software support I have ever experienced.

Please pass on my thanks to your development team as well :slight_smile:

Regards,
Jargon

Hello Jargon,

You are welcome. Please feel free to let me know if you need any help. :slight_smile:

Best regards,
Jick

Hi Jargon,

We just released the new build of VP Suite. It is now safe to run the product updater (inside ${vp-suite-install-dir}/bin) to advance to the latest release. Please feel free to let me know if there are any questions.

Best regards,
Jick Yeung