Search Results

Search found 724 results on 29 pages for 'constants'.

Page 2/29 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • GWT - problems with constants in css

    - by hba
    Hi, I'm new to GWT; I'm building a small sample app. I have several CSS files. I'm able to successfully use the ClientBundle and CssResource to assign styles to the elements defined in my UiBinder script. Now I'd like to take it one step further and introduce CSS constants using @def css-rule. The @def works great when I define a constant and use it in the same CSS file. However I cannot use it in another CSS file. When I try to use the @eval rule to evaluate an existing constant the compiler throws an execption: "cannot make a static reference to the non-static method ". Here is an example of what I'm trying to do: ConstantStyle.css @def BACKGROUND red; ConstantStyle.java package abc; import ...; interface ConstantStyle extends cssResource { String BACKGROUND(); } MyStyle.css @eval BACKGROUND abc.ConstantStyle.BACKGROUND(); .myClass {background-color: BACKGROUND;} MyStyle.java package abc; import ...; interface ConstantStyle extends cssResource { String myClass; } MyResources.java package abc; import ...; interface MyResources extends ClientBundle { @Source("ConstantStyle.css") ConstantStyle constantStyle(); @Source("MyStyle.css") MyStyle myStyle(); } Thanks in advance!

    Read the article

  • Using nested public classes to organize constants

    - by FrustratedWithFormsDesigner
    I'm working on an application with many constants. At the last code review it came up that the constants are too scattered and should all be organized into a single "master" constants file. The disagreement is about how to organize them. The majority feel that using the constant name should be good enough, but this will lead to code that looks like this: public static final String CREDITCARD_ACTION_SUBMITDATA = "6767"; public static final String CREDITCARD_UIFIELDID_CARDHOLDER_NAME = "3959854"; public static final String CREDITCARD_UIFIELDID_EXPIRY_MONTH = "3524"; public static final String CREDITCARD_UIFIELDID_ACCOUNT_ID = "3524"; ... public static final String BANKPAYMENT_UIFIELDID_ACCOUNT_ID = "9987"; I find this type of naming convention to be cumbersome. I thought it might be easier to use public nested class, and have something like this: public class IntegrationSystemConstants { public class CreditCard { public static final String UI_EXPIRY_MONTH = "3524"; public static final String UI_ACCOUNT_ID = "3524"; ... } public class BankAccount { public static final String UI_ACCOUNT_ID = "9987"; ... } } This idea wasn't well received because it was "too complicated" (I didn't get much detail as to why this might be too complicated). I think this creates a better division between groups of related constants and the auto-complete makes it easier to find these as well. I've never seen this done though, so I'm wondering if this is an accepted practice or if there's better reasons that it shouldn't be done.

    Read the article

  • C# coding standards” Use the const directive only on natural constants

    - by Nathan Wilfert
    I've seen these 2 guidelines in coding c# standard and I’m not sure the what the 2nd one means. With the exception of zero and one, never hard-code a numeric value; always declare a constant instead. Use the const directive only on natural constants such as the number of days of the week. 1st what is the definition of a natural constants and if the number is not a natural constants given the 1st rule how does one declare a constant in c# without the const directive? See http://www.scribd.com/doc/10731655/IDesign-C-Coding-Standard-232 for reference.

    Read the article

  • Servlet : Usage of Constants.java class vs context param

    - by Pongsakorn Semsuwan
    I'm just wondering whether to keep some of my variables in Constants class or keep it in web.xml Say, I want to keep a variable of Facebook graph API prefix or api_key, client_id From my understand, the difference between Constants.java and web.xml is web.xml is easier to rewrite on compile using ant. So, you can replace your variables in web.xml according to what environment you are building you app for. (client_id varies by development environment/production environment, for example) If I understand it right, then Facebook graph API prefix should be kept in Constants.java (because it always is "https://graph.facebook.com/") and api_key, client_id should be kept in web.xml? What's the proper way to use them?

    Read the article

  • Scope of Constants in Ruby Modules

    - by user204078
    I'm having a little problem with constant scope in mixin modules. Let's say I have something like this module Auth USER_KEY = "user" unless defined? USER_KEY def authorize user_id = session[USER_KEY] def end The USER_KEY constant should default to "user" unless it's already defined. Now I might mix this into a couple of places, but in one of those places the USER_KEY needs to be different, so we might have something like this class ApplicationController < ActionController::Base USER_KEY = "my_user" include Auth def test_auth authorize end end I would expect that USER_KEY would be "my_user" when used in authorize, since it's already defined, but it's still "user", taken from the modules definition of USER_KEY. Anyone have any idea how to get authorize to use the classes version of USER_KEY?

    Read the article

  • How to I make private class constants in Ruby

    - by DMisener
    In Ruby how does one create a private class constant? (i.e one that is visible inside the class but not outside) class Person SECRET='xxx' # How to make class private?? def show_secret puts "Secret: #{SECRET}" end end Person.new.show_secret puts Person::SECRET # I'd like this to fail

    Read the article

  • Constants and aspx

    - by arinte
    I have constants in my cs file Constants.cs. In the asp.net mvc controllers I use the constants like this ViewData[Constants.Whatever] = ...; How can I use the constants in my aspx file? When I try to use it I get an error saying: CS0103: The name 'Constants' does not exist in the current context

    Read the article

  • Making game constants/tables available to game logic classes/routines in a modular manner

    - by Extrakun
    Suppose I have a game where there are several predefined constants and charts (a XP chart, cost of goods and so on). Those could be defined at runtime, or load from files at start-up. The question is how should those logic routines access the constants and charts? For example, I could try using global variables, but that cause all classes relying on the variables to be tightly coupled with them.

    Read the article

  • Initialized variables vs named constants

    - by Mike
    I'm working on a fundamental programming class in college and our textbook is "programming logic and design" by joyce farrell(spelling?) Anyhow, I'm struggling conceptually when it comes to initialized variables and named constants. Our class is focusing on pseudo-code for the time being and not one particular language so let me illustrate what I'm talking about. Let's say I am declaring a variable named "myVar" and the data type is numeric: num myVar now I want to initialize it (I don't understand this concept) starting with the number 5 num myVar = 5 how is that any different than creating a named constant?

    Read the article

  • Storing class constants (for use as bitmask) in a database?

    - by fireeyedboy
    Let's say I have a class called Medium which can represent different types of media. For instance: uploaded video embedded video uploaded image embedded image I represent these types with contants, like this: class MediumAbstract { const UPLOAD = 0x0001; const EMBED = 0x0010; const VIDEO = 0x0100; const IMAGE = 0x1000; const VIDEO_UPLOAD = 0x0101; // for convenience const VIDEO_EMBED = 0x0110; // for convenience const IMAGE_UPLOAD = 0x1001; // for convenience const IMAGE_EMBED = 0x1010; // for convenience const ALL = 0x1111; // for convenience } Thus, it is easy for me to do a combined search on them on an (abstract) repository, with something like: { public function findAllByType( $type ) { ... } } $media = $repo->findAllByType( MediumAbstract::VIDEO | MediumAbstract::IMAGE_UPLOAD ); // or $media = $repo->findAllByType( MediumAbstract::ALL ); // etc.. How do you feel about using these constant values in a concrete repository like a database? Is it ok? Or should I substitute them with meaningful data in the database. Table medium: | id | type | location | etc.. ------------------------------------------------- | 1 | use constants here? | /some/path | etc.. (Of course I'll only be using the meaningful constants: VIDEO_UPLOAD, VIDEO_EMBED, IMAGE_UPLOAD and IMAGE_EMBED)

    Read the article

  • Compatibility of Enum Vs. string constants

    - by Yosi
    I was recently told that using Enum: public enum TaskEndState { Error, Completed, Running } may have compatibility/serialization issues, and thus sometimes it's better to use const string: public const string TASK_END_STATE = "END_STATE"; public const string TASK_END_STATE_ERROR = "TASK_END_STATE_ERROR"; public const string TASK_END_STATE_COMPLETE = "TASK_END_STATE_COMPLETE"; public const string TASK_END_STATE_RUNNING = "TASK_END_STATE_RUNNING"; Can you find practical use case where it may happen, is there any guidelines where Enum's should be avoided? Edit: My production environment has multiple WFC services (different versions of the same product). A later version may/or may not include some new properties as Task end state (this is just an example). If we try to deserialize a new Enum value in an older version of a specific service, it may not work.

    Read the article

  • Objective C defining UIColor constants

    - by futureelite7
    Hi, I have a iPhone application with a few custom-defined colors for my theme. Since these colors will be fixed for my UI, I would like to define the colors in a class to be included (Constants.h and Constants.m). How do I do that? (Simply defining them does not work because UIColors are mutable, and would cause errors - Initalizer not constant). /* Constants.h */ extern UIColor *test; /* Constants.m */ UIColor *test = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; Thanks!

    Read the article

  • Why can't Perl's DBD::DB2 find dbivport.h during installation?

    - by Liju Mathew
    We are using a Perl utility to dump data from DB2 database. We installed DBI package and it is asking for DBD package also. We dont have root access and when we try to install DBD package we are getting the following error: ERROR BUILDING DB2.pm [lijumathew@intblade03 DBD-DB2-1.78]$ make make[1]: Entering directory '/home/lijumathew/lperl/perlsrc/DBD-DB2-1.78/Constants' gcc -c -I"/db2/db2tf1/sqllib/include" -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"1.78\" -DXS_VERSION=\"1.78\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" Constants.c Running Mkbootstrap for DBD::DB2::Constants () chmod 644 Constants.bs rm -f ../blib/arch/auto/DBD/DB2/Constants/Constants.so gcc -shared -L/usr/local/lib Constants.o -o ../blib/arch/auto/DBD/DB2/Constants/Constants.so chmod 755 ../blib/arch/auto/DBD/DB2/Constants/Constants.so cp Constants.bs ../blib/arch/auto/DBD/DB2/Constants/Constants.bs chmod 644 ../blib/arch/auto/DBD/DB2/Constants/Constants.bs make[1]: Leaving directory `/home/lijumathew/lperl/perlsrc/DBD-DB2-1.78/Constants' gcc -c -I"/db2/db2tf1/sqllib/include" -I"/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI" -I"/usr/lib/perl5/5.8.5/i386-linux-thread-multi/auto/DBI" -I"/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/auto/DBI" -I"/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI" -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"1.78\" -DXS_VERSION=\"1.78\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" DB2.c In file included from DB2.h:22, from DB2.xs:7: dbdimp.h:10:22: dbivport.h: No such file or directory make: *** [DB2.o] Error 1 How do we fix this? Do we need root access to resolve this?

    Read the article

  • DBI::DBD package not getting installed for Perl?

    - by Liju Mathew
    Hi, We are using a Perl utility to dump data from DB2 database. We installed DBI package and it is asking for DBD package also. We dont have root access and when we try to install DBD package we are getting the following error. ERROR BUILDING DB2.pm [lijumathew@intblade03 DBD-DB2-1.78]$ make make[1]: Entering directory '/home/lijumathew/lperl/perlsrc/DBD-DB2-1.78/Constants' gcc -c -I"/db2/db2tf1/sqllib/include" -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"1.78\" -DXS_VERSION=\"1.78\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" Constants.c Running Mkbootstrap for DBD::DB2::Constants () chmod 644 Constants.bs rm -f ../blib/arch/auto/DBD/DB2/Constants/Constants.so gcc -shared -L/usr/local/lib Constants.o -o ../blib/arch/auto/DBD/DB2/Constants/Constants.so chmod 755 ../blib/arch/auto/DBD/DB2/Constants/Constants.so cp Constants.bs ../blib/arch/auto/DBD/DB2/Constants/Constants.bs chmod 644 ../blib/arch/auto/DBD/DB2/Constants/Constants.bs make[1]: Leaving directory `/home/lijumathew/lperl/perlsrc/DBD-DB2-1.78/Constants' gcc -c -I"/db2/db2tf1/sqllib/include" -I"/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI" -I"/usr/lib/perl5/5.8.5/i386-linux-thread-multi/auto/DBI" -I"/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/auto/DBI" -I"/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI" -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"1.78\" -DXS_VERSION=\"1.78\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" DB2.c In file included from DB2.h:22, from DB2.xs:7: dbdimp.h:10:22: dbivport.h: No such file or directory make: *** [DB2.o] Error 1 How to fix this? Do we need root access to resolve this? Appreciate the help in advance. Thanks, Mathew Liju

    Read the article

  • floating constants in C

    - by Daziplqa
    Hi floks, I have a question concerning floating constants in C. In Java, the default type of floating point constants in double, so the following will causes a compilation error in java: float f = 100.0; // we either need to uses type case operator or put f at the end of the number constant. This is because the default floating-point constants are of type double and casting from double to float without type cast operator is an error, so we need either add a type case operator or put f at the end of the number. So, Why in C this doesn't produce an error, Is it because the default floating-point constants are of type float, or because the compiler do an implicit down-cast conversion (that doesn't requires type case operator in C)????

    Read the article

  • C++ Thread level constants

    - by Gokul
    Is there a way by which we can simulate thread level constants in C++? For example, if i have to make a call to template functions, then i need to mention the constants as template level parameters? I can use static const variables for template metaprogramming, but they are process level constants. I know, i am asking a question with a high probability of 'No'. Just thought of asking this to capitalize on the very rare probability :)) Thanks, Gokul.

    Read the article

  • PHP constants declaration based on condition

    - by CM
    I am using one separate file for all constants of my PHP application. class constants { const USERNAME = 'abc'; ........ ........ } For lets say USERNAME constant, value can be either xyz or abc based on file exists check. if xyz file exists USERNAME value would be xyz. How can I do this check in my constants class? Thanks in advance.

    Read the article

  • C# using consts in static classes

    - by NickLarsen
    I was plugging away on an open source project this past weekend when I ran into a bit of code that confused me to look up the usage in the C# specification. The code in questions is as follows: internal static class SomeStaticClass { private const int CommonlyUsedValue = 42; internal static string UseCommonlyUsedValue(...) { // some code value = CommonlyUsedValue + ...; return value.ToString(); } } I was caught off guard because this appears to be a non static field being used by a static function which some how compiled just fine in a static class! The specification states (§10.4): A constant-declaration may include a set of attributes (§17), a new modifier (§10.3.4), and a valid combination of the four access modifiers (§10.3.5). The attributes and modifiers apply to all of the members declared by the constant-declaration. Even though constants are considered static members, a constant-declaration neither requires nor allows a static modifier. It is an error for the same modifier to appear multiple times in a constant declaration. So now it makes a little more sense because constants are considered static members, but the rest of the sentence is a bit surprising to me. Why is it that a constant-declaration neither requires nor allows a static modifier? Admittedly I did not know the spec well enough for this to immediately make sense in the first place, but why was the decision made to not force constants to use the static modifier if they are considered constants? Looking at the last sentence in that paragraph, I cannot figure out if it is regarding the previous statement directly and there is some implicit static modifier on constants to begin with, or if it stands on its own as another rule for constants. Can anyone help me clear this up?

    Read the article

  • How to have abstract and overriding constants in C# ?

    - by Chris
    Hi all, My code below won't compile. What am i doing wrong? I'm basically trying to have a public constant that is overridden in the base class. public abstract class MyBaseClass { public abstract const string bank = "???"; } public class SomeBankClass : MyBaseClass { public override const string bank = "Some Bank"; } Thanks as always for being so helpful!

    Read the article

  • [PHP] Associating a Function to Fire on session_start()?

    - by user317808
    Hi, I've searched the web but haven't been able to find a solution to the following challenge: I'd like to somehow associate a function that executes when session_start is called independent of the page session_start is called in. The function is intended to restore constants I've stored in $_SESSION using get_defined_constants() so that they're available again to any PHP page. This seems so straightforward to me but I'm pretty sure the PHP Session extension doesn't support the registration of user-defined events. I was wondering if anyone might have insight into this issue so I can either figure out the solution or stop trying. Ideally, I'd like to just register the function at run-time like so: $constants = get_defined_constants(); $_SESSION["constants"] = $constants["user"]; function event_handler () { foreach ($_SESSION["constants"] as $key => $value) { define($key, $value); } } register_handler("session_start", "event_handler"); So in any webpage, I could just go: session_start(); and all my constants would be available again. Any help would be greatly appreciated.

    Read the article

  • Singletons and constants

    - by devoured elysium
    I am making a program which makes use of a couple of constants. At first, each time I needed to use a constant, I'd define it as //C# private static readonly int MyConstant = xxx; //Java private static final int MyConstant = xxx; in the class where I'd need it. After some time, I started to realise that some constants would be needed in more than one class. At this time, I had 3 choises: To define them in the different classes that needed it. This leads to repetition. If by some reason later I need to change one of them, I'd have to check in all classes to replace them everywhere. To define a static class/singleton with all the constants as public. If I needed a constant X in ClassA, ClassB and ClassC, I could just define it in ClassA as public, and then have ClassB and ClassC refer to them. This solution doesn't seem that good to me as it introduces even more dependencies as the classes already have between them. I ended up implementing my code with the second option. Is that the best alternative? I feel I am probably missing some other better alternative. What worries me about using the singleton here is that it is nowhere clear to a user of the class that this class is using the singleton. Maybe I could create a ConstantsClass that held all the constants needed and then I'd pass it in the constructor to the classes that'd need it? Thanks

    Read the article

  • C non-trivial constants

    - by user525869
    I want to make several constants in C with #define to speed up computation. Two of them are not simply trivial numbers, where one is a right shift, the other is a power. math.h in C gives the function pow() for doubles, whereas I need powers for integers, so I wrote my own function, ipow, so I wouldn't need to be casting everytime. My question is this: One of the #define constants I want to make is a power, say ipow(M, T), where M and T were also #define constants. ipow is a function in the actual code, so this actually seems to slows things down when I run the code (is it running ipow everytime the constant is mentioned?). However, when I ues the built in pow function and just do (int)pow(M,T), the code is sped up. I'm confused as to why this is, since the ipow and pow functions are just as fast. On a more general note, can I define constants using #define using functions inside the actual code? The above example has me confused on whether this speeds things up or actually slows things down.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >