conventions

Subqueries in CakePHP 3?

此生再无相见时 提交于 2019-12-01 22:03:43
I have two tables products and product_categories that are associated through a third table, products_categories_products , according to CakePHP BelongsToMany conventions (Edit: these associations are established in ProductsTable.php and ProductCategoriesTable.php ). I want to generate a list of product categories, using the image from the best selling products to represent each category. I can achieve my desired outcome using the following function: public function findImages(Query $query, array $options) { $query->select([ 'ProductCategories.id', 'ProductCategories.name', 'ProductCategories_

(Conventions) C# Class names

北慕城南 提交于 2019-12-01 20:49:26
问题 I'm not too quite sure about what i should do about a grouped set of classes. My situation: I have 11 classes that relate only to the class Character.cs , but all of those classes (including Character.cs and CharacterManager.cs ) are within the namespace Models.Characters . Which is the more "proper" or preferred way of naming the classes: (examples): CharacterDetails.cs CharacterSprites CharacterAppearance CharacterClientRights CharacterServerRights or: Details.cs Sprites Appearance

Can I make vim accept \\b rather than just \\< and \\>?

孤街醉人 提交于 2019-12-01 18:12:51
I've just read this: In Vim, how do you search for a word boundary character, like the \b in regexp? and I was wondering - can't I make vim recognize \b also, somehow? Since Vim's regex flavor treats \b as a backspace character, and there is no chance re-defining this shorthand construct, you can only make it work with a PCRE regex engine that can be used with Vim the way described at Perl compatible regular expressions Vim Tips Wiki. This is the description from that page: Verify with :ver that +perl or +perl/dyn is compiled in. Install Perl if necessary. On Windows, ActivePerl is standard

Self-Referential ManyToMany Convention in CakePHP

谁说我不能喝 提交于 2019-12-01 01:09:30
I have an existing data model where I can rename things freely to match CakePHP's conventions . I have a type of graph node, where a node can have an arbitrary number of child nodes and an arbitrary number of parent nodes (uni-directional relationships). Here's the table of nodes, following CakePHP's conventions: Table: nodes Column: node_id (INT) Column: description (TEXT) My question is what the join table should look like? Here is what it looks like now: Table: nodes_nodes Column: parent_node_id (INT) Column: child_node_id (INT) And what the documentation implies it should be: Table: nodes

Self-Referential ManyToMany Convention in CakePHP

流过昼夜 提交于 2019-11-30 20:08:22
问题 I have an existing data model where I can rename things freely to match CakePHP's conventions. I have a type of graph node, where a node can have an arbitrary number of child nodes and an arbitrary number of parent nodes (uni-directional relationships). Here's the table of nodes, following CakePHP's conventions: Table: nodes Column: node_id (INT) Column: description (TEXT) My question is what the join table should look like? Here is what it looks like now: Table: nodes_nodes Column: parent

Type Hints Convention for Instance Variables Python

…衆ロ難τιáo~ 提交于 2019-11-30 13:55:02
Unsure of the Python convention for type hinting instance variables - I've been doing them within the __init__ constructor arguments like seen here: class LoggedVar(Generic[T]): def __init__(self, value: T, name: str, logger: Logger) -> None: self.name = name self.logger = logger self.value = value` link to above code snippet: https://docs.python.org/3/library/typing.html#user-defined-generic-types But I also see the PEP conventions of annotating instance variables as such(snippet below) and then also doing type hinting within the __init__ arguments: class BasicStarship: captain: str = 'Picard

Is there any technical reason to use or not to use var in C# when the type is known?

℡╲_俬逩灬. 提交于 2019-11-30 12:34:54
It seems that more and more C# code I read uses the var type identifier: foreach (var itemChange in ItemChanges) { //... } instead of explicitly stating the type: foreach (ItemChange itemChange in ItemChanges) { //... } even when the type is known. I am still using the latter explicit version just because I think someone reading it later will more quickly understand which type a variable is than if you use var. But is there any technical reason to use one or the other? Adam Ralph There is no technical reason. If the type cannot be inferred at compile time then the code will not compile. You

Should arrays be used in C++?

血红的双手。 提交于 2019-11-30 10:17:03
问题 Since std::list and std::vector exist, is there a reason to use traditional C arrays in C++, or should they be avoided, just like malloc ? 回答1: In C++11 where std::array is available, the answer is "yes, arrays should be avoided". Prior to C++11, you may need to use C arrays to allocate arrays in the automatic storage (i.e. on the stack). 回答2: Definitely, although with std::array in C++11, practically only for static data. C style arrays have three important advantages over std::vector : They

Is there a reason to prefer '&&' over '&' in 'if' statements, other than short-circuiting?

匆匆过客 提交于 2019-11-30 08:54:18
Yes I know, there have been a number of questions (see this one , for example) regarding the usage of & vs. && in R, but I have not found one that specifically answers my question. As I understand the differences, & does element-wise, vectorised comparison, much like the other arithmetic operations. It hence returns a logical vector that has length > 1 if both arguments have length > 1. && compares the first elements of both vectors and always returns a result of length 1. Moreover, it does short-circuiting : cond1 && cond2 && cond3 && ... only evaluates cond2 if cond1 is TRUE , and so forth.

set/get methods in C++

吃可爱长大的小学妹 提交于 2019-11-30 08:52:42
Java programmers and API seems to favor explicit set/get methods. however I got the impression C++ community frowns upon such practice. If it is so,is there a particular reason (besides more lines of code) why this is so? on the other hand, why does Java community choose to use methods rather than direct access? Thank you A well designed class should ideally not have too many gets and sets. In my opinion, too many gets and sets are basically an indication of the fact that someone else (and potentially many of them) need my data to achieve their purpose. In that case, why does that data belong