What is Facades and how it works? (Specially for Laravel) [duplicate] - laravel-5

This question already has answers here:
What is Facades used in Laravel?
(3 answers)
Closed 4 years ago.
Can you please describe elaborately about Facade?

A Facade is an alias to classes that are available in the application's service container, these classes can be Laravelor vendor package classes. Facades are used because they provide a terse, memorable syntax that allows us to use Laravel/Vendor features without remembering long class names.
In short Facades allow you to use fro example JWTAuth::getToken(), instead of having to type out Tymon\JWTAuth::getToken() in full, increasing code readability.
[read More][1][1]: https://laravel.com/docs/5.5/facades

Related

Naming convention for java 9 modules [duplicate]

This question already has answers here:
How should I name my Java 9 module?
(2 answers)
Closed 4 years ago.
What's the naming convention for java 9 modules? Let's say my package name is me.jasonyeo.awesome.project, and whenever I create a module-info.java file in IDEA, it would suggest me to name it awesome.project
Is that the convention? Or should I name it me.jasonyeo.awesome.project?
It seems, IDEA’s suggestion is based on the fact the Java’s builtin modules have two components, e.g. java.base or java.desktop, but that doesn’t make a good suggestion for 3rd party modules.
JLS §6.1, Declarations says:
The name of a module should correspond to the name of its principal exported package. If a module does not have such a package, or if for legacy reasons it must have a name that does not correspond to one of its exported packages, then its name should still start with the reversed form of an Internet domain with which its author is associated.
Example 6.1-2. Unique Module Names
com.nighthacks.scrabble
org.openjdk.compiler
net.jcip.annotations
You may find the cited part faster using the direct link to the example
So your assumption is right, the recommended module name is me.jasonyeo.awesome.project, not awesome.project.

Dart v1.8: new feature enum [duplicate]

This question already has answers here:
How can I build an enum with Dart? [duplicate]
(4 answers)
Closed 8 years ago.
A simple question here :) I'm really happy to see a new feature in the dart language. But I just realized that I kind of never use enumeration.I don't know if there is a discussion somewhere about that but.
What is the pros and cons of this feature in terms of code writing (seems shorter), performance,etc?
Cheers
If I understand it correctly an enum is like a class with const members and some useful methods. Given that cost members are resolved by the compiler using an enum should not incur in any performance hit.
In terms of "code writing" enums are good candidates to replace classic const or static enumerations or, even better, hard-coded constants.

PEVerify in code? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Is there an API for verifying the MSIL of a dynamic assembly at runtime?
I'm dynamically generating an assembly using Reflection.Emit and the like.
For a unit test, I'd like to PEVerify my IL.
I can do it from the command line, but I'd rather do this in code.
Is there a way to do this which is more convenient than calling PEVerify.exe? Ideally, I'd like to directly hand it the dynamic assembly without having to save that assembly to disk first.
Ideally I'm looking for something along the lines of (psuedocode:
Assert.IsFalse(new PEVerifier(myAssembly).Verify().Errors.Any());
You could, as the 'duplicate' question's answer suggests, figure out how to hook into the native DLL used by PEVerify.exe (which I'm guessing would cause issues since it is not documented and probably is subject to change).
The other option would be to use the AssemblyBuilder class to write the dynamic assembly that you're creating to the disk at a temporary location and then call PEVerify.exe via the System.Diagnostics.Process class (much like this PEVerifier class example does).

Perfect forwarding - what's it all about? [duplicate]

This question already has answers here:
Closed 10 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Possible Duplicate:
Advantages of using forward
Could someone please explain to me what perfect forwarding is about?
http://www.justsoftwaresolutions.co.uk/cplusplus/rvalue_references_and_perfect_forwarding.html
Why is this useful? Well, it means that a function template can pass its arguments through to another function whilst retaining the lvalue/rvalue nature of the function arguments by using std::forward. This is called "perfect forwarding", avoids excessive copying, and avoids the template author having to write multiple overloads for lvalue and rvalue references.
Quoting Session Announcement: Adventures in Perfect Forwarding:
Perfecting forwarding is an important C++0x technique built atop
rvalue references. It allows move semantics to be automatically
applied, even when the source and the destination of a move are
separated by intervening function calls. Common examples include
constructors and setter functions that forward arguments they receive
to the data members of the class they are initializing or setting, as
well as standard library functions like make_shared, which
“perfect-forwards” its arguments to the class constructor of whatever
object the to-be-created shared_ptr is to point to.

Simple ruby syntax question [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What is Ruby's double-colon (::) all about?
Can you explain me, what two dots :: in ruby means?
Explain me on this example:
AWS::S3::Bucket.find(BUCKET).objects
What is here ASW, what S3, and what is Bucket (I mean, classes, packets, objects,...)
Here is the exact code that you are using under the hood:
https://github.com/marcel/aws-s3/blob/master/lib/aws/s3/bucket.rb
As you can see, there are nested modules/classes:
module AWS
module S3
class Bucket < Base
end
end
end
So:
AWS is a module.
S3 is a module.
Bucket is a class.
The class Bucket is nested inside the module S3 which is nested inside the module AWS.
A Module is basically a bundle of methods/constants, but they differ from classes in the sense where they can't have instances. You use that a lot in order to refactor your code and to better design it. More information on Modules here.
The :: is used to refer to the nested modules/classes. It's a kind of resolution operator, that helps you reach your nested modules/classes/constants by knowing their paths.
It's a ruby module. A module is a container of classes, and it's used to separate the namespace, it's similar (in a way) to java packages.

Resources