This question already has answers here:
What is the difference between 'open' and 'public' in Kotlin?
(8 answers)
Closed 1 year ago.
I'm new at Kotlin and I'm reading the kotlin official documentation, it states the 4 differents visibility modifiers (public, private, internal, protected) furthermore it's also using the keyword OPEN to express that a class can be extended (that is its purpose). My question is, can OPEN be considered as a Visibility Modifier?
No, open is not a visibility modifier, as it does not affect visibility at all.
Instead, open affects if classes or methods can be extended/overridden and is the opposite of javas final in these cases.
Related
This question already has answers here:
I can't compile class with an interface
(1 answer)
I don't know if I need to or how to implement those 3 basic methods of an interface
(1 answer)
Closed 9 months ago.
My primary goal is to use SOLID principles while switching to Delphi language.
Let suppose I have a parent class Parent that I unfortunately can't edit or modify (e.g. part of the delphi library, hidden in private code..).
Parent = class;
And a child class, that I want to improve, by implementing an OOP interface ("interface" or "pure abstract class", used indistinctively from now on):
INiceInterface = interface
procedure HelloWorld;
end;
Child = class(Parent, INiceInterface)
procedure HelloWorld; override;
end;
When trying to do this, the compiler complains about:
E2291 Missing implementation of interface method INiceInterface._AddRef
E2291 Missing implementation of interface method INiceInterface._Release
E2291 Missing implementation of interface method INiceInterface.QueryInterface
Looking for those errors, I found the following text exploring solutions, with a quite negative conclusion: https://www.codeproject.com/Articles/1252175/Fixing-Delphis-Interface-Limitations
Considering that OOP is a quite mature concept, much older than Delphi, I am positively convinced that I am missing something, and that such a basic feature must be available in Delphi.
How to properly apply inverse dependency in Delphi?
[ enfasis multiple interfaces ]
This question already has answers here:
Why use inline without lambdas
(3 answers)
Closed 1 year ago.
The Kotlin documentation itself states the following:
If an inline function has no inlinable function parameters and no reified type parameters, the compiler will issue a warning, since inlining such functions is very unlikely to be beneficial.
Both statements, no inlinable function parameters and no reified type parameters, are true for, for example, the following extension methods in String.kt:
public inline fun String.reversed(): String
public inline fun String.slice(indices: Iterable<Int>) : String
public inline fun CharSequence.random(): Char
Can anyone explain me a specific reason why the language designers probably made the decisions to mark these methods as inline? Thanks.
As #somethingsomething pointed out in the comments, this question has been answered in a similar question before.
The answer there (by a JetBrains employee) was:
This particular function and a few others in kotlin-stdlib are marked as #InlineOnly so that they are not present in the actual stdlib class files and are only available for the Kotlin compiler to inline them. The goal that is achieved in this way is reducing the methods count in the artifacts, which matters for Android.
The #InlineOnly annotation is also discussed in this question.
This question already has answers here:
Classes vs. Modules in VB.NET
(8 answers)
VB.NET What is the purpose of a class or module?
(7 answers)
Closed 9 years ago.
I have been new to Visual Basic. Why exactly do we use a module in VB.NET?
What would be a small example of a module and calling it one of the form?
A Module in VB.Net is essentially a grouping a methods and fields. These members can be accessed without qualification anywhere that the module itself is accessible. This mechanism is actually how many of the standard VB operators ChDir, ChDrive, CurDir are implemented. There is a module in the VB runtime named FileSystem which defines all of these operations
The main advantages / differences between Module and Class are the following
It's a declarative grouping of functions that aren't associated with instances of an object
It's the only way to define extension methods in VB.Net
No need for a redundant qualifier on every usage of a project helper method
No need to protect a module from accidental instantiation by the developer. It's by definition not creatable
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What is the best way to solve an Objective-C namespace collision?
I was using 2 open source projects in an application with different use --- the issue was that both project had same class name with different implementations.
As per my understanding objective C don't have namespace option to handle scope --- as of now I am renaming the one of the class and its usage to make it work in my project.
Is there any alternative solution then renaming? I feel like objective C is missing namespace.
Renaming is the correct way. There is a reason why Apple recommends to prefix your classes with some uppercase letters. This should prevent exactly this situation. Same for method names in class extension, or "private" methods.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
“Overloads” keyword in VB.NET
what exactly overloads signifies in vb.net coz even if i am not writing the overloads in derived class function its working in the similar manner when i am writing it.
Function overloading allows more than one function to be defined with the same name in the same class, as long as the arguments are different. Not to be confused with function overriding where functions have the same number, type of arguments its the implementations in the derived classes that differs.
I believe that the overloads keyword in vb.net is completely optional, and is there only to support better readability of the code.
There is an all-or-nothing rule, however, so if you use it for one method, you have to use it for all overloading methods.