conventions

Implementing custom STL-like data structures

I have already implemented and tested the data structure and would now like to make it compatible with the collection of STL algorithms. Guidelines for implementing a custom iterator and the like. Specifically: What is the minimum set of operations that must be supported? (e.g. ++, +=, ==, !=?) Are there any properties of these operati...

Prefixes for C/C++ data members / objects

I've been getting more and more involved in C / C++ programming lately and have noticed a trend in the way people name datatypes in their code. I always see prefixes such as p, m, ui, etc. For example: mPlayerNames, pData, uiNumResets I think I get it, but just to confirm: Do these prefixes indicate the data type? ie: mData -> Matrix ...

Better solution than accessing routes in the Model?

So I know that you shouldn't use UrlWriter methods in a model, but I wasn't sure what a better way to handle my current situation is. Basically, I want to allow a User to post something to his facebook feed, and want to write a post_to_fb_feed(object) method in class User. Now, the URL of what is actually posted depends on the object, s...

Product naming convention for iPhone 4 apps?

With the iPad we got applications with the product name extension "HD" to distinguish them from their low resolution iPhone counterparts. But, now with iPhone 4 also being an "HD" device, how to correctly name your apps? Basically I'd like to publish a game in three flavors: iPad, iPhone 4, and all other iPhone/iPod devices. Any though...

MIME-type conventions, standards or limitations?

Given a new, proprietary file format that cannot currently be handled by any known application, I assume you can just invent a new MIME type value as follows: Content-Type: application/my-arbitrary-format Assuming this is the way to go, are there any limitations (format, syntax, length, reserved words, or otherwise), standards (IETF, ...

JavaScript braces on new line or not?

Hi, At work, we place braces on the next line, but at home, I do the opposite. Which one do you prefer? (K&R vs OTBS) function something() { // ... } function something() { // ... } A lot of JavaScript libraries seem to use the OTBS (one true brace style). I'd like to follow them for consistence among other JavaScript projec...

Bug or new convention for namespace declaration in .Net 4.0

Visual Studio 2010, .Net 4.0 I'm generating some Domain Service Classes and this is how visual studio includes the namespaces: namespace MyCoolProject.Web.Services { using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Data.Linq; u...

Difference Class and Instance Methods

Hi, Whats the difference between class methods and Instance methods. Why do we need them separately? Can somebody please explain? Class and Instance Methods • Instances respond to instance methods - (id)init; - (float)height; - (void)walk; • Classes respond to class methods + (id)alloc; + (id)person; + (Person *)sharedPerson;...

Where to put reusable testing methods used in several grails test classes

I often need to set up the same test structures for different test cases. Therefore I created a TestService class that has several public methods for the test classes. I guess that this is not the best place to put them as TestService will also be deployed although not needed on production. Where would you put those commonly test metho...

Help me write this event The Right Way

Original Question I've read at least a dozen articles and SO threads on events and have puzzled out the basic ideas, but I'm a bit muddy on how to do it The Right Way. It seems that there are at least two common approaches to writing events, and one is more recommended than the other. I'm seeing a lot of material in which the author sk...

cakephp creates misspelled model class and it's filename

I have a database table named 'abuses'. While baking the application the bake command named it's controller classname as "abuses" and filename as "abuses_controller.php" but when I baked the model the filename was "Abus.php" and classname was "Abus". Is that a bug in cakePHP ? or did I miss something ? Has anyone encountered the same p...

Cross controller function conventions for MVC web?

I have a question about the best practices of placing certain functions in controllers in an MVC web framework. Lets say I have a User & Tags controller. I have a function/method called addTag_to_user(). What is the conventions or best practices for placing this in either the Users or Tags controller? Though personally I am more incli...

Removing a trailing slash in MSBuild / Convention based filename generation

I'm trying to search for a set of assemblies based on the following convention within a directory: {SubDirName}\{SubDirName}.dll I've started by creating an MSBuild ItemGroup [by batching another ItemGroup on the .RecursiveDir portion]. <AllAssemblies Include="$(SourceDirectory)\**\Test.*.dll" /> <Dirs Include="@(AllAssemblies->'%(Re...

what is actually "EXTENT" in gis slang?

Hi , I am not clearly understanding the extent parameter in GIS applications. for ex, In mapserver map file we are using NAME "CGI-CONTEXT-DEMO" STATUS ON SIZE 400 300 **EXTENT -2200000 -712631 3072800 3840000** UNITS METERS IMAGECOLOR 255 255 255 IMAGETYPE png here extent means lower left x,y and upper right x,y. but long,lat values ...

How to create custom routes for certain actions in a CakePHP controller?

Coming from Django, I'm used to be able to organize my URL routings any way I see fit. For example, user registration would exist under the /users/ url. /users/ /users/registration/ /users/registration/optin/ /users/registration/thankyou/ However, I'm creating a user registration system in CakePHP and the default convention behaviour...

How to create a test for Fluent nHibernate conventions?

I am creating a set of conventions for Fluent nHibernate. I create a few conventions, like primary key, foreign key and many-to-many table. I would like to be able to test out these conventions with an in memory database to see if I coded these conventions correctly. Currently, I am setting up nHibernate using an SQlite in-memory datab...

Where do you put your Rack middleware files and requires?

I'm in the process of refactoring some logic built into a Rails application into middleware, and one annoyance I've run into is a seeming lack of convention for where to put them. Currently I've settled on app/middleware but I could just as easily move it to vendor/middleware or maybe vendor/plugins/middleware... The biggest problem is...

I know I'm supposed to keep Python code to 79 cols, but how do I indent continuations of lines?

I am aware that the standard Python convention for line width is 79 characters. I know lines can be continued in a number of ways, such as automatic string concatenation, parentheses, and the backslash. What does not seem to be as clearly defined is how exactly the overflowing text should be formatted. Do I push it all the way back to co...

Benefits of stripping trailing white spaces?

I got into the habit of removing trailing white spaces from my source file. In fact, I have my editor to do this automatically. I got in this habit by using git; it created a habit that I adhere to. My question relates to the fact that I cannot justify this behaviour. I can understand that in some fields, such as web designers, it may ...

FluentNHibernate and VARCHAR Columns

Hi everyone, I am starting a simple .NET project with FluentNhibernate. I've followed few examples I've found on the Internet and it seems quite easy to grasp. I've realized that if I let FluentNhibernate build my DB schema (Sql Server 2000) it generates NVARCHAR fields for my strings model properties. Someone suggested that I can add ...