Search Results

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

Page 62/391 | < Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >

  • Why would one want to use the public constructors on Boolean and similar immutable classes?

    - by Robert J. Walker
    (For the purposes of this question, let us assume that one is intentionally not using auto(un)boxing, either because one is writing pre-Java 1.5 code, or because one feels that autounboxing makes it too easy to create NullPointerExceptions.) Take Boolean, for example. The documentation for the Boolean(boolean) constructor says: Note: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance. My question is, why would you ever want to get a new instance in the first place? It seems like things would be simpler if constructors like that were private. For example, if they were, you could write this with no danger (even if myBoolean were null): if (myBoolean == Boolean.TRUE) It'd be safe because all true Booleans would be references to Boolean.TRUE and all false Booleans would be references to Boolean.FALSE. But because the constructors are public, someone may have used them, which means that you have to write this instead: if (Boolean.TRUE.equals(myBoolean)) But where it really gets bad is when you want to check two Booleans for equality. Something like this: if (myBooleanA == myBooleanB) ...becomes this: if ( (myBooleanA == null && myBooleanB == null) || (myBooleanA == null && myBooleanA.equals(myBooleanB)) ) I can't think of any reason to have separate instances of these objects which is more compelling than not having to do the nonsense above. What say you?

    Read the article

  • Most proper way to use inherited classes with shared scopes in Mongo?

    - by Trip
    I have the TestVisual class that is inherited by the Game class : class TestVisual < Game include MongoMapper::Document end class Game include MongoMapper::Document belongs_to :maestra key :incorrect, Integer key :correct, Integer key :time_to_complete, Integer key :maestra_id, ObjectId timestamps! end As you can see it belongs to Maestra. So I can do Maestra.first.games But I can not to Maestra.first.test_visuals Since I'm working specifically with TestVisuals, that is ideally what I would like to pull. Is this possible with Mongo. If it isn't or if it isn't necessary, is there any other better way to reach the TestVisual object from Maestra and still have it inherit Game ?

    Read the article

  • Can a CSS class inherit one or more other classes?

    - by Joel Martinez
    I feel dumb for having been a web programmer for so long and not knowing the answer to this question, I actually hope it's possible and I just didn't know about rather than what I think is the answer (which is that it's not possible). My question is whether it is possible to make a CSS class that "inherits" from another CSS class (or more than one). For example, say we had: .something { display:inline } .else { background:red } What I'd like to do is something like this: .composite { .something; .else } where the ".composite" class would both display inline and have a red background

    Read the article

  • How to best manage multi-frame MovieClips with classes?

    - by Arms
    After switching to AS3, I've been having a hell of a time figuring out the best way to manage MovieClips that have UI elements spread across multiple frames with a single class. An example that I am working on now is a simple email form. I have a MovieClip with two frames: the 1st frame has the form elements (text inputs, submit button) the 2nd frame has a "thank you" message and a button to go back to the first frame (to send another email) In the library I have linked the MovieClip to a custom class (Emailer). My immediate problem is how do I assign a MouseEvent.CLICK event to the button on the 2nd frame? I should note at this point that I am trying to avoid putting code on the timeline (except for stop() calls). This is how I am 'solving' the problem now: Emailer registers an event listener for a frame change ( addEventListener("frame 2", onFrameChange) ) On the 2nd frame of the MovieClip I am calling dispatchEvent(new Event("frame 2")); (I would prefer to not have this code on the frame, but I don't know what else to do) My two complaints with this method are that, first I have calls to addEventListener spread out across different class methods (I would rather have all UI event listeners registered in one method), and second that I have to dispatch those custom "onFrameChange" events. The second complaint grows exponentially for MovieClips that have more than just 2 frames. My so called solution feels makes me feel dirty and makes my brain hurt. I am looking for any advice on what to do differently. Perhaps there's a design pattern I should be looking at? Should I swallow my pride and write timeline code even though the rest of my application is written in class files (and I abhor the Flash IDE code editor)? I absolutely LOVE the event system, and have no problem coding applications with it, but I feel like I'm stuck thinking in terms of AS2 when working with mutl-frame movieclips and code. Any and all help would be greatly appreciated.

    Read the article

  • Could/Should I use static classes in asp.net/c# for shared data?

    - by death.au
    Here's the situation I have: I'm building an online system to be used by school groups. Only one school can log into the system at any one time, and from that school you'll get about 13 users. They then proceed into a educational application in which they have to co-operate to complete tasks, and from a code point of view, sharing variables all over the place. I was thinking, if I set up a static class with static properties that hold the variables that are required to be shared, this could save me having to store/access the variables in/from a database, as long as the static variables are all properly initialized when the application starts and cleaned up at the end. Of course I would also have to put locks on the get and set methods to make the variables thread safe. Something in the back of my mind is telling me this might be a terrible way of going about things, but I'm not sure exactly why, so if people could give me their thoughts for or against using a static class in this situation, I would be quite appreciative.

    Read the article

  • Do private classes need to be accessed by properties?

    - by Andy
    I am using an instance of a private class as the state object supplied to a stream.BeginRead operation. (The class is private to my main stream reading/writing class.) public class MainClass { // ... private class ResponseState { public IResponse response; public Stream stream; public byte[] buffer = new byte[1024]; } } Access to the class is via the fields directly. Should I really be providing access to the class via properties in this case, even though it is only to be used for holding state? Interested to know what others do.

    Read the article

  • How to generate links to the android Classes' reference in javadoc ?

    - by Kaillash
    Hi, When I generate Javadoc for my android project in eclipse, there are lots of warnings like cannot find symbol symbol : class TextView and warning - Tag @see: reference not found: android.app.Dialog I also tried -link http://developer.android.com/reference/ -link http://java.sun.com/j2se/1.4.2/docs/api/ in Extra javadoc options tab in Configure Javadoc Arguments dialog of eclipse-Export Javadoc. But only -link http://java.sun.com/j2se/1.4.2/docs/api/ is working i.e for String class link http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true is generated. but for android.app.Dialog , no link is generated. Please help !!

    Read the article

  • Code generation tool, to create C# adapter classes for unit testing?

    - by RyBolt
    I know I wouldn't need this with Typemock, however, with something like MoQ , I need to use the adapter pattern to enable the creation of mocks via interfaces for code I don't control. For example, TcpClient is a .NET class, so I use adapter pattern to enable mocking of this object, b/c I need an interface of that class. I then produce interface ITcpClient, that can then be implemented via a TcpClientAdapter class, which is just plain vanilla adapter pattern implementation. I am looking for a tool to do this automatically (creation of interface and adapter), I would think there is one out there somewhere? (or is everyone just hand coding these)

    Read the article

  • Override the methods of classes from a .war file.

    - by Sweety
    I have a base application war file say homeApp.war. This contains default operations which user can carry out on the web browser. Now I need to extend the operations available on the same application using that .war file. Like I need to add the extra menus, some shortcuts like icon for log out etc. Please let me know how can I use this .war file to extend the operations and also fix the already existing issues on the application. This web application uses java server faces.

    Read the article

  • Is there a way to make sure classes implementing an Interface implement static methods?

    - by Tobias Kienzler
    Frist of all, I read erickson's usefull reply to "Why can’t I define a static method in a Java interface?". This question is not about the "why" but about the "how then?". So basically I want one Interface to provide both usual methods and e.g. a getSimilarObject method. For (a made up) example public interface ParametricFunction { /** @return f(x) using the parameters */ static abstract public double getValue(double x, double[] parameters); /** @return The function's name */ static abstract public String getName(); } and then public class Parabola implements ParametricFunction { /** @return f(x) = parameters[0] * x² + parameters[1] * x + parameters[2] */ static public double getValue(double x, double[] parameters) { return ( parameters[2] + x*(parameters[1] + x*parameters[0])); } static public String getName() { return "Parabola"; } } Since this is not allowed in the current Java standard, what is the closest thing to this? The idea behind this is putting several ParametricFunction's in a package and use Reflection to list them all, allowing the user to pick e.g. which one to plot. Obviously one could provide a loader class containing an array of the available ParametricFunction's, but every time a new one is implemented one has to remember adding it there, too.

    Read the article

  • How to instantiate objects of classes that have dependencies injected?

    - by chester89
    Let's say I have some class with dependency injected: public class SomeBusinessCaller { ILogger logger; public SomeBusinessCaller(ILogger logger) { this.logger = logger; } } My question is, how do I instantiate an object of that class? Let's say I have an implementation for this, called AppLogger. After I say ObjectFactory.For<ILogger>().Use<AppLogger>(); how do I call constructor of SomeBusinessCaller? Am I calling SomeBusinessCaller caller = ObjectFactory.GetInstance<SomeBusinessCaller>(); or there is a different strategy for that?

    Read the article

  • Is it okay to use zoom:1 in my css classes?

    - by Spines
    Whenever I find IE is displaying my website weird (different from chrome and firefox), I try putting a zoom:1 in the css class for the part that is being displayed weird. A lot of the time this fixes the problem and makes it look consistent with the other browsers. Is it a problem to use zoom:1? I know my CSS won't validate, but are there any real world problems that can arise if I rely too much on using zoom:1?

    Read the article

  • Can I add a custom method to Core Data-generated classes?

    - by Andy
    I've got a couple of Core Data-generated class files that I'd like to add custom methods to. I don't need to add any instance variables. How can I do this? I tried adding a category of methods: // ContactMethods.h (my category on Core Data-generated "Contact" class) #import "Contact.h" @interface Contact (ContactMethods) -(NSString*)displayName; @end ... // ContactMethods.m #import "ContactMethods.h" @implementation Contact (ContactMethods) -(NSString*)displayName { return @"Some Name"; // this is test code } @end This doesn't work, though. I get a compiler message that "-NSManagedObject may not respond to 'displayName' " and sure enough, when I run the app, I don't get "Some Name" where I should be seeing it.

    Read the article

  • C++: Is there a way to limit access to certain methods to certain classes without exposing other pri

    - by dadads
    I have a class with a protected method Zig::punt() and I only want it to be accessible to the class "Avocado". In C++, you'll normally do this using the "friend Avocado" specifier, but this will cause all of the other variables to become accessible to "Avocado" class; I don't want this because this breaks encapsulation. Is what I want impossible, or does there already exist an obscure trick out there that I can use to achieve what I want? Or possibly alternative class design patterns that'll achieve the same thing? Thanks in advance for any ideas!

    Read the article

  • (WinForm/.net) Databind List Of Classes To A DataGridView. But Not Show Certain Public Properties

    - by Pyronaut
    I'm not even sure if i'm doing this correctly. But basically I have a list of objects that are built out of a class. From there, I am binding the list to a datagrid view that is on a Windows Form (C#) From there, it shows all the public properties of the object, in the datagrid view. However there is some properties that i still need accessible from other parts of my application, but aren't really required to be visible in the DataGridView. So is there an attribute or something similar that I can write above the property to exclude it from being shown. P.S. Im binding at runtime. So i cannot edit the columns via the designer. P.P.S. Please no answers of just making public variables (Although if that is the only way, let me know :)).

    Read the article

  • which text writing classes are the most efficient for writing lots of small files?

    - by Robert H
    I have to write 300+ files to a server share on a hourly basis. A quick implementation using CreateText takes approximately 1.4 seconds per file. I know there is a better way to do this, but I am unsure which way is actually the quickest/most efficient; hence my question: Which text writing class is the most efficient for writing hundreds of small files ( 336 bytes on average ) to a server share?

    Read the article

  • Visual Studio 2008 - Is it possible for two projects to share common classes?

    - by John M
    In Visual Studio 2008 I know its possible to have one solution with two (or more) projects. Is it possible OR How is it possible for the projects to share common class files? For example - Project 1 has a log file handling class. Can Project 2 reference it? My hope is to increase code re-use and avoid two copies of the same thing that need to be maintained. The target is Winforms C# (3.5)

    Read the article

  • How can I get class, property, and method data from files without executing their code, similar to R

    - by Chris
    I have a bunch of PHP files with classes, in them (although I can't be 100% sure that they won't have code outside of classes in them too), and I need to parse these files to get information about the classes, such as the names of the classes, the methods, the properties, whether they are private/public/static, etc. I looked at PHP's reflection classes and this is very close to what I want but the reflection doesn't seem to use external files and it appears to need to define the classes first. I need to make sure that none of the code is executed and I will be editing the files so I can't guarantee that they will even be error-free. Any suggestions? Thanks.

    Read the article

  • TypeError: object not callable when making instance

    - by TSM
    I've searched around other threads with similar questions, but I'm not finding the answer. Basically, I have a class: import Android_Class class Android_Revision(object): def __init__(self): # dict for storing the classes in this revision # (format {name : classObject}): self.Classes = {} self.WorkingClass = Android_Class() self.RevisionNumber = '' def __call__(self): print "Called" def make_Class(self, name): newClass = Android_Class(name) self.Classes.update({name : newClass}) self.WorkingClass = newClass def set_Class(self, name): if not(self.Classes.has_key(name)): newClass = Android_Class(name) self.Classes.update({name : newClass}) self.WorkingClass = self.Classes.get(name) I'm trying to make an instance of this class: Revision = Android_Revision() and that's when I'm getting the error. I'm confused because I have another situation where I'm doing almost the exact same thing, and it's working fine. I can't figure out what differences between the two would lead to this error. Thanks.

    Read the article

  • How can I remove all classes that are not named "message" from an element?

    - by Marilou
    I have the following: <div id="abc"> </div> Inside that div there can be one only of the following: <p class="message"> <p class="message error"></p> <p class="message warning"></p> <p class="message success"></p> <p class="message loading"></p> Is there a way that I can find and remove only the class from the <p> element that's NOT "message". I realize I could remove everything and then add what I need with .removeClass() but this won't work for me as after I previously added the message class I did some CSS changes and these will be lost if I remove all and then add again the message class.

    Read the article

  • Do you leave historical code commented out in classes that you update?

    - by 18Rabbit
    When you need to obsolete a section of code (say either the business rules changed, or the old system has been reworked to use a new framework or something) do you delete it from the file or do you comment it out and then put in the new functionality? If you comment it out, do you leave a note stating why it was removed and what it was originally intended to do? I ask mainly because I've done a lot of contract work for different places over the years and sometimes it's like excavating a tomb to find the actual code that is still being used. Why comment it out and leave it in the file if source control has a record of what used to be there? If you comment out a method do you also comment out/delete any methods that were exclusively used by that method? What do you think the best practices for this should be?

    Read the article

  • How do I run compiled java classes with GPU libraries (Jogamp JOCL)?

    - by jam383
    Does anyone know how to run the java code from the command line with dependency on GPU libraries in this case Jogamps JOCL. I have compiled a test program HelloJOCL.java but I get an error during run time. I tried javac -classpath "./lib/jocl.jar:./lib/jocl-natives-macosx-universal.jar:./lib/jocl-natives-linux-i586.jar:./lib/jocl-natives-linux-amd64.jar:./lib/gluegen-rt.jar:./lib/gluegen-rt-natives-linux-amd64.jar:./lib/gluegen-rt-natives-macosx-universal.jar:./lib/gluegen-rt-natives-linux-i586.jar" ./HelloJOCL.java java -classpath "./lib/jocl.jar:./lib/jocl-natives-macosx-universal.jar:./lib/jocl-natives-linux-i586.jar:./lib/jocl-natives-linux-amd64.jar:./lib/gluegen-rt.jar:./lib/gluegen-rt-natives-linux-amd64.jar:./lib/gluegen-rt-natives-macosx-universal.jar:./lib/gluegen-rt-natives-linux-i586.jar:." HelloJOCL but get this error Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/opencl/CLContext at java.lang.Class.getDeclaredMethods0(Native Method)

    Read the article

< Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >