conventions

NodeJS best practices: Errors for flow control?

故事扮演 提交于 2020-01-02 04:31:08
问题 In Node.js, should I use errors for flow control, or should I use them more like exceptions? I'm writing an authentication controller and some unit tests in Sails.js, and currently, my registration method checks to see if a user with the same username exists. If a user already exists with the username, my model method calls its callback arguments with a new Error object, like so: Model: exists: function (options, cb) { User.findOne({ where: { username: typeof options === 'Object' && options

When to use companion object factory versus the new keyword

本小妞迷上赌 提交于 2020-01-01 08:42:28
问题 Many classes in the Scala standard library use apply() of their companion object as factory. This is often convenient when chaining calls like List(List(1)) . On the other hand, it's still possible to create objects directly with new ( new HashMap[Int, Int]() ). That's standard library. Now, in my own code, which approach is better to use: companion factory or creating objects with new ? Is there any convention on when to create companion object factory and when to do with the new keyword?

What is the name of this convention for curly braces?

夙愿已清 提交于 2020-01-01 08:32:28
问题 I'm a bit puzzled by the number of developers I see writing methods and classes with curly braces below the class name or the method. What convention are they following? Sun clearly states that the correct declaration would be: // this declaration follows sun's conventions class Sample extends Object { Sample(int i, int j) { .... } } Yet more and more I see this declared as (even in books): // this declaration follows a convention I cant identify class Sample extends Object { Sample(int i,

What is the name of this convention for curly braces?

廉价感情. 提交于 2020-01-01 08:32:25
问题 I'm a bit puzzled by the number of developers I see writing methods and classes with curly braces below the class name or the method. What convention are they following? Sun clearly states that the correct declaration would be: // this declaration follows sun's conventions class Sample extends Object { Sample(int i, int j) { .... } } Yet more and more I see this declared as (even in books): // this declaration follows a convention I cant identify class Sample extends Object { Sample(int i,

Clojure code static analysis tools

北城余情 提交于 2020-01-01 04:53:21
问题 Is there a tool to run code convention tests in clojure? For example, make sure function names don't have any capital letters or keywords don't have any underscores in them. 回答1: Two useful Leiningen plugins I learned about recently: lein-bikeshed lein-kibit 回答2: Late to the party here. Seconding noahlz, the three main static analysis tools that I use on a regular basis are lein-bikeshed, lein-kibit, and Eastwood, though I also use yagni. Each of these has different strengths. Bikeshed is

Durandal and ASP.NET MVC conventions

帅比萌擦擦* 提交于 2020-01-01 01:54:08
问题 I'm currently evaluating Durandal for use in an enterprise ASP.NET MVC application. However the default conventions used by Durandal seem to conflict with the MVC conventions I've grown accustomed to. The HotTowel MVC template by John Papa is great, but this too seems to "do away" with MVC conventions in favour of Durandals by putting things in an App folder. A couple of the issues I have with these conventions are: Views are potentially split across two locations (/App/views and /Views).

Laravel 4 Controller Templating / Blade - Correct method? [closed]

戏子无情 提交于 2019-12-31 08:58:46
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I've been reading through the Laravel 4 documentation and have been making a demo application to help with learning. I couldn't find much documentation on the templating of views with blade and controllers. Which is the correct method or does it come down to personal

Laravel 4 Controller Templating / Blade - Correct method? [closed]

我怕爱的太早我们不能终老 提交于 2019-12-31 08:58:31
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I've been reading through the Laravel 4 documentation and have been making a demo application to help with learning. I couldn't find much documentation on the templating of views with blade and controllers. Which is the correct method or does it come down to personal

Getters and Setters in Java convention [duplicate]

戏子无情 提交于 2019-12-30 09:57:24
问题 This question already has answers here : Java Getters and Setters (16 answers) Closed 6 years ago . My Java is a bit rusty (been doing C# for the last couple of years). Also I hope this won't be a very subjective question. Anyway say I had class Person (yeah a bit of a cliche, I know), with no behaviour (C# version): public class Person { public string Name { get; set; } public int Age { get; set; } // say 10+ properties } How would the equivalent Java version look like ? I know I can write

Why is it thought of 'T *name' to be the C way and 'T* name' to be the C++ way?

让人想犯罪 __ 提交于 2019-12-30 07:55:32
问题 Note: This question is about the position of the asterisk ( * ). In most C code I see (e.g., in Beej's guide to network programming), all variable declarations / definitions use the T *name format, i.e., bind the * to the variable name. The pointer is thought of belonging to the variable, not the type. In most C++ code I see, the format is T* name , i.e., it binds the * to the type of the variable . The pointer is thought of belonging to the type, not the variable. I myself, as a pure C++