Search Results

Search found 254060 results on 10163 pages for 'stack oriented'.

Page 10/10163 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • OO Design - polymorphism - how to design for handing streams of different file types

    - by Kache4
    I've little experience with advanced OO practices, and I want to design this properly as an exercise. I'm thinking of implementing the following, and I'm asking if I'm going about this the right way. I have a class PImage that holds the raw data and some information I need for an image file. Its header is currently something like this: #include <boost/filesytem.hpp> #include <vector> namespace fs = boost::filesystem; class PImage { public: PImage(const fs::path& path, const unsigned char* buffer, int bufferLen); const vector<char> data() const { return data_; } const char* rawData() const { return &data_[0]; } /*** other assorted accessors ***/ private: fs::path path_; int width_; int height_; int filesize_; vector<char> data_; } I want to fill the width_ and height_ by looking through the file's header. The trivial/inelegant solution would be to have a lot of messy control flow that identifies the type of image file (.gif, .jpg, .png, etc) and then parse the header accordingly. Instead of using vector<char> data_, I was thinking of having PImage use a class, RawImageStream data_ that inherits from vector<char>. Each type of file I plan to support would then inherit from RawImageStream, e.g. RawGifStream, RawPngStream. Each RawXYZStream would encapsulate the respective header-parsing functions, and PImage would only have to do something like height_ = data_.getHeight();. Am I thinking this through correctly? How would I create the proper RawImageStream subclass for data_ to be in the PImage ctor? Is this where I could use an object factory? Anything I'm forgetting?

    Read the article

  • Getters and Setters are bad OO design?

    - by Dan
    Getters and Setters are bad Briefly reading over the above article I find that getters and setters are bad OO design and should be avoided as they go against Encapsulation and Data Hiding. As this is the case how can it be avoided when creating objects and how can one model objects to take this into account. In cases where a getter or setter is required what other alternatives can be used? Thanks.

    Read the article

  • [Smalltalk] Store List of Instruction

    - by Luciano Lorenti
    Hi all, I have a design Problem. i have a Drawer class wich invokes a serie of methods of a kind-of-brush class and i have a predefined shapes which i want to draw. Each shape uses a list of instance methods from the drawer. I can have more than 1 brush object. I want to add custom shapes on runtime in the drawer instance, especifying the list of methods of the new shape. i've created a class method for every predefined shape that returns a BlockClosure with the instruccions. Obviously i have to give to each BlockClosure the brush object as parameter. I imagine a collection with all the BlockClosures in each instance of the Drawer Class. Maybe i can inherit a SequenceableCollection and make a instruccion collection. Each element of the collection it's a instruction and i give the brush object when i instance this new collection. I really don't know the best way to store these steps. (Maybe a shared variable?)

    Read the article

  • How to make this OO?

    - by John
    Hello, Sorry for the poor title,I'm new to OOP so I don't know what is the term for what I need to do. I have, say, 10 different Objects that inherit one Object.They have different amount and type of class members,but all of them have one property in common - Visible. type TObj1=class(TObject) private a:integer; ...(More members) Visible:Boolean; end; TObj2=class(TObject) private b:String; ...(More members) Visible:Boolean; end; ...(Other 8 objects) For each of them I have a variable. var Obj1:TObj1; Obj2:TObj2; Obj3:TObj3; ....(Other 7 objects) Rule 1: Only one object can be initialized at a time(others have to be freed) to be visible. For this rule I have a global variable var CurrentVisibleObj:TObject; //Because they all inherit TObject Finally there is a procedure that changes visibility. procedure ChangeObjVisibility(newObj:TObject); begin CurrentVisibleObj.Free; //Free the old object CurrentVisibleObj:=newObj; //assign the new object CurrentVisibleObj:= ??? //Create new object CurrentVisibleObj.Visible:=true; //Set visibility to new object end; There is my problem,I don't know how to initialize it,because the derived class is unknown. How do I do this? I simplified the explanation,in the project there are TFrames each having different controls and I have to set visible/not visible the same way(By leaving only one frame initialized). Sorry again for the title,I'm very new to OOP.

    Read the article

  • Two objects with dependencies for each other. Is that bad?

    - by Kasper Grubbe
    Hi SO. I am learning a lot about design patterns these days. And I want to ask you about a design question that I can't find an answer to. Currently I am building a little Chat-server using sockets, with multiple Clients. Currently I have three classes. Person-class which holds information like nick, age and a Room-object. Room-class which holds information like room-name, topic and a list of Persons currently in that room. Hotel-class which have a list of Persons and a list of Rooms on the server. I have made a diagram to illustrate it (Sorry for the big size!): http://i.imgur.com/Kpq6V.png I have a list of players on the server in the Hotel-class because it would be nice to keep track of how many there are online right now (Without having to iterate through all of the rooms). The persons live in the Hotel-class because I would like to be able to search for a specific Person without searching the rooms. Is this bad design? Is there another way of achieve it? Thanks.

    Read the article

  • Is it good to subclass a class only to separate some functional parts?

    - by prostynick
    Suppose we have abstract class A (all examples in C#) public abstract class A { private Foo foo; public A() { } public void DoSomethingUsingFoo() { //stuff } public void DoSomethingElseUsingFoo() { //stuff } //a lot of other stuff... } But we are able to split it into two classes A and B: public abstract class A { public A() { } //a lot of stuff... } public abstract class B : A { private Foo foo; public B() : base() { } public void DoSomethingUsingFoo() { //stuff } public void DoSomethingElseUsingFoo() { //stuff } //nothing else or just some overrides of A stuff } That's good, but we are 99.99% sure, that no one will ever subclass A, because functionality in B is very important. Is it still good to have two separate classes only to split some code into two parts and to separate functional elements?

    Read the article

  • Does this copy the reference or the object?

    - by Water Cooler v2
    Sorry, I am being both thick and lazy, but mostly lazy. Actually, not even that. I am trying to save time so I can do more in less time as there's a lot to be done. Does this copy the reference or the actual object data? public class Foo { private NameValueCollection _nvc = null; public Foo( NameValueCollection nvc) { _nvc = nvc; } } public class Bar { public static void Main() { NameValueCollection toPass = new NameValueCollection(); new Foo( toPass ); // I believe this only copies the reference // so if I ever wanted to compare toPass and // Foo._nvc (assuming I got hold of the private // field using reflection), I would only have to // compare the references and wouldn't have to compare // each string (deep copy compare), right? } I think I know the answer for sure: it only copies the reference. But I am not even sure why I am asking this. I guess my only concern is, if, after instantiating Foo by calling its parameterized ctor with toPass, if I needed to make sure that the NVC I passed as toPass and the NVC private field _nvc had the exact same content, I would just need to compare their references, right?

    Read the article

  • Is there anything wrong with a class with all static methods?

    - by MatthewMartin
    I'm doing code review and came across a class that uses all static methods. The entrance method takes several arguments and then starts calling the other static methods passing along all or some of the arguments the entrance method received. It isn't like a Math class with largely unrelated utility functions. In my own normal programming, I rarely write methods where Resharper pops and says "this could be a static method", when I do, they tend to be mindless utility methods. Is there anything wrong with this pattern? Is this just a matter of personal choice if the state of a class is held in fields and properties or passed around amongst static methods using arguments?

    Read the article

  • Are document-oriented databases meant to replace relational databases?

    - by evolve
    Recently I've been working a little with MongoDB and I have to say I really like it. However it is a completely different type of database then I am used. I've noticed that it is most definitely better for certain types of data, however for heavily normalized databases it might not be the best choice. It appears to me however that it can completely take the place of just about any relational database you may have and in most cases perform better, which is mind boggling. This leads me to ask a few questions: Are document-oriented databases have been developed to be the next generation of databases and basically replace relational databases completely? Is it possible that projects would be better off using both a document-oriented database and a relational database side by side for various data which is better suited for one or the other? If document-oriented databases are not meant to replace relational databases, then does anyone have an example of a database structure which would absolutely be better off in a relational database (or vice-versa)?

    Read the article

  • What open source document-oriented database system is most mature for Windows usage?

    - by jdk
    After using relational databases as back-end storage all my Windows programming life (currently .NET), I want to experiment with a document-oriented database by this Wikipedia definition; it can be standalone or layered over an existing non-commercial database system. What open source document-oriented database solution would you recommend from your own experience and why? A nice to have would be a .NET provider. Admittedly this is somewhat subjective and potentially argumentative so keep it real folks and I'll do the same - also your answers will be invaluable to others looking into document-oriented databases for the first time on Windows. I'm sure the overall value of your answers will outweigh any biases. Thanks.

    Read the article

  • Service-Oriented Architecture and Web Services

    Service oriented architecture is an architectural model for developing distributed systems across a network or the Internet. The main goal of this model is to create a collection of sub-systems to function as one unified system. This approach allows applications to work within the context of a client server relationship much like a web browser would interact with a web server. In this relationship a client application can request an action to be performed on a server application and are returned to the requesting client. It is important to note that primary implementation of service oriented architecture is through the use of web services. Web services are exposed components of a remote application over a network. Typically web services communicate over the HTTP and HTTPS protocols which are also the standard protocol for accessing web pages on the Internet.  These exposed components are self-contained and are self-describing.  Due to web services independence, they can be called by any application as long as it can be accessed via the network.  Web services allow for a lot of flexibility when connecting two distinct systems because the service works independently from the client. In this case a web services built with Java in a UNIX environment not will have problems handling request from a C# application in a windows environment. This is because these systems are communicating over an open protocol allowed by both environments. Additionally web services can be found by using UDDI. References: Colan, M. (2004). Service-Oriented Architecture expands the vision of web services, Part 1. Retrieved on August 21, 2011 from http://www.ibm.com/developerworks/library/ws-soaintro/index.html W3Schools.com. (2011). Web Services Introduction - What is Web Services. Retrieved on August 21, 2011 from http://www.w3schools.com/webservices/ws_intro.asp

    Read the article

  • For buffer overflows, what is the stack address when using pthreads?

    - by t2k32316
    I'm taking a class in computer security and there is an extra credit assignment to insert executable code into a buffer overflow. I have the c source code for the target program I'm trying to manipulate, and I've gotten to the point where I can successfully overwrite the eip for the current function stack frame. However, I always get a Segmentation fault, because the address I supply is always wrong. The problem is that the current function is inside a pthread, and therefore, the address of the stack seems to always change between different runs of the program. Is there any method for finding the stack address within a pthread (or for estimating the stack address within a pthread)? (note: pthread_create's 2nd argument is null, so we're not manually assigning a stack address)

    Read the article

  • Stack Exchange Notifier Chrome Extension [v1.2.9.3 released]

    - by Vladislav Tserman
    About Stack Exchange Notifier is a handy extension for Google Chrome browser that displays your current reputation, badges on Stack Exchange sites and notifies you on reputation's changes. You will now get notified of comments on your own posts (questions and answers) and of any comments that refer to you by @username in a comment, even if you do not own the post (aka mentions). All StackExchange sites are supported. Screenshots Access Install extensions from Google Chrome Extension Gallery Platform Google Chrome browser extension Contact Created by me (Vladislav Tserman). I'm available at: vladjan (at) gmail.com Follow Stack Exchange Notifier on twitter to get notified about news and updates: http://twitter.com/se_notifier Code Written in Java, Google Web Toolkit under Eclipse Helios. Stack Exchange Notifier uses the Stack Exchange API and is powered by Google App Engine for Java. Changelog I will be porting extension to not use app engine back-end due to some limitations. New versions of the extension will be making direct calls to Stack Exchange API right from your browser. Please do not expect new versions of the extension any time soon. Sorry. Read more about limitations here http://stackapps.com/questions/1713 and here http://stackoverflow.com/questions/3949815 Currently, you may sometimes experience some issues using extension, but most users will have no problems. You may notice too many errors in the logs, but there is nothing I can do with this now. Thanks for using my little app, thanks to all of you it still works in spite of many issues with API Version 1.2.9.3 - Thursday, October 14, 2010 - Bug fix release (back-end improvements) Version 1.2.9.2 - Thursday, October 07, 2010 - Bug fix release (high rate of occasional API errors were noticed so some fixes added to handle them were possible) Version 1.2.9.1 - Tuesday, October 05, 2010 - Mostly bug fix release, back-end performance improvements - You will now get notified of comments on your own posts (questions and answers) that are not older than 1 year and of any comments that refer to you by @username in a comment, even if you do not own the post (aka mentions). This is experimental feature, let me know if you like/need it. - New 'All sites' view displays all websites from Stack Exchange network (part of new feature that is not finished yet) Version 1.2.9 - Saturday, September 25, 2010 - Fixes an issue when some users got empty Account view. - When hovering on @Username on account view the title now displays '@Username on @SiteName' to easily understand the site name Version 1.2.7 - Wednesday, September 22, 2010 - Fixed an issue with notifications. - Minor improvements Version 1.2.5 - Tuesday, September 21, 2010 - Fixed an issue where some characters in response payload raised an exception when parsing to JSON. v1.2.3 (Sunday, September 19, 2010) - Support for new OpenID providers was added (Yahoo, MyOpenID, AOL) - UI improvements - Several minor defects were fixed v1.2.2 (Thursday, September 16, 2010) - New types of notifications added. Now extension notifies you on comments that are directed to you. Comments are expandable, so clicking on comment title will expand height to accommodate all available text. - UI and error handling improvements Future Application still in beta stage. I hope you're not having any problems, but if you are, please let me know. Leave your feedback and bug reports in comments. I'm available at: vladjan (at) gmail.com. I'm working on adding new features. I want to hear from the users and incorporate as much feedback as possible into the extension. Any suggestions for improvements/features to add?

    Read the article

  • OpenGL - Stack overflow if I do, Stack underflow if I don't!

    - by Wayne Werner
    Hi, I'm in a multimedia class in college, and we're "learning" OpenGL as part of the class. I'm trying to figure out how the OpenGL camera vs. modelview works, and so I found this example. I'm trying to port the example to Python using the OpenGL bindings - it starts up OpenGL much faster, so for testing purposes it's a lot nicer - but I keep running into a stack overflow error with the glPushMatrix in this code: def cube(): for x in xrange(10): glPushMatrix() glTranslated(-positionx[x + 1] * 10, 0, -positionz[x + 1] * 10); #translate the cube glutSolidCube(2); #draw the cube glPopMatrix(); According to this reference, that happens when the matrix stack is full. So I thought, "well, if it's full, let me just pop the matrix off the top of the stack, and there will be room". I modified the code to: def cube(): glPopMatrix() for x in xrange(10): glPushMatrix() glTranslated(-positionx[x + 1] * 10, 0, -positionz[x + 1] * 10); #translate the cube glutSolidCube(2); #draw the cube glPopMatrix(); And now I get a buffer underflow error - which apparently happens when the stack has only one matrix. So am I just waaay off base in my understanding? Or is there some way to increase the matrix stack size? Also, if anyone has some good (online) references (examples, etc.) for understanding how the camera/model matrices work together, I would sincerely appreciate them! Thanks!

    Read the article

  • Stack Trace Logger [migrated]

    - by Chris Okyen
    I need to write a parent Java class that classes using recursion can extend. The parent class will be be able to realize whenever the call stack changes ( you enter a method, temporarily leave it to go to another method call, or you are are finsihed with the method ) and then print it out. I want it to print on the console, but clear the console as well every time so it shows the stack horizantaly so you can see the height of each stack to see what popped off and what popped on... Also print out if a baseline was reached for recursive functions. First. How can I using the StackTraceElements and Thread classes to detect automatically whenever the stack has popped or pushed an element on without calling it manually? Second, how would I do the clearing thing? For instance , if I had the code: public class recursion(int i) { private static void recursion(int i) { if( i < 10) System.out.println('A'); else { recursion(i / 10 ); System.out.println('B'); } } public static void main(String[] argv) { recursion(102); } } It would need to print out the stack when entering main(), when entering recursion(102) from main(), when it enters recursion(102 / 10), which is recursion(10), from recursion(102), when it enters recursion(10 / 10), which is recursion(1) from recursion(10). Print out a message out when it reaches the baseline recursion(1).. then print out the stacks of reversed revisitation of function recursion(10), recursion(102) and main(). finally print out we are exiting main().

    Read the article

  • LAMP Stack Location

    - by Artem Moskalev
    I have installed the LAMP stack on Ubuntu 12.04 LTS using the tasksel command. I checked - it works. But I cant find the location of the installaton, I worked with WAMP - there you have a separate folder for Apache, for PHP and for mysql. Now I cant even find where to put the documents I create. Which folder is used to contain my web projects? How to start MySQL console and where to look for its installation directory? Which directories are PHP and Apache installed in? how to erase LAMP stack? I found out that some of the parts of the stack are installed in the root/var and root/etc directories: How can I install the whole LAMP stack in /home?

    Read the article

  • What's the demonym for people who use Stack Exchange or Stack Overflow? [closed]

    - by YatharthROCK
    What's the demonym† for people who use Stack Exchange and its network of sites? There's isn't a documented answer anywhere, so I'd like to know the general consensus. Suggestions and ideas are welcome too.‡ Give one answer per site: Stack Exchange Stack Overflow Super User Server Fault And any other site you think has one unique enough :) † Demonymns for or the collective noun used to refer to the people ‡ I asked it on English.SE too. Should I have done that? Would Meta.SO have been more appropriate?

    Read the article

  • Document-oriented database - What if the document definitions change?

    - by Sebastian Hoitz
    As I understand it, you can enter any non-structured information into a document-oriented database. Let's imagine a document like this: { name: 'John Blank', yearOfBirth: 1960 } Later, in a new version, this structure is refactored to { firstname: 'John', lastname: 'Blank', yearOfBirth: 1960 } How do you do this with Document-Oriented databases? Do you have to prepare merge-scripts, that alter all your entries in the database? Or are there better ways you can handle changes in the structure?

    Read the article

  • How to mmap the stack for the clone() system call on linux?

    - by Joseph Garvin
    The clone() system call on Linux takes a parameter pointing to the stack for the new created thread to use. The obvious way to do this is to simply malloc some space and pass that, but then you have to be sure you've malloc'd as much stack space as that thread will ever use (hard to predict). I remembered that when using pthreads I didn't have to do this, so I was curious what it did instead. I came across this site which explains, "The best solution, used by the Linux pthreads implementation, is to use mmap to allocate memory, with flags specifying a region of memory which is allocated as it is used. This way, memory is allocated for the stack as it is needed, and a segmentation violation will occur if the system is unable to allocate additional memory." The only context I've ever heard mmap used in is for mapping files into memory, and indeed reading the mmap man page it takes a file descriptor. How can this be used for allocating a stack of dynamic length to give to clone()? Is that site just crazy? ;) In either case, doesn't the kernel need to know how to find a free bunch of memory for a new stack anyway, since that's something it has to do all the time as the user launches new processes? Why does a stack pointer even need to be specified in the first place if the kernel can already figure this out?

    Read the article

  • When there's no TCO, when to worry about blowing the stack?

    - by Cedric Martin
    Every single time there's a discussion about a new programming language targetting the JVM, there are inevitably people saying things like: "The JVM doesn't support tail-call optimization, so I predict lots of exploding stacks" There are thousands of variations on that theme. Now I know that some language, like Clojure for example, have a special recur construct that you can use. What I don't understand is: how serious is the lack of tail-call optimization? When should I worry about it? My main source of confusion probably comes from the fact that Java is one of the most succesful languages ever and quite a few of the JVM languages seems to be doing fairly well. How is that possible if the lack of TCO is really of any concern?

    Read the article

  • What is Object Oriented Programming ill-suited for?

    - by LeguRi
    In Martin Fowler's book Refactoring, Fowler speaks of how when developers learn something new, they don't consider when it's inappropriate for the job: Ten years ago it was like that with objects. If someone asked me when not to use objects, it was hard to answer. [...] It was just that I didn't know what those limitations were, although I knew what the benefits were. Reading this, it occurred to me I don't know what the limitations or potential disadvantages of Object-Oriented Programming are. What are the limitations of Object Oriented Programming? When should one look at a project and think "OOP is not best suited for this"?

    Read the article

  • Any 3D, Isometric, RPG oriented engines?

    - by Don Quixote
    I was wondering if there are any game engines out there that are oriented towards isometric, 3D RPGs such as Diablo 3, Torchlight, Magika, etc.. Most engines I found so far are either oriented towards FPS, such as Cry Engine and UDK, or are far too generic, such as the Irrlicht engine, which will add what I think is unnecessary work on the engine instead of the game. Any chance there are any engines out there that are crafted to be more suitable for RPGs? I would prefer they be in Java, since it's more my forte, but beggars can't be choosers, so C++ is great as well! Thank you.

    Read the article

  • Why so much stack space used for each recursion?

    - by Harvey
    I have a simple recursive function RCompare() that calls a more complex function Compare() which returns before the recursive call. Each recursion level uses 248 bytes of stack space which seems like way more than it should. Here is the recursive function: void CMList::RCompare(MP n1) // RECURSIVE and Looping compare function { auto MP ne=n1->mf; while(StkAvl() && Compare(n1=ne->mb)) RCompare(n1); // Recursive call ! } StkAvl() is a simple stack space check function that compares the address of an auto variable to the value of an address near the end of the stack stored in a static variable. It seems to me that the only things added to the stack in each recursion are two pointer variables (MP is a pointer to a structure) and the stuff that one function call stores, a few saved registers, base pointer, return address, etc., all 32-bit (4 byte) values. There's no way that is 248 bytes is it? I don't no how to actually look at the stack in a meaningful way in Visual Studio 2008. Thanks

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >