naming

Reasons behind naming in easy-to-confuse Python's classes such as OS and SYS?

折月煮酒 提交于 2019-12-06 00:46:06
I have noticed that considerably amount of questions in SO, relating to Python, are about people messing up Sys -class, OS class and no class. For example, an easy confusing is the case: os.open("something") , open("something") and sys.open("something") . I haven't understood yet the reasons behind the naming of classes, perhaps it is just an evolution. I would like to hear why they were created with their current names? Are naming due to things like having FDs in a class? Is naming because some classes require special privileges? To which extent is the naming a design solution? If you cannot

Naming: solution, projects, namespaces and assemblies

别说谁变了你拦得住时间么 提交于 2019-12-05 13:13:41
问题 I'm working on naming guidelines for solutions, projects, their default namespaces and assemblies (Visual Studio). Now it looks like that: For example, we have a company named "Company" and a project named "Project". The project has business logic in separate dll, UI (WPF/WinForms) and a web part. There are names of things listed in the question title: Solution name: "Project". Business logic dll project name: "Project", default namespace: "Company.Project", assembly name: "Project". UI

Interface naming convention Golang

我怕爱的太早我们不能终老 提交于 2019-12-05 11:37:13
问题 I'll just post my code: /* * Role will ALWAYS reserve the session key "role". */ package goserver const ( ROLE_KEY string = "role" ) type Role string //if index is higher or equal than role, will pass type RolesHierarchy []Role func (r Role) String() string { return string(r) } func NewRole(session ServerSession) Role { return session.GetValue(ROLE_KEY).(Role) } func (this Role) IsRole(role Role, hierarchy RolesHierarchy) bool { if role == this { return true } if len(hierarchy) == 0 { return

Open file knowing only a part of its name

二次信任 提交于 2019-12-05 11:17:09
I'm currently reading a file and importing the data in it with the line: # Read data from file. data = np.loadtxt(join(mypath, 'file.data'), unpack=True) where the variable mypath is known. The issue is that the file file.data will change with time assuming names like: file_3453453.data file_12324.data file_987667.data ... So I need a way to tell the code to open the file in that path that has a name like file*.data , assuming that there will always be only one file by that name in the path. Is there a way to do this in python ? You can use the glob module. It allows pattern matching on

JavaScript: Getting fully-qualified function name from within it?

房东的猫 提交于 2019-12-05 09:17:02
Take a look at the snippet below. Is there any function I could write in replace of ... to generate the route, that could reused in another function? Something like var route = this.show.fullyQualifiedName perhaps? var services = { 'github.com': { api: { v2: { json: { repos: { show: function(username, fn) { var route = ...; // route now == 'github.com/api/v2/json/repos/show' route += '/' + username; return $.getJSON('http://' + route).done(fn); } } } } } } } No, there isn't, at least not using "reflection" style operations. Objects have no knowledge of the name of the objects in which they're

Rails Reserved Class Names

青春壹個敷衍的年華 提交于 2019-12-05 05:34:46
I tried creating a model called "class" (as in a graduating class of students), and encountered all kinds of problems. What are some other words or class names to avoid in Rails? Some links I've found: http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/ http://railsforum.com/viewtopic.php?id=22242 This page has a very long list of words not to use: https://reservedwords.herokuapp.com/words Because 'class' comes up very commonly as a name with metaprogamming, I think the accepted ruby alternative is 'klass'. This is obviously a different context from your graduating class

Mutex names - best practice?

瘦欲@ 提交于 2019-12-05 04:54:30
Related to this question , what is the best practice for naming a mutex? I realize this may vary with OS and even with version (esp for Windows), so please specify platform in answering. My interest is in Win XP and Vista. Sam Saffron A really safe name for a global mutex is <a description> + <a GUID> : MyApp Single Instance Mutex : {c96f7db4-d743-4718-bef0-8533a198bcca} By using a name like this there is absolutely no chance someone else will use the same mutex name as your mutex. Sniffing around with process explorer, you can see that GUIDs are used in a few places, though in general they

Why people don't use uppercase in the name of header files in C++?

我是研究僧i 提交于 2019-12-05 02:33:10
I was wondering why people don't use uppercase in name of header files. I see many header files with name only in lowercase. But I thought it would be more easy to read if they write them with uppercase, say "BaseClass.h", "SubClass.h", instead of "baseclass.h", "subclass.h". Why is that? Or it's just that the header files I've seen are named only in lowercase? There are systems out there which are case-sensitive (*nix), and there are systems which are traditionally case-insensitive (Windows). As a result, if you develop on *nix and create two files: baseclass.h and BaseClass.h - your code

Why can't you name a function in Go “init”?

随声附和 提交于 2019-12-05 00:39:53
So, today while I was coding I found out that creating a function with the name init generated an error method init() not found , but when I renamed it to startup it all worked fine. Is the word "init" preserved for some internal operation in Go or am I'm missing something here? Yes, the function init() is special. It is automatically executed when a package is loaded. Even the package main may contain one or more init() functions that are executed before the actual program begins: http://golang.org/doc/effective_go.html#init It is part of the package initialization, as explained in the

(Spring MVC / Jackson) Mapping query parameters to @ModelAttribute: LOWERCASE_WITH_UNDERSCORE to SNAKE_CASE fails

天大地大妈咪最大 提交于 2019-12-05 00:17:29
@GetMapping("item") public @ResponseBody String get(@ModelAttribute Item item) Item has the attributes name itemType When I access /item?name=foo&item_type=bar the item gets populated only with name not with itemType . I tried a bunch of things to get the itemType attribute mapped from item_type . Added @JsonProperty("item_type") inside Item 's itemType attribute. Described here . Added a JackonConfiguration that sets the propertyNamingStrategy to PropertyNamingStrategy.SNAKE_CASE. Described here . Added spring.jackson.property-naming-strategy=SNAKE_CASE to my Spring Boot application