Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 118/391 | < Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >

  • C++ Types Impossible to Name

    - by Kirakun
    While reading Wikipedia's page on decltype, I was curious about the statement, Its [decltype's] primary intended use is in generic programming, where it is often difficult, or even impossible, to name types that depend on template parameters. While I can understand the difficulty part of that statement, what is an example where there is a need to name a type that cannot be named under C++03? EDIT: My point is that since everything in C++ has a declaration of types. Why would there ever be a case where it is impossible to name a type? Furthermore, aren't trait classes designed to yield type informations? Could trait classes be an alternative to decltype?

    Read the article

  • NoMethodError when trying to invoke helper method from Rails controller

    - by John Topley
    I'm getting a NoMethodError when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the helper class method with the :all symbol as shown below: class ApplicationController < ActionController::Base helper :all . . end My understanding is that this should make all of my controller classes automatically include all of the helper modules within the app/helpers directory, therefore mixing in all of the methods into the controllers. Is this correct? If I explicitly include the helper module within the controller then everything works correctly.

    Read the article

  • IDisposable, does it really matter

    - by adrianm
    Coming from C/C++ a long time ago I still have a habit of ensuring that all resources are cleaned up correctly. I always ensure Dispose is called on IDisposable classes and implement Dispose patterns in my classes containing disposable objects. However, in my environment I'm more or less the only one doing this. Others just don't understand what I'm doing and think my code is more difficult to understand. They just create database connections, open streams etc without calling Close or Dispose. Sometimes they set a local or member variable to "Nothing" at the end of a method (guess their background). My problem is that their code works just as well as mine. Code that over time creates thousands of database connection objects just works. So, ignoring any arguments about code correctness, following guidelines etc, does IDiposable really matter? Has anyone actually ran out of resources from not Disposing objects?

    Read the article

  • Setting new class variables inside a module

    - by Sean McCleary
    I have a plugin I have been working on that adds publishing to ActiveRecord classes. I extend my classes with my publisher like so: class Note < ActiveRecord::Base # ... publishable :related_attributes => [:taggings] end My publisher is structured like: module Publisher def self.included(base) base.send(:extend, ClassMethods) @@publishing_options = [] # does not seem to be available end module ClassMethods def publishable options={} include InstanceMethods @@publishing_options = options # does not work as class_variable_set is a private method # self.class_variable_set(:@@publishing_options, options) # results in: uninitialized class variable @@publishing_options in Publisher::ClassMethods puts "@@publishing_options: #{@@publishing_options.inspect}" # ... end # ... end module InstanceMethods # results in: uninitialized class variable @@publishing_options in Publisher::InstanceMethods def related_attributes @@publishing_options[:related_attributes] end # ... end end Any ideas on how to pass options to publishable and have them available as a class variable?

    Read the article

  • Rails: Creating subfolders in model?

    - by keruilin
    I'm going to have a ton of subclasses, so want to organize them under a subfolder called stream. I added the following line to the environment.rb so that all classes in the subfolder would be loaded: Rails::Initializer.run do |config| ... config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? } ... end I thought this would solve the issue in which by convention the model class is namespaced into an according module. However, when I try to call one of the classes called stream in the stream folder, I get the following error: NoMethodError: undefined method `new' for Stream:Module from (irb):28 from /usr/local/bin/irb:12:in `<main>' Here's the model for the parent and one child: class Stream end class EventStream < Stream end Any idea what the issue is?

    Read the article

  • Java - Confused by the one class per file rule

    - by Mark
    The one class per file rule in Java has me a bit confused. I writing an Android app and trying to implement the accepted answer to this question: Common class for AsyncTask in Android? which calls for an interface definition which class A implements and class B accepts as an argument to its constructor. So I need an A.java and a B.java, but where does the interface go? Does it need a separate java file itself? Do I have to define it inside both A and B? If not how to import it? Also I will have about 10 different AsyncTask classes, but I don't want to bother creating a new file for each one. What would you recommend? Is there a way to put all 10 classes in one file? Or should I create a big if/then block inside the class and pass an argument telling it which of the 10 different tasks I want it to do?

    Read the article

  • MySQL customized join query using multiple tables

    - by itgeek
    I am searching one student from each class from one group. There are different class groups and every group has different classes and every class has multiple students. See below: Group1 --> Class1, Class2 etc Class1 --> GreenStudent1, GreenStudent2 etc Class2 --> RedStudent1, RedStudent2 etc ------------------------------------------------------ SELECT table1.id, table1.myname, table1.marks table2.studentid, table2.studentname FROM table1 INNER JOIN table3 ON table1.oldid = table3.id INNER JOIN table2 ON table2.studentid = table3.newid WHERE table1.classgroup = 'SCI79' GROUP BY table1.oldid ORDER BY table1.marks DESC There are different joins applied in the query. Above mentioned query giving me correct results but I need little modification in it. Current query returning me one student from each class. What I need? I need one student from each class but only that student who has MAXIMUM table1.marks So I should have one student from each class who has maximum number in their relevant classes. Can anyone suggest some solution or rewrite this query? Thanks :)

    Read the article

  • What is the order of loading the CSS files in a HTML page ?

    - by Purushotham
    I want to know the order of loading the CSS files in a HTML page. My actual requirement is like this: I have more than 10 CSS files in my application. I am importing some 3 to 4 CSS files in each HTML page. The problem is I have duplicate classes that defined in some CSS files. That means I override some of the CSS classes in the CSS files. In some pages it behaves correctly. In some pages it behaves wrongly. I have inline styles defined for some of the DIVs in HTML page also. I am keeping CSS class for that DIVs also. Can anyone know which one will take higher priority or which one loads first ?

    Read the article

  • Save objects to a database?

    - by Eric
    So far in my .Net coding adventures I've only had a need to save information to files. So I've used XmlSerializer and DataContractSerializer to serialize attributed classes to XML files. My next project, however, requires that I save and retrieve information from a SQL server database. I'm wondering what my options are for doing this. The current version of the app, which was not created by me, uses a lot of hard coded SQL commands. But now I'm trying to avoid doing anything where I have to read or write individual fields to or from the database or objects. I especially want to avoid a lot of hard coded SQL in my code. I like how the serializer classes just figure out how to read and write XML files based on the attributes and or public properties of the class. Is there something similar for a database rather then XML?

    Read the article

  • Is there a transformation matrix that can scale the x and/or y axis logarithmically?

    - by Dave M
    I'm using .net WPF geometry classes to graph waveforms. I've been using the matrix transformations to convert from the screen coordinate space to my coordinate space for the waveform. Everything works great and it's really simple to keep track of my window and scaling, etc. I can even use the inverse transform to calculate the mouse position in terms of the coordinate space. I use the built in Scaling and Translation classes and then a custom matrix to do the y-axis flipping (there's not a prefab matrix for flipping). I want to be able to graph these waveforms on a log scale as well (either x axis or y axis or both), but I'm not sure if this is even possible to do with a matrix transformation. Does anyone know if this is possible, and if it is, what is the matrix?

    Read the article

  • So I dynamically load a jar at runtime how do I use it?

    - by justinhj
    So question 194698 shows how to load a jar file at runtime and you can load individual named classes and get a Class object. Now my problem is I want to be able to cast those Classes to the types they really are, but I can't because I can't use an import since the whole point is to load it at runtime rather than compile time. It seems like the way to go is to use reflection to discover the functions and field names, but that seems brittle since the API in the jar files could change and the code won't break until it is run. Is there a better way?

    Read the article

  • Composite pattern in C++ problem

    - by annouk
    Hello! I have to work with an application in C++ similar to a phone book: the class Agenda with an STL list of Contacts.Regarding the contacts hierarchy,there is a base-class named Contact(an abstract one),and the derived classes Friend and Acquaintance(the types of contact). These classes have,for instance, a virtual method called getName,which returns the name of the contact. Now I must implement the Composite pattern by adding another type of contact,Company(being derived from Contact),which also contains a collection of Contacts(an STL list as well),that can be either of the "leaf" type(Friends or Acquaintances),or they can be Companies as well. Therefore,Company is the Compound type. The question is: how and where can I implement an STL find_if to search the contact with a given name(via getName function or suggest me smth else) both among the "leaf"-type Contact and inside the Company collection? In other words,how do I traverse the tree in order to find possible matches there too,using an uniform function definition? I hope I was pretty clear...

    Read the article

  • Get information from a higher class?

    - by Clint Davis
    I don't know really how to word the question so please bear with me... I have 3 classes: Server, Database, and Table. Each class has a "Name" property. How I want it to work is that each server can have multiple databases and each database can have multiple tables. So in the Server class I have this property. Private _databases As List(Of Database) Public Property Databases() As List(Of Database) Get Return _databases End Get Set(ByVal value As List(Of Database)) _databases = value End Set End Property And I have something similar in the Database class for the tables. This works fine now because I can do something like this to get all the databases in the server. For Each db In s.Databases 's being the server object Debug.Print(db.Name) Next I would like to expand these classes. I want the server class to handle all the connection information and I would like the other classes to use the server class's connection information in them. For example, I setup a server class and set the connection string to the server. Then I want the database class to use serverclass.connectionstring property to connect to the server and get a list of all the databases. But I want to keep that code in the database class. How can I do this? I've attached some code of what I want to do. Public Class Server Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _databases As List(Of Database) Public Property Databases() As List(Of Database) Get Return _databases End Get Set(ByVal value As List(Of Database)) _databases = value End Set End Property End Class '-----New class Public Class Database Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _tables As List(Of Table) Public Property Tables() As List(Of Table) Get Return _tables End Get Set(ByVal value As List(Of Table)) _tables = value End Set End Property 'This is where I need help! Private Sub LoadTables () dim connectionstring as string = server.connectionstring 'Possible? 'Do database stuff End Class Thanks for reading!

    Read the article

  • Limiting what a .net plugin can access

    - by David Hogue
    I have a web application that can load plugins through reflection. It currently uses Assembly.LoadFrom() and Activator.CreateInstance() to get this done. Right now plugins are loaded into the same AppDomain and have access to anything in my app and anything my app could access. What I'm looking for is a way to limit what classes and methods the plugin can access for security purposes. I want to have all of my classes and methods throw an exception when called unless they are whitelisted. I'd be whitelisting basically all the functions in an API class and a few data transfer objects. I also don't want the plugin to be able to access the filesystem or the database on it's own. I think I can do that with trust levels in a separate AppDomain though. Does anyone out there have any good ideas or resources? Is this something that could be done with Code Access Security or the new Security-Transparent Code features in .net 4?

    Read the article

  • What is the Quicker / More Efficient CSS styling

    - by Sessa
    I have been curious as to which method of CSS styling is quicker (rendering wise) and then from simply a best practices perspective which method makes more sense (pretty subjective I would say?). I can create base classes like: .rounded-corners-5 { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } OR I can do the other method of applying styles to multiple IDs/Classes: #box1, #header, #container, .titles { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }

    Read the article

  • Avoiding sub-type selection in view code

    - by John Donoghue
    Hi, I have some code where the model contains some classes like (vb.net pseudocode, but could be any OO language): Enum AttributeType Boolean Date String End Enum MustInherit Class Attibute Must Override Function Type As AttributeType End Class Class BooleanAttribute: Attribute Function Type As AttributeType Return AttributeType.Boolean End Function End Class And the view contains some code like: Select Case AttributeType Case Boolean //Display checkbox control Case Date //Display date picker control Case String //Display textbox control End Select I don't really like the code in the view, for the hopefully obvious reasons (what happens when I get a new attribute type etc). My question is, how should I replace it? I could easily add a method to the concrete classes, but that pollutes the model with UI stuff so that's a horrible idea. I could move the select into a factory, but that seems to be just hiding the problem. Can anybody advise a better approach?

    Read the article

  • Can pydoc/help() hide the documentation for inherited class methods and attributes?

    - by EOL
    When declaring a class that inherits from a specific class: class C(dict): added_attribute = 0 the documentation for class C lists all the methods of dict (either through help(C) or pydoc). Is there a way to hide the inherited methods from the automatically generated documentation (the documentation string can refer to the base class, for non-overwritten methods)? or is it impossible? This would be useful: pydoc lists the functions defined in a module after its classes. Thus, when the classes have a very long documentation, a lot of less than useful information is printed before the new functions provided by the module are presented, which makes the documentation harder to exploit (you have to skip all the documentation for the inherited methods until you reach something specific to the module being documented).

    Read the article

  • C++ code visualization

    - by bobobobo
    A sort of follow up/related question to this. I'm trying to get a grip on a large code base that has hundreds and hundreds of classes and a large inheritance hierarchy. I want to be able to see the "main veins" of the inheritance hierarchy at a glance - not all the "peripheral" classes that only do some very specific / specialized thing. Visual Studio's "View Class Diagram" makes something that looks like a train and its sprawled horizontally across the screen and isn't very organized. You can't grok it easily. I've just tried doxygen and graphviz but the results are .. somewhat similar to Visual Studio. I'm getting sweet looking call graphs but again too much detail for what I'm trying to get. I need a quick way to generate the inheritance hierarchy, in some kind of collapsible view.

    Read the article

  • how to use ByteArrayOutputStream and DataOutputStream simultaneously (Java)

    - by Manuel
    Hi! I'm having quite a problem here, and I think it is because I don't understand very much how I should use the API provided by Java. I need to write an int and a byte[] into a byte[] I thought of using a DataOutputStream to solve the data writing with writeInt(int i) and write(byte[] b), and to be able to put that into a byte array, I should use ByteArrayOutputStream's method toByteArray(). I understand that this classes use the Wrapper pattern, so I had two options: DataOutputStream w = new DataOutputStream(new ByteArrayOutputStream()); or ByteArrayOutputStream w = new ByteArrayOutputStream(new DataOutputStream()); but in both cases, I "loose" a method. in the first case, I can't access the toByteArray method, and in the second, I can't access the writeInt method. How should I use this classes together?

    Read the article

  • Generate service layer with Hibernate

    - by gmate
    Hi all! I generate *.hbm.xml mapping files and *.java file from the DB schema, with Hibernate tools. My question is, that is there any option, to generate service classes also? These are the classes where I implement the store(), find(), delete(), etc... methods. I know that for C# there are many solutions to generate almost everything. I'm looking for the same, but with Hibernate. Is there any? Thanks for every reply in advance!

    Read the article

  • Can anybody explain the working of following code...?

    - by Siddhi
    Can anybody explain the working of following code...? interface myInterface{} public class Main { public static void main(String[] args) { System.out.println(new myInterface(){public String toString(){return "myInterfacetoString";}}); System.out.println(new myInterface(){public String myFunction(){return "myInterfacemyFunction";}}); } } Output is... myInterfacetoString primitivedemo.Main$2@9304b1 All answers saying that myInterface in println() statement is anonymous class. But as I already declared it as an interface, why does it allow me to create anonymous class of same name....? again...if these are anonymous classes then class main should allow me to give any name to these anonymous classes..But if try to do so..I'm getting compilation error

    Read the article

  • Determining whether a class implements a generic list in a T4 template

    - by James Hollingworth
    I'm writing a T4 template which loads some classes from an assembly, does some analysis of the classes and then generates some code. One particular bit of analysis I need to do is to determine whether the class implements a generic list. I can do this pretty simply in C#, e.g. public class Foo : List<string> { } var t = typeof(Foo); if (t.BaseType != null && t.BaseType.IsGenericType && t.BaseType.GetGenericTypeDefinition() == typeof(List<>))) Console.WriteLine("Win"); However T4 templates use the FXCop introspection engine and so you do not have access to the .net reflection API. I've spent the past couple of hours in Reflector but still can't figure it out. Does anyone have any clues about how to do this?

    Read the article

  • Should I share UI for objects that use common fields?

    - by wb
    I have a parent class that holds all of the fields that are common between all device types. From that, I have a few derived classes that each hold their unique fields. Say I have device type "Switch" and "Transformer". Both derived classes only have 2-3 of their own unique fields. When doing the UI design (windows forms) in this case. Should I create two separate forms for each device type or create a user control with all fields that are shared among all devices? Thank you.

    Read the article

  • .NET project: unified wrapper for object databases.

    - by Steve
    I am considering doing a project which would provide unified API and tools (import/export, etc.) for object databases (e.g. Caché, Objectivity) for .NET. It would provide: schema generation from CLR classes, generation of C# classes from given OODBMs schema, API for deleting, creating and updating objects, Linq provider, API for calling object's methods on DB server, some of OODBMs provide some kind of SQL support, so API for this, providers for Caché and Objectivity in first phase. Does any project which implements any of above exist? Can this be achieved with NHibernate dialects? or are OODBMs so different than RDBMs that it worth doing separate framework for them?

    Read the article

  • Program output to file in Java (and reading it again)

    - by Cohagen
    I have a large main method in an IO class which creates objects from four different classes in my program (which all use one another to some extent). My main method takes all info in using a scanner, from the console window, and uses this info to call the constructors and methods in the other classes. As this is my first full program in Java I have been focussed on making the main method work via the console, without properly considering file input and output. I cannot see an easy way of making that work now. Ideally what I require is some way of writing everything I input to the console while running the main method to a file, in a format that can be read again and inputed back through the main method? I have refrained from posting the main method as it is 250+ lines long, but will post any relevant parts of it if required. Any help appreciated

    Read the article

< Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >