conventions

Is there a standard/convention for the ordering of columns in a database table definition?

Is there a standard/convention for how the columns should be ordered in the definition of a database table, and if so what is the motivation for that standard? (pros/cons) For example, should the primary key be the first column? Should the foreign keys directly follow the primary key or should they be placed at the far right of the tabl...

Is it poor coding practice to have a SQL table that contains a column with the same name?

Example: CREATE TABLE ErrorNumber ( ErrorNumber int, ErrorText varchar(255), ) This can result in queries that look like: SELECT ErrorNumber FROM ErrorNumber WHERE ErrorNumber=10 ...

What best practices and conventions are there when designing and implementing a website?

I'll soon be working on a personal website that will include static and dynamic content (starting with static content, with dynamic content added over time using both custom-written components as well as open-source solutions), however I'm fairly new to web design and development, so any advice on things such as directory structure, file...

\Windows\ versus \Windows\System32 - File location conventions

Is there a standard convention for the types of files that go in \Windows\ versus those that go in \Windows\System32 ?? I'm working on an SDK that has a variety of DLLs a helper exe, and a Windows service exe. The previous guy who worked on the code put the two exe files in \Windows\ and the DLLs in \Windows\System32\ But it seems t...

Order of Methods within any Class

I'm still very new to programming and I want to write the cleanest code possible. This may sound like a silly question, but what order should I put my methods in? Functionally of course it doesn't matter, but layout it makes a huge difference. So say we have the following code in one class: -(void)testCreateProjectWithStartDate { [...

Are there a Code Conventions for Assembly (mainly PIC)?

Are there a Code Conventions for Assembly (mainly PIC)? ...

Fluent NHibernate Has Many to Many Convention Questions

I am new to fluent nhibernate and nhibernate. I want to write a fluent nhibernate autopersistence convention to handle creating the many to many mappings for my entities. This is what I have right now: using System; using FluentNHibernate.Conventions; using FluentNHibernate.Mapping; namespace Namespace { public class HasManyToMan...

Which style of return should I use?

This is related to conventions used in C#. I've got a method that has two parameters (X and Y coordinates). These coordinates represent the position at which a "tile" may reside. If a tile resides at these coordinates, the method returns its number. If no tile resides at these coordinates, I'm wondering how the method should behave. ...

Is accepting Object as a parameter acceptable?

Let us say I have a textbox or any other form of input that asks for a social security number. I do want to note that the SSN is a pure example I simply thought of as of right now. This input will naturally be stored as a string initially. string s = Console.ReadLine(); Let us say I want to have a method that validates an SSN and it m...

Function/Class Comment Formatting Conventions

Who has the most readable and useful function/class commenting convention? I'm not looking for something that generates docs, but I'm considering adopting something like JavaDoc because all the info is there. /** * This function processes data * * @param p1 the first piece of data * @param p2 the second piece of data * @return t...

Is it pythonic to import inside functions?

PEP 8 says: Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants. On occation, I violate PEP 8. Some times I import stuff inside functions. As a general rule, I do this if there is an import that is only used within a single function. Any opin...

PHP framework URL conventions

A lot of frameworks use URL conventions like /controller/action/{id} which is great, but if you need any configuration beyond that, it's up to you to write your own routes. How would you handle URLs like /users/{id}/friends on the backend? (to list all of a user's friends) I'm thinking that in the controller, something like this would ...

Contents Folder Convention in MVC

I am wondering what the history behind the convention for a /contents folder in ASP.NET MVC project is; where it originates; and the reasoning behind it. Our team is considering to move our /images and /styles out of /contents to decrease the folder levels in the project. It will be nice to know why the convention was in place in the fi...

Why are the arguments to atan2 Y,X rather than X,Y?

In C the atan2 function has the following signature: double atan2( double y, double x ); Other languages do this as well. This is the only function I know of that takes its arguments in Y,X order rather than X,Y order, and it screws me up regularly because when I think coordinates, I think (X,Y). Does anyone know why atan2's argumen...

Should I Use self Keyword (Properties) In The Implementation?

Hey guys. I believe I understand properties for the most part. My question is, if I have a property for an instance variable, and I am setting or retrieving it from within a method in my implementation file, should I use self.myProperty or just myProperty? I know either one works, but I have seen mixed conventions, sometimes code accesse...

Recommended initialization values for numbers

Assume you have a variety of number or int based variables that you want to be initialized to some default value. But using 0 could be problematic because 0 is meaningful and could have side affects. Are there any conventions around this? I have been working in Actionscript lately and have a variety of value objects with optional param...

Are MySQL ENUMS intended for use with CakePHP or should I avoid them?

Thing is, I don't see these ENUMs producing pull-down menus in CakePHP scaffolding, so I'm thinking CakePHP might advise against it, but I can't find any documentation on the matter. Anyone know whether or not to use ENUMs? ...

What is the conventional way to assign default values to member variables in C#?

Which is more conventional in C#? class Foo { private string _first; private string _second; public Foo(string first) { _first = first; _second = string.Empty; } } or class Foo { private string _first; private string _second = string.Empty; public Foo(string first) { _first = first; } } ...

Newbie to python conventions, is my code on the right track?

I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?) #There are six brack...

Is it bad practice to put a lot of code in the get function of a property which wraps PInvoke stuff?

A confusing title I know. Let me explain. I have to marshal an array of structs, which then get converted to an array of classes (legacy compatibility). For instance public class InnerClass {} public class OuterClass { private InnerClass[] innerClasses; } public struct InnerStruct { // Data } private static buildInnerClass( Inne...