constants

What is the best way to define string constants in an objective-c protocol?

I have defined a protocol that all my plug-ins must implement. I would also like the plug-ins to all use certain strings, like MyPluginErrorDomain. With integers this is quite easily achieved in an enum, but I can't figure out how to do the same with strings. Normally, in classes I would define extern NSString * const MyPluginErrorDoma...

Request for comments: python class factory for group of constant values

The following python module is meant to be a basis for "constant" handling in python. The use case is the following: one groups some constants (basically "names") that belong together with their values into a dictionary with that dictionary bound to class variable a class is created and instantinated run-time the attributes of this cla...

How to get name of the constant?

Assuming you have a constant defined in a class: class Foo { const ERR_SOME_CONST = 6001; function bar() { $x = 6001; // need to get 'ERR_SOME_CONST' } } Is it possible with PHP? ...

Should screen dimension constants that hold magic numbers be refactored?

I have a few specific places in my code where I use specific pixel dimensions to blit certain things to the screen. Obviously these are placed in well named constants, but I'm worried that it's still kind of vague. Example: This is in a small function's local scope, so I would hope it's obvious that the constant's name applies to what t...

Question about Ruby on Rails, Constants, belongs_to & Database Optimization/Performance

I've developed a web based point of sale system for one of my clients in Ruby on Rails with MySQL backend. These guys are growing so fast that they are ringing close to 10,000 transactions per day corporate-wide. For this question, I will use the transactions table as an example. Currently, I store the transactions.status as a string ...

(In Ruby) allowing mixed-in class methods access to class constants

Hi. I have a class with a constant defined for it. I then have a class method defined that accesses that class constant. This works fine. An example: #! /usr/bin/env ruby class NonInstantiableClass Const = "hello, world!" class << self def shout_my_constant puts Const.upcase end end ...

Delphi: constant class instance

If I define a record, I can define an instance of that record as a constant record e.g. Tunit = record _name: string; _scale: real; end; const metre: Tunit = (_name: 'metre'; _scale: 1.0; ) I need to do something similar where Tunit is a Class and metre is an instance of the class, but is a (particular) instance whose asso...

Create constant NSString from constant CFStringRef

I am attempting to create a Cocoa Framework that is an object-oriented wrapper around a procedural framework written in the Core Foundation. The procedural framework has a number of constants that are all defined as extern CFStringRef constantName. How should I create NSString constants that directly map to the procedural constants so t...

Sessions or Constants for storing data, which is better in this situation...

Hi, I would like some advice on storing data for different languages on my website. I've spent hours searchin and can't seem to find what I need. Here's my situation, so let me know what you think. I have a website that multiple users can log into to view and store information. I use php, Mysql, Apache, on a FreeBSD operating system (...

ASP.NET MVC "GET" and "POST" constants

Does ASP.NET MVC have any constants for the the strings "GET" and "POST"? ...

Why Doesn't Delphi 2009 Give A Message For A String Constant that is Too Long?

It got me stuck for an hour. I happened to have a string constant with about 280 characters in it. I was trying to use Pos to look for a substring within a long string constant. It gives the result 0 when the string is longer than 255 characters, but gives the correct result when the string is shorter. e.g.: pos('5', '123456789.12345...

How to represent system constants in XAML (like double.MaxValue)

What is the xaml equivalent of MyProperty = double.MaxValue? I'm afraid I'll need to use something like MyProperty="{x:Static sys:Int32.MaxValue}", but not sure, and can't find the equivalent for double. Thanks. ...

Help loading contstants stored in serialized array using eval() and constant()

DISCLAIMER: Please read carefully as this is NOT a question about storing arrays in constants or simple eval() or serialize() techniques. This IS a question primarily about how constants work in PHP and why the constant() function is not working to convert a constant name into a constant value. Thanks. BACKGROUND: For various reasons, I...

Overridable Constant?

Maybe I should just make this a public member, but I keep thinking it should be a constant. SCENARIO I have forms I'm rendering into PDFs (using iTextSharp). In code, the forms themselves all inherit a base class (OrderForm). Within OrderForm, there are a list of constants that I use for measurements when aligning things for the PDF re...

there is no type juggling for constants (I want my string 'REGEX_NAME' like 'REGEX_EMAIL' to become REGEX_NAME like REGEX_EMAIL)

I'm having to manually write: if($pattern == 'REGEX_EMAIL') $pattern = REGEX_EMAIL; if($pattern == 'REGEX_PASSWORD') $pattern = REGEX_PASSWORD; Is there an other way? ...

How to manage project-wide constants in a project using c#?

hi when developing a project by vb6, we created a module and put every project-wide constant in it. Now, by using c#, how can we manage project-wide constants? ...

How to find the usage of constant in sql server database

Is there a way to search through the set of (Stored Procedures, Functions, Views) for the usage of a constant? I have a problem where I've got a sql server database. It has quite a few stored procedures and functions declared. I'm looking for the usage of "115", which happens to be a pay code. I didn't write all of the code origina...

How do you override a Constant in Doctrine's Models?

In Doctrine you are provided with a Constant Variable that allows you to set a global Identifier column in all of the models that are generated by Doctrine's code. I am trying to figure out how I can override/shut off this value so that it does not create this column in a specific table. The Constant is: ATTR_DEFAULT_IDENTIFIER_OPTION...

Where to declare/define class scope constants in C++?

I'm curious about the benefits/detriments of different constant declaration and definition options in C++. For the longest time, I've just been declaring them at the top of the header file before the class definition: //.h const int MyConst = 10; const string MyStrConst = "String"; class MyClass { ... }; While this pollutes the globa...

iphone project constant

Hello, I want to have a constant in my project to change between Lite and Pro version. I don't think it is the best way to do it, but I am trying to: add a constant in my app delegate #define BUILD_PRO 1 //0 => LITE, 1 => PRO when I need it I import the appDelegate and test it: #import "myAppDelegate.h" then later #if (BUILD_PRO...