Search Results

Search found 30234 results on 1210 pages for 'object oriented'.

Page 19/1210 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Treeview DatafieldParentID Bind to Object whose property is a another object

    - by user228777
    I am trying to bind Generic collection to a Rad Treeview control. In following case CategoryCollection Returns collection of Category Object, which has bunch of properties and A Parent property which is a object and this parent object Has Id and text properties. What I am trying to do is: I want to Bind DataFieldParentID of the tree view to CategoryCollection.Parent.Id. How do I do that? Dim tvCategory As RadTreeView = DirectCast(cboCategory.Items(0).FindControl("tvCategory"), RadTreeView) With tvCategory .DataSource = CategoryCollection .DataTextField = "Name" .DataValueField = "ID" .DataFieldID = "ID" .DataFieldParentID = "Parent.ID" .DataBind() End With Thank You

    Read the article

  • Python: Hack to call a method on an object that isn't of its class

    - by cool-RR
    Assume you define a class, which has a method which does some complicated processing: class A(object): def my_method(self): # Some complicated processing is done here return self And now you want to use that method on some object from another class entirely. Like, you want to do A.my_method(7). This is what you'd get: TypeError: unbound method my_method() must be called with A instance as first argument (got int instance instead). Now, is there any possibility to hack things so you could call that method on 7? I'd want to avoid moving the function or rewriting it. (Note that the method's logic does depend on self.) One note: I know that some people will want to say, "You're doing it wrong! You're abusing Python! You shouldn't do it!" So yes, I know, this is a terrible terrible thing I want to do. I'm asking if someone knows how to do it, not how to preach to me that I shouldn't do it.

    Read the article

  • Measuring the time to create and destroy a simple object

    - by portoalet
    From Effective Java 2nd Edition Item 7: Avoid Finalizers "Oh, and one more thing: there is a severe performance penalty for using finalizers. On my machine, the time to create and destroy a simple object is about 5.6 ns. Adding a finalizer increases the time to 2,400 ns. In other words, it is about 430 times slower to create and destroy objects with finalizers." How can one measure the time to create and destroy an object? Do you just do: long start = System.nanoTime(); SimpleObject simpleObj = new SimpleObject(); simpleObj.finalize(); long end = System.nanoTime(); long time = end - start;

    Read the article

  • Change all instances of object to iframe for IE using Jquery

    - by geckomist
    I was wondering if it would be possible to use jquery to change all object tags on a site automatically to iframe for IE 8 and below. I would like this so that it can be xhtml 1.1 valid and not have to be double coded all the time and you would not have to focus on non-standard browsers. The data attribute would have to be changed to src, I would like frameborder="0" to be inserted, and all styles set to the object tag also set to the iframe tag. I don't want this to turn into a debate on iframes vs objects, I just thing this would be a huge time saver and would encourage proper strict xhtml coding. Thanks for any input!

    Read the article

  • Pass form object value to static method

    - by jrubengb
    Hi, I need to take a form object value and pass it into a static method: public void SetCalendarStartSafe(DateTime startDateSafe) { startDateSafe = calendarStart.Value; } private static DataTable GetData() { frmMain frm = new frmMain(); DateTime startDate = new frmMain(); frm.SetCalendarStartSafe(startDate); } However I keep getting today's current date whenever I try this approach, even if the specified calendar date on the form is different. How can I can the user-specified calendar date from the original frmMain object? Thanks in advance for any guidance.

    Read the article

  • I serialized a C++ object, how to allocate memory for it without knowing what type it is?

    - by Neo_b
    Hello, I have serialized a C++ object and I wish to allocate space for it, although I can't use the "new" operator, because I do not know the object's class. I tried using malloc(sizeof(object)), although trying to typecast the pointer to the type the serialized object is of, the program shut down. Where is the information about the object class stored? class object { public: virtual void somefunc(); int someint; }; class objectchild:public object { } object *o=(object*)malloc(sizeof(objectchild)); cout << int(dynamic_cast<objectchild*>(o)) << endl; This causes a program shutdown. Thank you in advance.

    Read the article

  • Object reference not set to an instance of an object

    - by Ste
    I have this function that create runtime textbox: int i = 0; private TextBox[] addressBox = new TextBox[100]; private void appendNewTab() { addressBox[i] = new TextBox(); addressBox[i].KeyPress += new KeyPressEventHandler(this.addressBox_KeyPress); i++; } void addressBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { MessageBox.Show(addressBox[i].Text); } } but i have Object reference not set to an instance of an object here MessageBox.Show(addressBox[i].Text); any suggestion?

    Read the article

  • Make object by it's name

    - by Ockonal
    Hello, is it possible to return exemplar of object using passed type name (string) in c++? I have some base abstract class Base and a few derivates. Example code: class Base { /* ... */ }; class Der1 : public Base { /* ... */ }; class Der2 : public Base { /* ... */ }; And I need function like: Base *objectByType(const std::string &name); Number of derivates classes are changeable and I don't want to make something like switching of name and returning by hands new object type. Is it possible in c++ to do that automatically anyway? p.s. usage should looks like: dynamic_cast<Der1>(objectByType("Der1")); I need pure c++ code (crossplatform). Using boost is permissible.

    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

  • jQuery: Writing jquery in an object oriented way

    - by anoopkattodi
    Hi all, I am trying to write all my query code in an object oriented way. But I don't know how to implement this for each click function and hover function etc. I also wanted to know: What are the advantages of writing query in object oriented way? For query what is better the object oriented way or in the ordinary way?

    Read the article

  • Are certain problems solved more elegantly with AOP?

    - by Winston Ewert
    I've come across the idea of Aspect Oriented Programming, and I have some concerns with it. The basic idea seems to be that we want to take cross-cutting concerns which aren't well modularized using object and modularize them. That is all very fine and well. But the implementation of AOP seems to be that of modifying code from outside of the module. So, for example, an aspect could be written that changes what happens when a particular object is passed as a parameter in a function. This seems to go directly against the idea of modules. I should not be able to modify a module's behavior from outside of that module, otherwise the whole point of modules are overturned. But aspects seem to be doing exactly that! Basically, aspects seems to be a form of code patching. It may useful for some quick hacks; but, as a general principle perhaps its not something you want to do. Aspect Oriented Programming seems to me taking a bad practice and raising to a general design principle. Is AOP a good practice? Are certain programming problems solved more elegantly with AOP?

    Read the article

  • Benefits of classic OOP over Go-like language

    - by tylerl
    I've been thinking a lot about language design and what elements would be necessary for an "ideal" programming language, and studying Google's Go has led me to question a lot of otherwise common knowledge. Specifically, Go seems to have all of the interesting benefits from object oriented programming without actually having any of the structure of an object oriented language. There are no classes, only structures; there is no class/structure inheritance -- only structure embedding. There aren't any hierarchies, no parent classes, no explicit interface implementations. Instead, type casting rules are based on a loose system similar to duck-typing, such that if a struct implements the necessary elements of a "Reader" or a "Request" or an "Encoding", then you can cast it and use it as one. Does such a system obsolete the concept of OOP? Or is there something about OOP as implemented in C++ and Java and C# that is inherently more capable, more maintainable, somehow more powerful that you have to give up when moving to a language like Go? What benefit do you have to give up to gain the simplicity that this new paradigm represents?

    Read the article

  • Composing programs from small simple pieces: OOP vs Functional Programming

    - by Jay Godse
    I started programming when imperative programming languages such as C were virtually the only game in town for paid gigs. I'm not a computer scientist by training so I was only exposed to Assembler and Pascal in school, and not Lisp or Prolog. Over the 1990s, Object-Oriented Programming (OOP) became more popular because one of the marketing memes for OOP was that complex programs could be composed of loosely coupled but well-defined, well-tested, cohesive, and reusable classes and objects. And in many cases that is quite true. Once I learned object-oriented programming my C programs became better because I structured them more like classes and objects. In the last few years (2008-2014) I have programmed in Ruby, an OOP language. However, Ruby has many functional programming (FP) features such as lambdas and procs, which enable a different style of programming using recursion, currying, lazy evaluation and the like. (Through ignorance I am at a loss to explain why these techniques are so great). Very recently, I have written code to use methods from the Ruby Enumerable library, such as map(), reduce(), and select(). Apparently this is a functional style of programming. I have found that using these methods significantly reduce code volume, and make my code easier to debug. Upon reading more about FP, one of the marketing claims made by advocates is that FP enables developers to compose programs out of small well-defined, well-tested, and reusable functions, which leads to less buggy code, and low code volume. QUESTIONS: Is the composition of complex program by using FP techniques contradictory to or complementary to composition of a complex program by using OOP techniques? In which situations is OOP more effective, and when is FP more effective? Is it possible to use both techniques in the same complex program? Do the techniques overlap or contradict each other?

    Read the article

  • Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?

    - by Danny Tuppeny
    In a blog post on F# for fun and profit, it says: In a functional design, it is very important to separate behavior from data. The data types are simple and "dumb". And then separately, you have a number of functions that act on those data types. This is the exact opposite of an object-oriented design, where behavior and data are meant to be combined. After all, that's exactly what a class is. In a truly object-oriented design in fact, you should have nothing but behavior -- the data is private and can only be accessed via methods. In fact, in OOD, not having enough behavior around a data type is considered a Bad Thing, and even has a name: the "anemic domain model". Given that in C# we seem to keep borrowing from F#, and trying to write more functional-style code; how come we're not borrowing the idea of separating data/behavior, and even consider it bad? Is it simply that the definition doesn't with with OOP, or is there a concrete reason that it's bad in C# that for some reason doesn't apply in F# (and in fact, is reversed)? (Note: I'm specifically interested in the differences in C#/F# that could change the opinion of what is good/bad, rather than individuals that may disagree with either opinion in the blog post).

    Read the article

  • How to REALLY start thinking in terms of objects?

    - by Mr Grieves
    I work with a team of developers who all have several years of experience with languages such as C# and Java. Most of them are young enough to have been shown OOP as a standard way to develop software in university and are very comfortable with concepts such as inheritance, abstraction, encapsulation and polymorphism. Yet, many of them, and I have to include myself, still tend to create classes which are meant to be used in a very functional fashion. The resulting software is often several smaller classes which correctly represent business objects which get passed through larger classes which only supply ways to modify and use those objects (functions). Large complex difficult-to-maintain classes named Manager are usually the result of such behaviour. I can see two theoretical reasons why people might write this type of code: It's easy to start thinking of everything in terms of the database Deep down, for me, a computer handling a web request feels more like a functional operation than an object oriented operation when you think about Request Handlers, Threads, Processes, CPU Cores and CPU operations... I want source code which is easy to read and easy to modify. I have seen excellent examples of OO code which meet these objectives. How can I start writing code like this? How I can I really start thinking in an object oriented fashion? How can I share such a mentality with my colleagues?

    Read the article

  • Automatically triggering standard spaceship controls to stop its motion

    - by Garan
    I have been working on a 2D top-down space strategy/shooting game. Right now it is only in the prototyping stage (I have gotten basic movement) but now I am trying to write a function that will stop the ship based on it's velocity. This is being written in Lua, using the Love2D engine. My code is as follows (note- object.dx is the x-velocity, object.dy is the y-velocity, object.acc is the acceleration, and object.r is the rotation in radians): function stopMoving(object, dt) local targetr = math.atan2(object.dy, object.dx) if targetr == object.r + math.pi then local currentspeed = math.sqrt(object.dx*object.dx+object.dy*object.dy) if currentspeed ~= 0 then object.dx = object.dx + object.acc*dt*math.cos(object.r) object.dy = object.dy + object.acc*dt*math.sin(object.r) end else if (targetr - object.r) >= math.pi then object.r = object.r - object.turnspeed*dt else object.r = object.r + object.turnspeed*dt end end end It is implemented in the update function as: if love.keyboard.isDown("backspace") then stopMoving(player, dt) end The problem is that when I am holding down backspace, it spins the player clockwise (though I am trying to have it go the direction that would be the most efficient at getting to the angle it would have to be) and then it never starts to accelerate the player in the direction opposite to it's velocity. What should I change in this code to get that to work? EDIT : I'm not trying to just stop the player in place, I'm trying to get it to use it's normal commands to neutralize it's existing velocity. I also changed math.atan to math.atan2, apparently it's better. I noticed no difference when running it, though.

    Read the article

  • i m trying to return list<object> from webmethod but gives error

    - by girish
    System.InvalidOperationException: There was an error generating the XML document. --- System.InvalidOperationException: The type WebService.Property.Property_Users was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write8_ArrayOfAnyType(Object o) at Microsoft.Xml.Serialization.GeneratedAssembly.ListOfObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces) at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o) at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue) at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream) at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues) at System.Web.Services.Protocols.WebServiceHandler.Invoke() public List<object> GetDataByModuleName(string ModuleName) { List<Property_Users> obj_UserList = new List<Property_Users>(); // performing some operation that add data to obj_UserList List < Object > myList = new List<object>(); return ConvertToObjectList<Property_Users>(obj_UserList); } public List<Object> ConvertToObjectList<N>(List<N> sourceList) { List<Object> result = new List<Object>(); foreach (N item in sourceList) { result.Add(item as Object); } return result; } [WebMethod] public List<object> GetDataByModuleName(string ModuleName) { List<object> obj_list = new List<object>(); obj_list = BAL_GeneralService.GetDataByModuleName(ModuleName); return obj_list; }

    Read the article

  • Is it true that in most Object Oriented Programming Languages, an "i" in an instance method always r

    - by Jian Lin
    In the following code: <script type="text/javascript"> var i = 10; function Circle(radius) { this.r = radius; this.i = radius; } Circle.i = 123; Circle.prototype.area = function() { alert(i); } var c = new Circle(1); var a = c.area(); </script> What is being alerted? The answer is at the end of this question. I found that the i in the alert call either refers to any local (if any), or the global variable. There is no way that it can be the instance variable or the class variable even when there is no local and no global defined. To refer to the instance variable i, we need this.i, and to the class variable i, we need Circle.i. Is this actually true for almost all Object oriented programming languages? Any exception? Are there cases that when there is no local and no global, it will look up the instance variable and then the class variable scope? (or in this case, are those called scope?) the answer is: 10 is being alerted.

    Read the article

  • Is there a Python module for handling Python object addresses?

    - by cool-RR
    (When I say "object address", I mean the string that you type in Python to access an object. For example 'life.State.step'. Most of the time, all the objects before the last dot will be packages/modules, but in some cases they can be classes or other objects.) In my Python project I often have the need to play around with object addresses. Some tasks that I have to do: Given an object, get its address. Given an address, get the object, importing any needed modules on the way. Shorten an object's address by getting rid of redundant intermediate modules. (For example, 'life.life.State.step' may be the official address of an object, but if 'life.State.step' points at the same object, I'd want to use it instead because it's shorter.) Shorten an object's address by "rooting" a specified module. (For example, 'garlicsim_lib.simpacks.prisoner.prisoner.State.step' may be the official address of an object, but I assume that the user knows where the prisoner package is, so I'd want to use 'prisoner.prisoner.State.step' as the address.) Is there a module/framework that handles things like that? I wrote a few utility modules to do these things, but if someone has already written a more mature module that does this, I'd prefer to use that. One note: Please, don't try to show me a quick implementation of these things. It's more complicated than it seems, there are plenty of gotchas, and any quick-n-dirty code will probably fail for many important cases. These kind of tasks call for battle-tested code. UPDATE: When I say "object", I mostly mean classes, modules, functions, methods, stuff like these. Sorry for not making this clear before.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >