Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interface - attribute not generated #11

Open
huseyin39 opened this issue Dec 28, 2018 · 5 comments
Open

interface - attribute not generated #11

huseyin39 opened this issue Dec 28, 2018 · 5 comments

Comments

@huseyin39
Copy link

Hello,
When creating an interface on StarUML and giving an attribute, the code generation doesn't create that attribute (would be CONST of ruby).
Thanks!

@meisyal
Copy link
Owner

meisyal commented Dec 29, 2018

Hi @huseyin39,

Taking from Java programming language, an interface is a basically blueprint of methods that the class who implements the interface. In other words, an interface only contains several methods. It doesn't contain attribute or instance variables.

This extension converts an interface to a Ruby module. You can look the example here.

So, if this doesn't work with your case. Could you share your class diagram or example of an interface with attributes? What should generated Ruby code be?

@huseyin39
Copy link
Author

huseyin39 commented Dec 29, 2018

In Ruby module, you can have variable. It is one of the purpose of Ruby's module with methods.

For example, I create an interface on StarUML 'Interface' and give it a attribute 'var' and with a value 'value'. So I expect the extension to create a module named 'Interface' with a variable named 'var' with 'value' as value.

It generates
module Interface
end

I would expect it to generate:

module Interface
var = value
end

@meisyal
Copy link
Owner

meisyal commented Dec 30, 2018

Could you share resources of a Ruby module with attributes?

As I understand it, an interface contains only several methods that to be implemented by a class who implements it. It can't contain attributes. If you want to add attributes, you should create an abstract class instead of interface. By the way, I don't know how to implement abstract class on Ruby.

Here are some resources about interface:

  1. What Is an Interface?
  2. Abstract Classes & Interfaces
  3. What is the difference between an interface and abstract class?

@huseyin39
Copy link
Author

I am not talking about Java interface but about Ruby module. There is not Ruby's module in StarUML, so we can consider implementing module from StarUML's interface.

See below the first line: "A Module is a collection of methods and constants."
Ruby Module

@meisyal
Copy link
Owner

meisyal commented Jan 1, 2019

I see. You are talking about constants in Ruby module. Yes, this extension doesn't generate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants