Book a Demo

Author Topic: "Template Classes"  (Read 3609 times)

jesuarez

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
"Template Classes"
« on: April 21, 2006, 08:22:02 am »
Hi,

I need to create classes that not implements any interface (legacy reasons) but have common methods and attributes.

So, every time i create a class of this type I have to manually add these methods.

Can I automate this createa something similar to Template Methods? I didn't understand the purpose of Metaclasses.... may be it could be useful.

Thanks in advance,
Regards,
Juan


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: "Template Classes"
« Reply #1 on: April 21, 2006, 11:59:50 am »
Is there any compelling reason you cannot create a parent class (perhaps abstract) and inherit the methods and attributes?
No, you can't have it!

jesuarez

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: "Template Classes"
« Reply #2 on: April 21, 2006, 12:05:36 pm »
Midnight,

Thanks for your reply.

I'm documenting an existing framework that i don't have the oportunity to change now, for example adding a base class or interface (if i add it in the model it will not refelct the reality).  :-[

I agree with your approach, but i can't do that in this scenario.

So, I have to add a clases that always have the same methods and don't implement a common interface or inherit from a base class.

Regards,
Juan

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: "Template Classes"
« Reply #3 on: April 21, 2006, 01:26:17 pm »
Long shot here; open EA help and look up "Template Package." This is primarily for setting default appearance, but does allow some of the attributes of default elements to be set. I have no idea if it would allow a set of default attributes or methods but it might be worth a try.

If it works, you'll have to set the most common subset at the beginning, create the appropriate elements, then modify the template and do the next 'closest' set; repeat as required.
No, you can't have it!

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: "Template Classes"
« Reply #4 on: April 23, 2006, 05:21:49 pm »
You're right Midnight; attributes and operations of the template class will be copied.
The Sparx Team
[email protected]