Using 'Class' and ES6 - mootools

Is there a conflict of behavior for using the Class expression, since it became a reserved word in the latest version of Ecmascript? Can't say if there is identity of grammar between the two contexts, but I guess the built-in noun takes precedence.

JavaScript is case-sensitive. Its class keyword and MooTools' Class identifier don't conflict at all.
If you mean the "classes" generated, I wouldn't try to use one style to subclass a "class" created with the other style (though you might get it to work, particularly if using class to subclass a Class class), but other than that, there's no big conflict. They both create objects with associated prototypes.

Related

How to write a wrapper class / Override configuration in pre existing Puppet Class

I would like to override the values of another class in another Puppet Modules. Please help me by suggesting ways.
Existing Class : ( Module Name : MySQL )
class mysql::server (
$config_file = $mysql::params::config_file,
$includedir = $mysql::params::includedir)
{
My Code Logics
}
My Current Class : ( Module Name : Profiles )
Class profiles::mysql () {
class { '::mysql::server':
config_file => '/opt/arunraj',
includedir => true
}
}
When i am doing like above, I am getting duplicate class declaration error. Which is a best way to override a values between two classes
In the first place, your example code is incomplete. You present the definitions of classes mysql::server and profiles::mysql, and the latter contains a resource-style declaration of class mysql::server, but you say nothing about the one or more other declarations of class mysql::server that the given one collides with. What you actually presented is not enough to produce the error you describe.
Note also that using resource-style class declarations is usually poor form, especially for declaring public classes of any module, and most especially for declaring classes belonging to a different module than the one in which the declaration appears. The reasons are a bit technical, but to a large extent they boil down to the risk of eliciting exactly the kind of error you encountered. That happens whenever Puppet evaluates a resource-style declaration of a class for which a declaration (in any style) has already been evaluated, because class parameter values are bound as part of evaluating the first-encountered declaration.
The best way to customize class parameter values is to rely on automatic data binding (Hiera) to bind values to those parameters in the first place. If you have an oddball machine that needs different parameter values then you set them at a higher-priority level of your data hierarchy than the one from which the ordinary values come, and which is scoped narrowly enough to avoid affecting machines that should have the ordinary parameters.
Moreover, to avoid the kind of error you describe, you should also be certain everywhere to use only include-like declarations for any class that might be declared more than once (i.e. any public one, and some private ones). That goes hand in hand with automatic binding because if you don't use resource-like declarations then automatic data binding is your best available means for customizing class parameter values. The classical include-style declaration is via the include function itself, but the require, contain, and hiera_include functions also provide include-style declarations (with various differences in semantics). If you're using an ENC to declare classes then it might produce either style.

get/set methods and constructors in class diagram

recently I was assigned to develop an use case diagram and a class diagram for a conference management system. First I developed use case diagram and then class diagram. In the class diagram I have the following unclear parts:
Do we need to show get and set methods for all the private fields in every class. Or we can omit get and set methods, since it is obvious.
Do we need to show the constructors in a class? If it is not necessary, what is the reason for not showing them? I have seen lot of class diagrams without the constructors but the reason for that is beyond my understanding.
Gets and sets methods are not UML definition. It is just way how to manipulate with attribute values in some programming languages. Pure UML know attribute , its type, name and other properties.
Typical usage of getters and setters in programing is to implement readonly or derived (calculated) attributes.
You do not have to define getters and setters in uml class diagram.
Constructor:
You can define constructor operation in class of course. Constructor operation has keyword "create" at the beginning of its name. You can assign behavior definition to constructor as its method to define how to construct instance of class.
See Common Behavion in UML Superstructure.

Actionscript 3 - passing custom class as parameter to custom class where parameter class not constructed

Hi and thanks in advance,
I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.
This, I understand, is because the custom class used as a parameter has not yet been constructed.
It all works when I use the variable type ( * ) to type the parameter.
I suspect this is a design flaw, in that I am using an incorrect design pattern. It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.
I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.
Is there any other way to control the order of construction of classes? Would the rest variables work?
Thanks
(edit)
in main.as within the constructor or another function
var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:
public function customclass1(parameter1:customclass2)
{
....
Flash complains that the compiled type cannot be found when I use the data type customclass 2 in the paramater. It does not complain when I use the variable data type * or leave out the data type (which then defaults to * anyway). I reason that this is because customclass2 has not yet been constructed and is therefore not available to the compiler.
Alternatively, I have not added the path of customclass2 to the compiler but I am fairly certain I have ruled this out.
There are over 10,000 lines of code and the whole thing works very well. I am rewriting simply to optimise for the compiler - strict data typing, error handling, etc. If I find a situation where inheritance etc is available as an option then I'll use it but it is already divided into classes (at least in the main part). It is simply for my own peace of mind and to maintain a policy of strict data typing so that compiler optimization works more efficiently.
thnx
I have not added the path of customclass2 to the compiler but I am fairly certain I have ruled this out.
So if you don't have the class written anywhere what can the compiler do ? It is going to choke of course. You either have to write the CustomClass class file or just use "thing:Object" or "thing:Asteriks". It's not going to complain when you use the "*" class type because it could be anything an array, string, a previously declared class. But when you specify something that doesn't exists it will just choke, regardless of the order the parameters are declared in.

Understanding the difference between types and representations

This article speaks of the difference between types and classes. Since I've only worked with languages that treat both as identical, please suggest material/programming-languages that will teach me the difference.
Difference is not the right word - classes are certainly types. But not all types are classes. Note also that the word "class" is quite vague - it could be just a tuple type (with no operations except construction and projection - a C struct so to speak) or, on the other side of the spectrum, a class that contains only methods, but no state.
Sather is the oldest language i know of which treats types and classes separately. However, it is not completely rigorous, as one can still use a class as a variable type (i think), one just can't subtype it.
This is not terribly different from what C++ lets you do: you can use purely abstract classes to define types, and have all concrete classes implement them using public inheritance, but subclass each other using private inheritance. You then use the abstract classes for variable types, using the concrete classes only in constructor expressions.
Java lets you do more or less the same, defining types using interfaces and implementations using classes, but because there is no private inheritance, there is no way to hide the inheritance relationship of the classes.
Does that make any sense at all?
Java, pre-autoboxing. int and Integer are both types, but only the latter is a class.

How to avoid class name and namespace conflict?

Sometimes I have need to call namespace and class the same. For example, SomeProject.Compiler namespace, containing lots of compiler-related stuff and the main entry point class Compiler. But naming namespace and class name the same is not recommended, as it creates ambiguity and misleads compiler.
Is there any idea, how to name them better?
It is always possible to give general namespace name, which describes all its members. For example, CompilerServices instead of compiler.
Some books say you should write the domain of your company (in the reverse order) before the name of namespace.
Something like com.company.www.compiler