Search Results

Search found 8397 results on 336 pages for 'implementation'.

Page 69/336 | < Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >

  • .NET - Retrieve attribute from controller context?

    - by ropstah
    I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:="Id")> <ModelBinder(GetType(CustomModelBinder))> ByVal object As SomeObject) As ActionResult End Function And i have a CustomModelBinder class with a BindModel implementation: Public Function BindModel( _ ByVal controllerContext As System.Web.Mvc.ControllerContext, _ ByVal bindingContext As System.Web.Mvc.ModelBindingContext) As Object Implements System.Web.Mvc.IModelBinder.BindModel For Each s In HttpContext.Current.Request.Form.Keys HttpContext.Current.Response.Write(s & ": " & HttpContext.Current.Request.Form(s) & "<br />") Next HttpContext.Current.Response.End() End Function As you can see I have a controllerContext and a ModelBindingContext available. How do I get the: <Bind(Exclude:="Id")> part inside the BindModel implementation?

    Read the article

  • What Use are Threads Outside of Parallel Problems on MultiCore Systesm?

    - by Robert S. Barnes
    Threads make the design, implementation and debugging of a program significantly more difficult. Yet many people seem to think that every task in a program that can be threaded should be threaded, even on a single core system. I can understand threading something like an MPEG2 decoder that's going to run on a multicore cpu ( which I've done ), but what can justify the significant development costs threading entails when you're talking about a single core system or even a multicore system if your task doesn't gain significant performance from a parallel implementation? Or more succinctly, what kinds of non-performance related problems justify threading? Edit Well I just ran across one instance that's not CPU limited but threads make a big difference: TCP, HTTP and the Multi-Threading Sweet Spot Multiple threads are pretty useful when trying to max out your bandwidth to another peer over a high latency network connection. Non-blocking I/O would use significantly less local CPU resources, but would be much more difficult to design and implement.

    Read the article

  • How to map a property for HQL usage only (in Hibernate)?

    - by ManBugra
    i have a table like this one: id | name | score mapped to a POJO via XML with Hibernate. The score column i only need in oder by - clauses in HQL. The value for the score column is calculated by an algorithm and updated every 24 hours via SQL batch process (JDBC). So i dont wanna pollute my POJO with properties i dont need at runtime. For a single column that may be not a problem, but i have several different score columns. Is there a way to map a property for HQL use only? For example like this: <property name="score" type="double" ignore="true"/> so that i still can do this: from Pojo p order by p.score but my POJO implementation can look like this: public class Pojo { private long id; private String name; // ... } No Setter for score provided or property added to implementation. using the latest Hibernate version for Java.

    Read the article

  • C#: why Base class is allowed to implement an interface contract without inheriting from it?

    - by etarassov
    I've stumbled upon this "feature" of C# - the base class that implements interface methods does not have to derive from it. Example: public interface IContract { void Func(); } // Note that Base does **not** derive from IContract public abstract class Base { public void Func() { Console.WriteLine("Base.Func"); } } // Note that Derived does *not* provide implementation for IContract public class Derived : Base, IContract { } What happens is that Derived magically picks-up a public method Base.Func and decides that it will implement IContract.Func. What is the reason behind this magic? IMHO: this "quasi-implementation" feature is very-unintuitive and make code-inspection much harder. What do you think?

    Read the article

  • Make Java parent class not part of the interface

    - by Bart van Heukelom
    (This is a hypothetical question for discussion, I have no actual problem). Say that I'm making an implementation of SortedSet by extending LinkedHashMap: class LinkedHashSortedMapThing extends LinkedHashMap implements SortedSet { ... } Now programmers who use this class may do LinkedHashMap x = new LinkedHashSortedMapThing(); But what if I consider the extending of LinkedHashMap an implementation detail, and do not want it to be a part of the class' contract? If people use the line above, I can no longer freely change this detail without worrying about breaking existing code. Is there any way to prevent this sort of thing, other than favouring composition over inheritance (which is not always possible due to private/protected members)?

    Read the article

  • Ideal way to set global uncaught exception Handler in Android

    - by Samuh
    I want to set a global uncaught exception handler for all the threads in my Android application. So, in my Application subclass I set an implementation of Thread.UncaughtExceptionHandler as default handler for uncaught exceptions. Thread.setDefaultUncaughtExceptionHandler( new DefaultExceptionHandler(this)); In my implementation, I am trying to display an AlertDialog displaying appropriate exception message. However, this doesn't seem to work. Whenever, an exception is thrown for any thread which goes un-handled, I get the stock, OS-default dialog (Sorry!-Application-has-stopped-unexpectedly dialog). What is the correct and ideal way to set a default handler for uncaught exceptions? Thanks.

    Read the article

  • What is this Design Pattern?

    - by Can't Tell
    I read the Wikipedia articles on FactoryMethod and AbstractFactory but the following code doesn't seem to fit anywhere. Can someone explain to me what the following pattern is or if it is an anti-pattern? interace PaymentGateway{ void makePayment(); } class PaypalPaymentGateway implements PaymentGateway { public void makePayment() { //some implementation } } class AuthorizeNetPaymentGateway implements PaymentGateway { public void makePayment() { //some implementation } } class PaymentGatewayFacotry{ PaymentGateway createPaymentGateway(int gatewayId) { if(gatewayId == 1) return PaypalPaymentGateway(); else if(gatewayId == 2) return AuthorizeNetPaymentGateway(); } } Let's say the user selects the payment method using a radio button on an html page and the gatewayId is derived from the radio button value. I have seen code like this and thought it was the AbstractFactory pattern but after reading the Wikipedia article, I'm having doubts.

    Read the article

  • Minutia on Objective-C Categories and Extensions.

    - by Matt Wilding
    I learned something new while trying to figure out why my readwrite property declared in a private Category wasn't generating a setter. It was because my Category was named: // .m @interface MyClass (private) @property (readwrite, copy) NSArray* myProperty; @end Changing it to: // .m @interface MyClass () @property (readwrite, copy) NSArray* myProperty; @end and my setter is synthesized. I now know that Class Extension is not just another name for an anonymous Category. Leaving a Category unnamed causes it to morph into a different beast: one that now gives compile-time method implementation enforcement and allows you to add ivars. I now understand the general philosophies underlying each of these: Categories are generally used to add methods to any class at runtime, and Class Extensions are generally used to enforce private API implementation and add ivars. I accept this. But there are trifles that confuse me. First, at a hight level: Why differentiate like this? These concepts seem like similar ideas that can't decide if they are the same, or different concepts. If they are the same, I would expect the exact same things to be possible using a Category with no name as is with a named Category (which they are not). If they are different, (which they are) I would expect a greater syntactical disparity between the two. It seems odd to say, "Oh, by the way, to implement a Class Extension, just write a Category, but leave out the name. It magically changes." Second, on the topic of compile time enforcement: If you can't add properties in a named Category, why does doing so convince the compiler that you did just that? To clarify, I'll illustrate with my example. I can declare a readonly property in the header file: // .h @interface MyClass : NSObject @property (readonly, copy) NSString* myString; @end Now, I want to head over to the implementation file and give myself private readwrite access to the property. If I do it correctly: // .m @interface MyClass () @property (readonly, copy) NSString* myString; @end I get a warning when I don't synthesize, and when I do, I can set the property and everything is peachy. But, frustratingly, if I happen to be slightly misguided about the difference between Category and Class Extension and I try: // .m @interface MyClass (private) @property (readonly, copy) NSString* myString; @end The compiler is completely pacified into thinking that the property is readwrite. I get no warning, and not even the nice compile error "Object cannot be set - either readonly property or no setter found" upon setting myString that I would had I not declared the readwrite property in the Category. I just get the "Does not respond to selector" exception at runtime. If adding ivars and properties is not supported by (named) Categories, is it too much to ask that the compiler play by the same rules? Am I missing some grand design philosophy?

    Read the article

  • About the String#substring() method

    - by alain.janinm
    If we take a look at the String#substring method implementation : new String(offset + beginIndex, endIndex - beginIndex, value); We see that a new String is created with the same original content (parameter char [] value). So the workaround is to use new String(toto.substring(...)) to drop the reference to the original char[] value and make it eligible for GC (if no more references exist). I would like to know if there is a special reason that explain this implementation. Why the method doesn't create herself the new shorter String and why she keeps the full original value instead? The other related question is : should we always use new String(...) when dealing with substring?

    Read the article

  • Getting meaningful error messages from fstream's in C++

    - by Hassan Syed
    What is the best way to get meaningful file access error messages, in a portable way from std::fstreams ? The primitiveness of badbits and failbits is getting to be bit annoying. I have written my own exception hierarchies against win32 and POSIX before, and that was far more flexible than the way the STL does it. I am getting "basic::ios_clear" as an error message from the what method of a downcasted catch (std::exception) of a fstream which has exceptions enabled. This doesn't mean much to me, although I do know what the problem is I'd like my program to be a tad more informative so that when I start deployment a few months later my life will be easier. Is there anything in Boost to extract meaningful messages out of the ofstream's implementation cross platform and cross STL implementation ?

    Read the article

  • Comet with multiple channels

    - by mark_dj
    Hello, I am writing an web app which needs to subscribe to multiple channels via javascript. I am using Atmosphere and Jersey as backend. However the jQuery plugin they work with only supports 1 channel. I've start buidling my own implementation. Now it works oke, but when i try to subscribe to 2 channels only 1 channel gets notified. Is the XMLHttpRequest blocking the rest of the XMLHttpRequests? Here's my code: function AtmosphereComet(url) { this.Connected = new signals.Signal(); this.Disconnected = new signals.Signal(); this.NewMessage = new signals.Signal(); var xhr = null; var self = this; var gotWelcomeMessage = false; var readPosition; var url = url; var onIncomingXhr = function() { if (xhr.readyState == 3) { if (xhr.status==200) // Received a message { var message = xhr.responseText; console.log(message); if(!gotWelcomeMessage && message.indexOf("") -1) { gotWelcomeMessage = true; self.Connected.dispatch(sprintf("Connected to %s", url)); } else { self.NewMessage.dispatch(message.substr(readPosition)); } readPosition = this.responseText.length; } } else if (this.readyState == 4) { self.disconnect(); } } var getXhr = function() { if ( window.location.protocol !== "file:" ) { try { return new window.XMLHttpRequest(); } catch(xhrError) {} } try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } catch(activeError) {} } this.connect = function() { xhr = getXhr(); xhr.onreadystatechange = onIncomingXhr; xhr.open("GET", url, true); xhr.send(null); } this.disconnect = function() { xhr.onreadystatechange = null; xhr.abort(); } this.send = function(message) { } } And the test code: var connection1 = AtmosphereConnection("http://192.168.1.145:9999/botenveiling/b/product/status/2", AtmosphereComet); var connection2 = AtmosphereConnection("http://192.168.1.145:9999/botenveiling/b/product/status/1", AtmosphereComet); var output = function(msg) { alert(output); }; connection1.NewMessage.add(output); connection2.NewMessage.add(output); connection1.connect(); In AtmosphereConnection I instantiate the given AtmosphereComet with "new". I iterate over the object to check if it has to methods: "send", "connect", "disconnect". The reason for this is that i can switch the implementation later on when i complete the websocket implementation :) However I think the problem rests with the XmlHttpRequest object, or am i mistaken? P.S.: signals.Signal is a js observer/notifier library: http://millermedeiros.github.com/js-signals/ Testing: Firefox 3.6.1.3

    Read the article

  • c++ "interface"-like classes similar to Java?

    - by William the Coderer
    In Java, you can define an interface as a class with no actual code implementation, but only to define the methods that a class must implement. Those types can be passed as parameters to methods and returned from methods. In C++, a pure virtual class can't be used as a parameter or return type, from what I can tell. Any way to mimic Java's interface classes? I have a string class in C++, and several subclasses for different encodings (like UTFxxx, ISOxxx, etc) that derive from the base string class. However, since there are so many different encodings, the base class has no meaningful implementation. But it would serve well as an interface if I could handle it as its own object and calls to that object would call on the correct subclass it was inherited to.

    Read the article

  • Qt: any way to automatically generate QSharedData-based structures?

    - by Eye of Hell
    Hello. Qt has a build-in supprt for creating objects with integrated reference counting via QSharedData and QSharedDataPointer. All wordks great, but for each such object i need to write a lot of code: QSharedData-based implementation class with constructor and copy constructor, object class itsef with accessor methods for each filed. For a simple structures with 5-10 fields this requires really lot of near same code. Is it some ways to automate such classes generation? Maybe it's some generators exists that take a short description and automatically generates implementation class and object class with all accessors?

    Read the article

  • Separation of domain and ui layer in a composite

    - by hansmaad
    Hi all, i'm wondering if there is a pattern how to separate the domain logic of a class from the ui responsibilities of the objects in the domain layer. Example: // Domain classes interface MachinePart { CalculateX(in, out) // Where do we put these: // Draw(Screen) ?? // ShowProperties(View) ?? // ... } class Assembly : MachinePart { CalculateX(in, out) subParts } class Pipe : MachinePart { CalculateX(in, out) length, diamater... } There is an application that calculates the value X for machines assembled from many machine parts. The assembly is loaded from a file representation and is designed as a composite. Each concrete part class stores some data to implement the CalculateX(in,out) method to simulate behaviour of the whole assembly. The application runs well but without GUI. To increase the usability a GUi should be developed on top of the existing implementation (changes to the existing code are allowed). The GUI should show a schematic graphical representation of the assembly and provide part specific dialogs to edit several parameters. To achieve these goals the application needs new functionality for each machine part to draw a schematic representation on the screen, show a property dialog and other things not related to the domain of machine simulation. I can think of some different solutions to implement a Draw(Screen) functionality for each part but i am not happy with each of them. First i could add a Draw(Screen) method to the MachinePart interface but this would mix-up domain code with ui code and i had to add a lot of functionality to each machine part class what makes my domain model hard to read and hard to understand. Another "simple" solution is to make all parts visitable and implement ui code in visitors but Visitor does not belong to my favorite patterns. I could derive UI variants from each machine part class to add the UI implementation there but i had to check if each part class is suited for inheritance and had to be careful on changes to the base classes. My currently favorite design is to create a parallel composite hierarchy where each component stores data to define a machine part, has implementation for UI methods and a factory method which creates instances of the corresponding domain classes, so that i can "convert" a UI assembly to a domain assembly. But there are problems to go back from the created domain hierarchy to the UI hierarchy for showing calculation results in the drawing for example (imagine some parts store some values during the calculation i want to show in the schematic representation after the simluation). Maybe there are some proven patterns for such problems?

    Read the article

  • c++11 atomic ordering: extended total order memory_order_seq_cst for locks

    - by itaj
    There's this note in c++11 29.3-p3: [ Note: Although it is not explicitly required that S include locks, it can always be extended to an order that does include lock and unlock operations, since the ordering between those is already included in the "happens before" ordering. - end note ] What does it mean by "always"? I can understand that any certain implementation can be designed to support such an extended S. But in some general implementation that wasn't designed for it, I don't see that S can be extended so. I had sent this question to comp.std.c++ but got no answers there. http://groups.google.com/group/comp.std.c++/browse_frm/thread/5242fa70d0594d1b#

    Read the article

  • How to define RequestMapping prioritization

    - by James Skidmore
    I have a situation where I need the following RequestMapping: @RequestMapping(value={"/{section}"}) ...method implementation here... @RequestMapping(value={"/support"}) ...method implementation here... There is an obvious conflict. My hope was that Spring would resolve this automatically and map /support to the second method, and everything else to the first, but it instead maps /support to the first method. How can I tell Spring to allow an explicit RequestMapping to override a RequestMapping with a PathVariable in the same place? (Edit - this is simplified, I know that having those two RequestMapping alone wouldn't make much sense)

    Read the article

  • How to approach copying objects with smart pointers as class attributes?

    - by tomislav-maric
    From the boost library documentation I read this: Conceptually, smart pointers are seen as owning the object pointed to, and thus responsible for deletion of the object when it is no longer needed. I have a very simple problem: I want to use RAII for pointer attributes of a class that is Copyable and Assignable. The copy and assignment operations should be deep: every object should have its own copy of the actual data. Also, RTTI needs to be available for the attributes (their type may also be determined at runtime). Should I be searching for an implementation of a Copyable smart pointer (the data are small, so I don't need Copy on Write pointers), or do I delegate the copy operation to the copy constructors of my objects as shown in this answer? Which smart pointer do I choose for simple RAII of a class that is copyable and assignable? (I'm thinking that the unique_ptr with delegated copy/assignment operations to the class copy constructor and assignment operator would make a proper choice, but I am not sure) Here's a pseudocode for the problem using raw pointers, it's just a problem description, not a running C++ code: // Operation interface class ModelOperation { public: virtual void operate = (); }; // Implementation of an operation called Special class SpecialModelOperation : public ModelOperation { private: // Private attributes are present here in a real implementation. public: // Implement operation void operate () {}; }; // All operations conform to ModelOperation interface // These are possible operation names: // class MoreSpecialOperation; // class DifferentOperation; // Concrete model with different operations class MyModel { private: ModelOperation* firstOperation_; ModelOperation* secondOperation_; public: MyModel() : firstOperation_(0), secondOperation_(0) { // Forgetting about run-time type definition from input files here. firstOperation_ = new MoreSpecialOperation(); secondOperation_ = new DifferentOperation(); } void operate() { firstOperation_->operate(); secondOperation_->operate(); } ~MyModel() { delete firstOperation_; firstOperation_ = 0; delete secondOperation_; secondOperation_ = 0; } }; int main() { MyModel modelOne; // Some internal scope { // I want modelTwo to have its own set of copied, not referenced // operations, and at the same time I need RAII to work for it, // as soon as it goes out of scope. MyModel modelTwo (modelOne); } return 0; }

    Read the article

  • iphone memory management: alloc and retain properties.

    - by Jonathan
    According to the docs, you do one release per alloc or retain (etc) However what about when using retain propertys? eg: HEADER @property(retain)UIView *someView; IMPLEMENTATION /*in some method*/ UIView *tempView = [[UIView alloc] init]; //<<<<<ALLOC - retain count = +1 [tempView setBackgroundColor:[UIColor redColor]]; self.someView = tempView; ///<<<<<RETAIN - retain count = +2 [tempView release]; ///should I do this? or a different version of the IMPLEMENTATION self.someView = [[UIView alloc] init]; //<<<<<ALLOC & RETAIN - retain count = +2 //now what??? [self.someView release]; ???? EDIT: I didn't make it clear, but I meant what to do in both circumstances, not just the first.

    Read the article

  • Web Service returning object with null fields

    - by Xaiter
    Never seen this one before. WebService.Implementation imp = new WebService.Implementation(); WebService.ImplementationRequest req = new WebService.ImplementationRequest(); return imp.GetValue(req); The object that imp returns is not null. It's returning an ImplementationResponse, as expected. But all of the fields in that object are null. Which is not expected. The WebService, currently, just returns some constant dummy data. We've tested this on another developer's machine, works just fine. I suppose I should also note that the WebService should throw an exception if I pass null into the GetValue method. It doesn't. Not for me. Any idea what could be wrong with my environment that could make a WebService return an object, but make every value in that object null? And somehow 'magically' return this mystery object when it should be throwing an exception?

    Read the article

  • What is the benefits and drawbacks of using header files?

    - by vodkhang
    I had some experience on programming languages like Java, C#, Scala as well as some lower level programming language like C, C++, Objective - C. My observation is that low level languages separate out header files and implementation files while other higher level programming language never separate it out. They use some identifiers like public, private, protected to do the jobs of header files. I saw one benefit of using header file (in some book like Code Complete), they talk about that using header files, people can never look at our implementation file and it helps with encapsulation. A drawback is that it creates too many files for me. Sometimes, it looks like verbose. It is just my thought and I don't know if there are any other benefits and drawbacks that people ever see and work with header file This question may not relate directly to programming but I think that if I can understand better about programming to interface, design software.

    Read the article

  • C++ Singleton design pattern.

    - by Artem Barger
    Recently I've bumped into realization/implementation of Singleton design pattern for C++. It has looked in the following way (I have adopted it from real life example): // a lot of methods is omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); static Singleton* instance; }; From this declaration I can deduce that instance field is initiated on the heap, that means there is a memory allocation. That is completely unclear for me is when does exactly memory is going to be deallocated? Or there is a bug and memory leak? It seems like there is a problem in implementation. PS. And main question how to implement it in the right way?

    Read the article

  • -[CCScene setOffsetx:]: unrecognized selector sent to instance

    - by Alexander Sharunov
    please help me, i'm very new in objective-c i've got 2 simplest classes (bellow first, second) i would like to set the offsetx properties of self.rolypoly object in second class like a self.rolypoly.offsetx=1 or run use [self.rolypoly setOffx]; to do somethings, but i always have the errors: trying [self.rolypoly setOffx]; in second class -[CCScene setOffx:]: unrecognized selector sent to instance 0x91d0b70' or trying self.rolypoly.offsetx=1; in second class -[CCScene setOffsetx:]: unrecognized selector sent to instance 0x808bfc0' first class //************************************************************ #import <Foundation/Foundation.h> #import "cocos2d.h" @interface RolyPoly : CCLayer { CCAction *_walkAction; CCSprite *_rolypoly; int offsetx; int offsety; } @property (nonatomic, retain) CCSprite *rolypoly; @property (nonatomic, retain) CCAction *walkAction; @property (nonatomic, assign) int offsetx; @property (nonatomic, assign) int offsety; +(id) scene; -(void) setOffx; @end //************************************************************ #import "GameLayer.h" #import "RolyPoly.h" @implementation RolyPoly @synthesize rolypoly = _rolypoly; @synthesize walkAction = _walkAction; @synthesize offsetx = _offsetx; @synthesize offsety = _offsety; +(id) scene { CCScene *scene = [CCScene node]; RolyPoly *layer = [RolyPoly node]; [scene addChild: layer]; return scene; } -(id) init { if ((self = [super init])) { [self scheduleUpdate]; } return self; } -(void) setOffx { NSLog(@"setOffx"); } -(void) update:(ccTime)delta { } - (void) dealloc { self.rolypoly = nil; self.walkAction = nil; [super dealloc]; } @end second class //************************************************************ #import <Foundation/Foundation.h> #import "cocos2d.h" #import "RolyPoly.h" @interface GameLayer : CCLayer { RolyPoly *_rolypoly; } // returns a CCScene that contains the HelloWorldLayer as the only child +(CCScene *) scene; @property (nonatomic, assign) RolyPoly * rolypoly; @end //************************************************************ #import "GameLayer.h" #import "RolyPoly.h" // HelloWorldLayer implementation @implementation GameLayer @synthesize rolypoly = _rolypoly; +(CCScene *) scene { CCScene *scene = [CCScene node]; GameLayer *layer = [GameLayer node]; [scene addChild: layer]; return scene; } -(id) init { if( (self=[super init])) { CGSize screenSize = [[CCDirector sharedDirector] winSize]; self.rolypoly = [RolyPoly scene]; [self addChild:self.rolypoly z:1]; [self.rolypoly setOffx]; [self scheduleUpdate]; } return self; } - (void)update:(ccTime)dt { } - (void) dealloc { [super dealloc]; } @end

    Read the article

  • Counting bits set in a .Net BitArray Class

    - by Sam
    I am implementing a library where I am extensively using the .Net BitArray class and need an equivalent to the Java BitSet.Cardinality() method, i.e. a method which returns the number of bits set. I was thinking of implementing it as an extension method for the BitArray class. The trivial implementation is to iterate and count the bits set (like below), but I wanted a faster implementation as I would be performing thousands of set operations and counting the answer. Is there a faster way than the example below? count = 0; for (int i = 0; i < mybitarray.Length; i++) { if (mybitarray [i]) count++; }

    Read the article

  • Allocation Target of std::aligned_storage (stack or heap?)

    - by Zenikoder
    I've been trying to get my head around the TR1 addition known as aligned_storage. Whilst reading the following documents N2165, N3190 and N2140 I can't for the life of me see a statement where it clearly describes stack or heap nature of the memory being used. I've had a look at the implementation provided by msvc2010, boost and gcc they all provide a stack based solution centered around the use of a union. In short: Is the memory type (stack or heap) used by aligned_storage implementation defined or is it always meant to be stack based? and, What the is the specific document that defines/determines that?

    Read the article

< Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >