Search Results

Search found 889 results on 36 pages for 'convention'.

Page 24/36 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Why do Java source files go into a directory structure?

    - by bdhar
    Suppose that I am creating a Java project with the following classes com.bharani.ClassOne com.bharani.ClassTwo com.bharani.helper.HelperOne com.bharani.helper.support.HelperTwo with files put immediately under the folder 'src' src/ClassOne.java src/ClassTwo.java src/HelperOne.java src/HelperTwo.java and compile them using the command $ javac src/*.java -d classes (assuming that classes directory exists) The compiler compiles these files and put the class files in appropriate sub-directories inside the 'classes' directory like this classes/com/bharani/ClassOne.class classes/com/bharani/ClassTwo.class classes/com/bharani/helper/HelperOne.class classes/com/bharani/helper/support/HelperTwo.class Because the spec mandates that the classes should go inside appropriate directory structure. Fine. My question is this: When I use an IDE such as Eclipse or NetBeans, they create the directory structure for the source code directory ('src' directory here) also. Why is that? Is it mandatory? Or, is it just a convention? Thanks.

    Read the article

  • Opinions sought on the best way to organise classes in PHP

    - by jax
    I am pretty much set on using the Java package naming convention of com.website.app.whatever but am unsure about the best way of doing this in PHP. Option 1: Create a directory structure com/ mysite/ myapp/ encryption/ PublicKeyGenerator.class.php Cipher.class.php Xml/ XmlHelper.class.php XmlResponse.class.php Now this is how Java does it, it uses the folders to organize the heirarchy. This is however a little clumsy in PHP because there is no native support for it and when you move things around you break all includes. Option 2 Name classes using a periods for the package, therefore sames are just like in Java but can all be in the same directory making __autoload a breeze. classes/ com.mysite.myapp.encription.PublicKeyGenerator.class.php com.mysite.myapp.encription.Cipher.class.php com.mysite.myapp.xml.XmlHelper.class.php com.mysite.myapp.xml.XmlResponse.class.php The only real disadvantage here is that all the classes are in a single folder which might be confusing for large projects. Opinions sought, which is the best or are there other even better options?

    Read the article

  • Rails STI validation inheritance

    - by KARASZI István
    Dear Rails users! I have STI models in my Rails application. The ancestor model has validations with the validates_... methods which are working fine. But I have custom validations as well, and I would like to add more different custom validations in the descendants. These custom validations would depend on the class. If I write class DescendantA < Ancestor protected def validate # ... end end It simply overwrites the original validations. Is there a convention to do this in Rails?

    Read the article

  • Model in sub-directory via app_label?

    - by prometheus
    In order to place my models in sub-folders I tried to use the app_label Meta field as described here. My directory structure looks like this: project apps foo models _init_.py bar_model.py In bar_model.py I define my Model like this: from django.db import models class SomeModel(models.Model): field = models.TextField() class Meta: app_label = "foo" I can successfully import the model like so: from apps.foo.models.bar_model import SomeModel However, running: ./manage.py syncdb does not create the table for the model. In verbose mode I do see, however, that the app "foo" is properly recognized (it's in INSTALLED_APPS in settings.py). Moving the model to models.py under foo does work. Is there some specific convention not documented with app_label or with the whole mechanism that prevents this model structure from being recognized by syncdb?

    Read the article

  • If free() knows the length of my array, why can't I ask for it in my own code?

    - by Chris Cooper
    I know that it's a common convention to pass the length of dynamically allocated arrays to functions that manipulate them: void initializeAndFree(int* anArray, int length); int main(){ int arrayLength = 0; scanf("%d", &arrayLength); int* myArray = (int*)malloc(sizeof(int)*arrayLength); initializeAndFree(myArray, arrayLength); } void initializeAndFree(int* anArray, int length){ int i = 0; for (i = 0; i < length; i++) { anArray[i] = 0; } free(anArray); } but if there's no way for me to get the length of the allocated memory from a pointer, how does free() "automagically" know what to deallocate? Why can't I get in on the magic, as a C programmer? Where does free() get its free (har-har) knowledge from?

    Read the article

  • How can I ignore properties of a component using Fluent Nhibernate's AutoPersistenceModel?

    - by Jason
    I am using Fluent NHibernate AutoMappings to map my entities, including a few component objects. One of the component objects includes a property like the following: public string Value { set _value = value; } This causes an NHibernate.PropertyNotFoundException: "Could not find a getter for property 'Value'..." I want to ignore this property. I tried creating an IAutoMappingOverride for the component class but I couldn't use AutoMapping<.IgnoreProperty(x = x.Value) for the same reason. "The property or indexer 'MyComponent.Value' cannot be used in this context because it lacks the get accessor" I've also looked at IComponentConvention but can't see anyway of altering the mappings with this convention. Any help would be appreciated... Thanks

    Read the article

  • Python 3.0 - Dynamic Class Instance Naming

    - by Jon
    I want to use a while loop to initialize class objects with a simple incremented naming convention. The goal is to be able to scale the number of class objects at will and have the program generate the names automatically. (ex. h1...h100...h1000...) Each h1,h2,h3... being its own instance. Here is my first attempt... have been unable to find a good example. class Korker(object): def __init__(self,ident,roo): self.ident = ident self.roo = roo b = 1 hwinit = 'h' hwstart = 0 while b <= 10: showit = 'h' + str(b) print(showit) #showit seems to generate just fine as demonstrated by print str(showit) == Korker("test",2) #this is the line that fails b += 1 The errors I get range from a string error to a cannot use function type error.... Any help would be greatly appreciated.

    Read the article

  • What is the most efficient way to list all of the files in a directory (including sub-directories)?

    - by prometheus
    I am writing a servlet which will examine a directory on the server (external to the web container), and recursively search for certain files (by certain files, I mean files that are of a certain extension as well as a certain naming convention). Once these files are found, the servlet responds with a long list of all of the found files (including the full path to the files). My problem is that there are so many files and directories that my servlet goes extremely slow. I was wondering if there was a best practice or existing servlet for this type of problem? Would it be more efficient to simply compile the entire list of files and do the filtering via js/jquery on the client side?

    Read the article

  • ASP.NET MVC / Linq-to-SQL classes: Can I get it to infer readable display names?

    - by Gary McGill
    If I have a table Orders with fields CustomerID, OrderID and OrderDate, then the "Linq-to-SQL classes" generated class will be called Orders, with members called CustomerID, OrderID and OrderDate. So far so good. However, if I then do Html.LabelFor(m => m.OrderDate) then the generated text will be "OrderDate" instead of "Order Date". I tried using Order_Date as the field name, but that didn't work. Is there any way to get it to infer a better display name? [I know that I can use data annotations to specify the display name explicitly, but I really don't want to do that for all my classes/members - I just want it to work by convention.]

    Read the article

  • plot only x and y axis (no box) in ggplot2

    - by Tyler Rinker
    The convention of some journals is to show only the x and y axis in a plot not a box around the entire plot area. How can I achieve this in ggplot2? I tried theme_minimal_cb_L from HERE but it seems to erase the entire box around the plot (does not leave the x and y axis) as seen here: Here's the code I'm using: dat <- structure(list(x = c(0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3), y1 = c(34, 30, 26, 23, 21, 19, 17, 16, 15, 13, 12, 12, 11), y2 = c(45, 39, 34, 31, 28, 25, 23, 21, 19, 17, 16, 15, 14)), .Names = c("x", "y1", "y2"), row.names = c(NA, -13L), class = "data.frame") library(reshape2); library(ggplot2) dat2 <- melt(dat, id='x') theme_minimal_cb_L <- function (base_size = 12, base_family = "", ...){ modifyList (theme_minimal (base_size = base_size, base_family = base_family), list (axis.line = element_line (colour = "black"))) } ggplot(data=dat2, aes(x=x, y=value, color=variable)) + geom_point(size=3) + geom_line(size=.5) + theme_minimal_cb_L()

    Read the article

  • Doctrine 1.2 Column Naming Conventions for Many To Many Relationships

    - by Alan Storm
    I'm working with an existing database schema, and trying to setup two Doctrine models with a Many to Many relationship, as described in this document When creating tables from scratch, I have no trouble getting this working. However, the existing join tables use a different naming convention that what's described in the Doctrine document. Specifically Table 1 -------------------------------------------------- table_1_id ....other columns.... Table 2 -------------------------------------------------- table_2_id ....other columns.... Join Table -------------------------------------------------- fktable1_id fktable_2_id Basically, the previous developers prefaced all forign keys with an fk. From the examples I've seen and some brief experimenting with code, it appears that Doctrine 1.2 requires that the join table use the same column names as the tables it's joining in Is my assumption correct? If so, has the situation changed in Doctrine 2? If the answers to either of the above are true, how do you configure the models so that all the columns "line up"

    Read the article

  • Problem invoking C DLL in C#

    - by CristiC
    I'm currently trying to invoke a method made in C from C# C code looks like this: extern "C" int addSum(int a, int b) { return a*b; } extern "C" int getCount() { return 12; } and C# code looks like this: [DllImport("mydll.dll", SetLastError=true)] private static extern int addSum(IntPtr a, IntPtr b); [DllImport("mydll.dll", SetLastError = true)] private static extern int getCount(); public static int mySum(int a, int b) { return suma(a, b); } public static int getMyCount() { return getCount(); } The code returns the right values but i'm getting the following error: addSum' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. Any sugestion regarding this issue ? Thanks

    Read the article

  • JSF (and friends) tags vs. traditional html tags

    - by H3wh0s33ks
    So this question came up today and I didn't have a specific or scientific answer. What are the costs associated with using jsf (or tomahawk, faclets, etc., etc.) tags in place of traditional html tags. My gut reaction is that you should use jsf tags in situations where you need the additional functionality they provide, and use traditional tags when you don't. Also I feel like jsf tags would require more resources (since the server has to take them and rerender them as html anyways) than html. Does anybody know what the cost actually is (as far as time and memory)? Also useful information is what is the convention that is in use, pure jsf or a mixture of the two?

    Read the article

  • AutoMapping Custom Collections with FluentNHibernate

    - by ScottBelchak
    I am retrofitting a very large application to use NHibernate as it's data access strategy. Everything is going well with AutoMapping. Luckily when the domain layer was built, we used a code generator. The main issue that I am running into now is that every collection is hidden behind a custom class that derives from List<. For example public class League { public OwnerList owners {get;set;} } public class OwnerList : AppList<Owner> { } public class AppList<T> : List<T> { } What kind of Convention do I have to write to get this done?

    Read the article

  • Are upper bounds of indexed ranges always assumed to be exclusive?

    - by polygenelubricants
    So in Java, whenever an indexed range is given, the upper bound is almost always exclusive. From java.lang.String: substring(int beginIndex, int endIndex) Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1 From java.util.Arrays: copyOfRange(T[] original, int from, int to) from - the initial index of the range to be copied, inclusive to - the final index of the range to be copied, exclusive. From java.util.BitSet: set(int fromIndex, int toIndex) fromIndex - index of the first bit to be set. toIndex - index after the last bit to be set. As you can see, it does look like Java tries to make it a consistent convention that upper bounds are exclusive. My questions are: Is this the official authoritative recommendation? Are there notable violations that we should be wary of? Is there a name for this system? (ala "0-based" vs "1-based")

    Read the article

  • ok.. what's with this 'var' thing in C#?? [closed]

    - by KevinDeus
    Possible Duplicate: Use of var keyword in C# I have ReSharper, which is a pretty good tool to remind me of some good programming practices.. for example it always recommends that I use the most narrowed convention I can use when passing variables to functions (such as recommending IEnumerable instead of List when I fail to use any of List's specific function. Awesome. However, one of its new behaviors (for C# 4.0) is to remind me at every opportunity to use 'var' when declaring variables. Now I know that there are some valid uses of 'var', but do I really want to use it all the time? I'm sure that ReSharper has a reason for this, but I can't figure it out.. for me it makes the code less readable..

    Read the article

  • Building Admin Areas in Rails - General Questions

    - by Carb
    What is the typical format/structure for creating an administrative area in a Rails application? Specifically I am stumped in the vicinity of these topics: How do you deal with situations where a model's resources are available to both the public and the Admin? i.e. A User model where anyone can create users, login, etc but only the admin can view users, delete/update them, etc. What is the proper convention for routing? How does one structure controllers? Are duplicate controllers considered OK? i.e. An admin version and the non-admin version? Thank you!

    Read the article

  • Can layouts be chosen by Grails controllers?

    - by maerics
    I'm building a CMS as a learning exercise in Grails and would like to give content managers the ability to choose between different HTML page structures (e.g. 2 column, 3 column, etc). Grails Layouts seem like a logical choice but is it possible for a Grails controller to explicitly name which layout will be used for rendering? Ideally there would be a layout option to the render method, per Ruby on Rails but I don't see anything like it. It seems like it might be possible using the applyLayout method by passing the name of the layout but this requires each GSP page to explicitly request layout (annoying overhead per-page) rather than using Layout by Convention. Any ideas?

    Read the article

  • How to extract messages to translate from a Play! application

    - by Martin
    I'm writing my first application using the Play! framework and I was wondering if there was a tool that could extract the messages that need translation from my views and controllers for me ? It is rather cumbersome to fill the conf/messages(.xx) file while I'm developing my app, but I'm afraid that if I don't do it as I go, I will never be able to completely translate my application afterwards. Such tools exist with other framework such as CakePHP for instance, and I think that it shouldn't be hard to write one by myself, but if there already is one... I was also wondering, what should I name the keys of the messages in my application ? Using gettext, it's not bad practice to directly type in the message in english as the key, but is it with the system that Play! uses (MessageFormat, right ?) ? Does anyone have an advice or naming convention (something like controller.action.describe_the_message maybe) ? Thank you for your advices !

    Read the article

  • XAML-based applications - Event Naming Conventions for C#

    - by user118190
    For event handling, I am starting to see many coders doing this: XButton.Click += OnXButtonClicked() ... void OnXButtonClicked() { ... } Where did this On_ convention come from? It just doesn't feel right in terms of methods. I am starting to see this as well and am wondering what others thought: XButton.Click += HandleXButtonClick() ... void HandleXButtonClick() { ... } When using intellisense, Visual Studio handles these like so: XButton.Click += XButton_Click; ... void XButton_Click(object sender, RoutedEventArgs e) { ... } I am seeking some advice on these naming conventions and would greatly appreciate some advice.

    Read the article

  • How do I add jars needed to compile a maven project if they were never built with a pom?

    - by JasonH
    I'm just starting with maven, coming from years of working with Ant. I'm trying a basic task now, building a simple project that requires some libraries from a vendor. I have the jars in src\main\resources\VENDORNAME. When I run mvn compile it fails on compilation saying the libraries don't exist. I can't seem to add these as dependencies because I don't know their version number and as they are proprietary I can't find them in ibiblio or elsewhere. Without these Jars I can't compile my classes. Is there a way to use jars that didn't follow Maven's convention? I might not understand maven correctly, so any guidance is welcome. Much appreciated for any responses.

    Read the article

  • Open generic interface types of open implementation don't equal interface type?

    - by George Mauer
    Here's a test that should, in my opinion be passing but is not. [TestMethod] public void can_get_open_generic_interface_off_of_implementor() { typeof(OpenGenericWithOpenService<>).GetInterfaces().First() .ShouldEqual(typeof(IGenericService<>)); } public interface IGenericService<T> { } public class OpenGenericWithOpenService<T> : IGenericService<T> { } Why does this not pass? Given Type t = typeof(OpenGenericWithOpenService<>) how do I get typeof(IGenericService<)? I'm generally curious, but if you're wondering what I'm doing, I'm writing a Structuremap convention that forwards all interfaces implemented by a class to the implementation (as a singleton).

    Read the article

  • Long/compound namespaces when using C++/CLI

    - by biozinc
    I'm working on a project where a mixture of C# (95%) and C++/CLI (5%) are used. The namespace naming convention I'm aiming for is the good old Company.Technology.Etc.. This works perfectly fine for C#. Now, can I carry this across to C++ classes? I read here that compound namespaces aren't supported in C++. Am I stuck with the clumsy namespace Company { namespace Technology { namespace Etc { ... } } } in order to stay consistent? Is it worth trying to stay consistent?

    Read the article

  • Strange difference between optimized/non optimized microsoft c++ code

    - by Anders Forsgren
    I have a c++ program with a method that looks something like this: int myMethod(int* arr1, int* arr2, int* index) { arr1--; arr2--; int val = arr1[*index]; int val2 = arr2[val]; doMoreThings(val); } With optimizations enabled (/O2) the first line where the first pointer is decremented is not executed. I assume the compiler believes that the arr1 array is not used since it thinks it can remove the decrement. Am I violating some convention in the above code? What could cause this behavior? It is a very old piece of f2c-translated code, the pointer decrement is due to the 1-based indexing of the original code.

    Read the article

  • How to deal with callback to your UIController after your UIController unloads?

    - by erotsppa
    Suppose your controller is a table view and one of the cells you are going off to do a length task (say download a thumbnail) to be viewed in the cell. Typically you would have the network call do a callback to your controller when it is done downloading. The callback can then reload the table or do some other form of UI update (hides a spinner etc). However, what if the controller is unloaded? Say the user navigated away from this controller and it got released? What happens? Will the callback still work despite the controller now not in memory? Also, if the callback operates on some objects (say the UITableView) what happens when the controller is deallocated? I suppose the controller can release all the objects and the callback would just be calling methods on nil to prevent crash. But is this the convention?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >