coding-style

Ordering columns in database tables

五迷三道 提交于 2019-12-04 23:34:12
When it comes to column order in DB tables, are there any standards or at least best practices? Here's a handmade convention that I follow: primary key (i.e. id ); unique columns (i.e. email , ssn ); foreign keys (i.e. article ); columns holding user generated data (i.e. first_name , last_name ); columns holding system generated data; non-boolean (i.e. password_hash ); boolean (i.e. deleted , verified ) timestamp columns (i.e. created_at ); These leave many questions unanswered, though, so I'd like to hear your thoughts. Patrick Karcher In short, you've stated the standard conventions well and

Export Visual Studio's 'Code Style settings' as .editorconfig

南笙酒味 提交于 2019-12-04 23:27:55
Our team works with Visual Studio 2017 Professional. I've been trying to unify the Code Style across the team and apparently the industry standard right now is to use .editorconfig files. Even Visual Studio in it's settings windows suggests to use that configuration file and links to a useful page on how to write an editorconfig file. but I don't want to write all the settings that I already have configured in VS by hand. I would like a tool that exports those settings as a .editorconfig file to distribute them. I haven't been able to find any tool to do just that so I thought on righting it

When to exploit type inference in Haskell?

自古美人都是妖i 提交于 2019-12-04 23:05:55
I'm curious as to how often experienced Haskell programmers really use type inference in practice. I often see it praised as an advantage over the always-explicit declarations needed in certain other languages, but for some reason (perhaps just because I'm new) it "feels" right to write a type signature just about all the time... and I'm sure in some cases it really is required. Can some experienced Haskellers (Haskellites? Haskellizers?) provide some input? It's still an advantage, even if you write type signatures, because the compiler will catch type errors in your functions. I usually

Nested case statements in SML

强颜欢笑 提交于 2019-12-04 23:00:44
This is more of a stylistic question than anything else. Given the following piece of code: case e1 of (* datatype type_of_e1 = p1 | p2 *) p1 => case e11 of (* datatype type_of_e11 = NONE | SOME int *) NONE => expr11 | SOME v => expr12 v | p2 => case e21 of (* datatype type_of_e21 = NONE | SOME string *) NONE => expr21 | SOME v => expr22 v Is there a way to resolve the types of rules don't agree error caused by trying to pattern match e11 to p2 , other than enclosing p1 's expression in parenthesis? The p2 pattern has another case statement, to avoid the 'just switch the patterns' answer ;-).

What does 1-, 2-, or 3-process mean for an FSM in VHDL?

狂风中的少年 提交于 2019-12-04 22:47:54
问题 It seems like there is quite some debate about how to code finite state machines (FSMs) in VHDL. People talk about 1-process, 2-process, or 3-process FSMs as if everyone knew exactly what it means and what each process does. However, I've been unable to find a precise definition, and the examples that exist seem to be contradictory. This is an objective question: What is the difference in terms of code for each FSM style (1-process, 2-process, 3-process)? I understand that there is a

Still lost on Repositories and Decoupling, ASP.NET MVC

北战南征 提交于 2019-12-04 22:36:52
问题 I'm still on my eternal quest to build (and understand) modern programming convention of decoupling, IoC, DI, etc. I'm to the part where I am trying to figure out how to build a repository. I've examined the post at Database abstraction layer design - Using IRepository the right way? which was very helpful, but I've still got some problems that are just befuddling me all the way. I have my program in now 4 layers... Web (Project | ASP.NET MVC Application) - References Models.dll and

How to get the blue style text in 2.1 Contacts or Preferences

拟墨画扇 提交于 2019-12-04 21:06:41
Running Android 2.1, preferences and other dialogs have white/blue text. Looking at theme values I see things like textColorPrimary and textColorSecondary. If I reference those colors in my layout xml, with something like: android:textColor="?android:attr/textColorSecondary" I just see white text (I have tried textColorPrimary, textColorTertiary and textColorHint also). I do not have any theme values stated in my manifest file. I am presuming this means I am using the system default theme. All that said, am I barking up the wrong tree with textColor* references? all the textColor* attributes

Using default font styles in Android

痞子三分冷 提交于 2019-12-04 20:59:33
问题 How do you use the Android default font sizes in xml? I tried: android:textAppearance="@android:style/TextAppearance_Large" But I get: error: Error: No resource found that matches the given name (at 'textAppearance' with value '@android:style/TextAppearance_Large'). 回答1: Isn't it android:textAppearance="?android:attr/textAppearanceLarge" for a TextView? 来源: https://stackoverflow.com/questions/3405161/using-default-font-styles-in-android

How to clear screen from simple C program?

牧云@^-^@ 提交于 2019-12-04 19:56:20
#include <stdio.h> #include <cstdlib> rec(); main() { int a, fact; char q, n, y; printf("\nEnter any number "); scanf("%d", & a); fact = rec(a); printf("Factorial value = %d\n", fact); printf("do you want to exit.....(y/n):"); scanf("%s" ,&q); if (q == 'n') { system("cls"); main(); } else return 0; } rec(int x) { int f; if (x == 1) return 1; else f = x * rec(x - 1); return f; } I'm using code blocks but I don't know how to clear the screen. I searched then found system("cls"); within header file #include<cstdlib> , but it shows the error cstdlib: no such file of directory . What should I do ?

What is the best way to use whitespace while programming? [closed]

谁说胖子不能爱 提交于 2019-12-04 19:34:51
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago . I'm fairly new to programming and from learning I have seen different ways of formatting code, comments, etc; and have been