Search Results

Search found 17940 results on 718 pages for 'algorithm design'.

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

  • Examples of limitations in IT due to different bit length by design

    - by Alaudo
    I am teaching the course "Introduction in Programming" for the first-year students and would like to find interesting examples where the datatype size in bits, chosen by design, led to certain known restrictions or important values. Here are some examples: Due to the fact that the Bell teleprinter used 7-bit-code (later accepted as ASCII) until now have we often to encode attachments in electronic messages to contain only 7 bit data. Classical limitation of 32-bit address space leads to the 4Gb maximal RAM size available for 32-bit systems and 4Gb maximal file size in FAT32. Do you know some other interesting examples how the choice of the data type (and especially its binary length) influenced the modern IT world. Added after some discussion in comments: I am not going to teach how to overcome limitations. I just want them to know that 1 byte can hold the values from -127..0..+127 o 0..255, 2 bytes cover the range 0..65535 etc by proving examples they know from other sources, like the above-mentioned base64 encoding etc. We are just learning the basic datatypes and I am trying to find a good reference for "how large" these types are.

    Read the article

  • iOS chat application design, sending/relaying the message over to the end user

    - by AyBayBay
    I have a design question. Let us say you were tasked with building a chat application, specifically for iOS (iOS Chat Application). For simplicity let us say you can only chat with one person at a time (no group chat functionality). How then can you achieve sending a message directly to an end user from phone A to phone B? Obviously there is a web service layer with some API calls. One of the API calls available will be startChat(). After starting a chat, when you send a message, you make another async call, let us call it sendMessage() and pass in a string with your message. Once it goes to the web service layer, the message gets stored in a database. Here is where I am currently stuck. After the message gets sent to the web service layer, how do we then achieve sending/relaying the message over to the end user? Should the web server send out a message to the end user and notify them, or should each client call a receiveMessage() method periodically, and if the server side has some info for them it can then respond with that info? Finally, how can we handle the case in which the user you are trying to send a message to is offline? How can we make sure the end user gets the packet when he moves back to an area with signal?

    Read the article

  • Office design and layout for agile development

    - by Adam Eberbach
    (moved from stackoverflow) I have found lot of discussions here on about which keyboard, desk, light or colored background is best - but I can't find one addressing the layout of the whole office. We are a company with about 20 employees moving to a new place, something larger. There are two main development practices going on here with regular combination, the back end people often needing to work with the mobile people to arrange web services. There are about twice as many back end people as mobile people. About half of the back end developers are working on-site at any time and while they are almost never all in the office at once at least 5-10 spaces need to be provided - so most of the time the two groups are about equal. We have the chance to arrange desks, partitions and possibly even walls to make the space good. There won't be cash for dot-com frills like catering or massages but now's the time to be planning to avoid ending up with a bunch of desks in a long line. Joel on Software's Bionic Office is an article I've remembered from way back and it has some good ideas but I* (and more importantly the company's owners) are not completely sold on the privacy idea in an environment where we are supposed to be collaborating. This is another great link - The Ultimate Software Development Office Layout - I hadn't even remembered enclosed meeting rooms until reading this. Does the private office stand in the way of agile development? Is the scrum enough forced contact and if you need to bug someone you should need to get up and knock on their door? What design layouts can you point to and why would you recommend them? *I'm not against closed offices at all but would be happy if some other solution can do just as well. If it can't... well, that's what this question is all about.

    Read the article

  • Decorator not calling the decorated instance - alternative design needed

    - by Daniel Hilgarth
    Assume I have a simple interface for translating text (sample code in C#): public interface ITranslationService { string GetTranslation(string key, CultureInfo targetLanguage); // some other methods... } A first simple implementation of this interface already exists and simply goes to the database for every method call. Assuming a UI that is being translated at start up this results in one database call per control. To improve this, I want to add the following behavior: As soon as a request for one language comes in, fetch all translations from this language and cache them. All translation requests are served from the cache. I thought about implementing this new behavior as a decorator, because all other methods of that interface implemented by the decorater would simple delegate to the decorated instance. However, the implementation of GetTranslation wouldn't use GetTranslation of the decorated instance at all to get all translations of a certain language. It would fire its own query against the database. This breaks the decorator pattern, because every functionality provided by the decorated instance is simply skipped. This becomes a real problem if there are other decorators involved. My understanding is that a Decorator should be additive. In this case however, the decorator is replacing the behavior of the decorated instance. I can't really think of a nice solution for this - how would you solve it? Everything is allowed, even a complete re-design of ITranslationService itself.

    Read the article

  • Question about a simple design problem

    - by Uri
    At work I stumbled uppon a method. It made a query, and returned a String based on the result of the query, such as de ID of a customer. If the query didn't return a single customer, it'd return a null. Otherwise, it'd return a String with the ID's of them. It looked like this: String error = getOwners(); if (error != null) { throw new Exception("Can't delete, the flat is owned by: " + error); } ... Ignoring the fact that getCustomers() returns a null when it should instead return an empty String, two things are happening here. It checks if the flat is owned by someone, and then returns them. I think a more readable logic would be to do this: if (isOwned) { throw new Exception("Can't delete, the flat is owned by: " + getOwners()); } ... The problem is that the first way does with one query what I do with two queries to the database. What would be a good solution involving good design and efficiency for this?

    Read the article

  • Best design for a "Command Executer" class

    - by Justin984
    Sorry for the vague title, I couldn't think of a way to condense the question. I am building an application that will run as a background service and intermittently collect data about the system its running on. A second Android controller application will query the system over tcp/ip for statistics about the system. Currently, the background service has a tcp listener class that reads/writes bytes from a socket. When data is received, it raises an event to notify the service. The service takes the bytes, feeds them into a command parser to figure out what is being requested, and then passes the parsed command to a command executer class. When the service receives a "query statistics" command, it should return statistics over the tcp/ip connection. Currently, all of these classes are fully decoupled from each other. But in order for the command executer to return statistics, it will obviously need access to the socket somehow. For reasons I can't completely articulate, it feels wrong for the command executer to have a direct reference to the socket. I'm looking for strategies and/or design patterns I can use to return data over the socket while keeping the classes decoupled, if this is possible. Hopefully this makes sense, please let me know if I can include any info that would make the question easier to understand.

    Read the article

  • Design help with parallel process

    - by brazc0re
    I am re-factoring some code and an having an issue with retrieving data from two parallel processes. I have an application that sends packets back and forth via different mediums (ex: RS232, TCP/IP, etc). The jist if of this question is that there are two parallel processes going on. I hope the picture below displays what is going on better than I can word it: SetupRS232() class creates a new instance of the SerialPort by: SerialPort serialPort = new SerialPort(); My question is, what is the best way that the Communicator() class, which sends out the packet via the respective medium, get access to the SerialPort object from the SetupRS232 class? I can do it with a Singleton but have heard that they are generally not the best design to go by. I am trying to follow SRP but I do feel like I am doing something wrong here. Communicator() will need to go out of it's way to get access to SetupRS232() to get access to the SerialPort class. I actually haven't found a way to even get access to it. Would designing each medium class, for example, SetupRS232(), SetupTCPIP, as a singleton be the best way to approach this problem?

    Read the article

  • OOP Design: relationship between entity classes

    - by beginner_
    I have at first sight a simple issue but can't wrap my head around on how to solve. I have an abstract class Compound. A Compound is made up of Structures. Then there is also a Container which holds 1 Compound. A "special" implementation of Compound has Versions. For that type of Compound I want the Container to hold the Versionof the Compound and not the Compound itself. You could say "just create an interface Containable" and a Container holds 1 Containable. However that won't work. The reason is I'm creating a framework and the main part of that framework is to simplify storing and especially searching for special data type held by Structure objects. Hence to search for Containers which contain a Compound made up of a specific Structure requires that the "Path" from Containerto Structure is well defined (Number of relationships or joins). I hope this was understandable. My question is how to design the classes and relationships to be able to do what I outlined.

    Read the article

  • Algorithm to reduce a bitmap mask to a list of rectangles?

    - by mos
    Before I go spend an afternoon writing this myself, I thought I'd ask if there was an implementation already available --even just as a reference. The first image is an example of a bitmap mask that I would like to turn into a list of rectangles. A bad algorithm would return every set pixel as a 1x1 rectangle. A good algorithm would look like the second image, where it returns the coordinates of the orange and red rectangles. The fact that the rectangles overlap don't matter, just that there are only two returned. To summarize, the ideal result would be these two rectangles (x, y, w, h): [ { 3, 1, 2, 6 }, { 1, 3, 6, 2 } ]

    Read the article

  • Need suggestion for Mutiple Windows application design

    - by King Chan
    This was previously posted in StackOverflow, I just moved to here... I am using VS2008, MVVM, WPF, Prism to make a mutiple window CRM Application. I am using MidWinow in my MainWindow, I want Any ViewModel would able to make request to MainWindow to create/add/close MidChildWindow, ChildWindow(from WPF Toolkit), Window (the Window type). ViewModel can get the DialogResult from the ChildWindow its excutes. MainWindow have control on all opened window types. Here is my current approach: I made Dictionary of each of the windows type and stores them into MainWindow class. For 1, i.e in a CustomerInformationView, its CustomerInformationViewModel can execute EditCommand and use EventAggregator to tell MainWindow to open a new ChildWindow. CustomerInformationViewModel: CustomerEditView ceView = new CustomerEditView (); CustomerEditViewModel ceViewModel = CustomerEditViewModel (); ceView.DataContext = ceViewModel; ChildWindow cWindow = new ChildWindow(); cWindow.Content = ceView; MainWindow.EvntAggregator.GetEvent<NewWindowEvent>().Publish(new WindowEventArgs(ceViewModel.ViewModeGUID, cWindow )); cWindow.Show(); Notice that all my ViewModel will generates a Guid for help identifies the ChildWindow from MainWindow's dictionary. Since I will only be using 1 View 1 ViewModel for every Window. For 2. In CustomerInformationViewModel I can get DialogResult by OnClosing event from ChildWindow, in CustomerEditViewModel can use Guid to tell MainWindow to close the ChildWindow. Here is little question and problems: Is it good idea to use Guid here? Or should I use HashKey from ChildWindow? My MainWindows contains windows reference collections. So whenever window close, it will get notifies to remove from the collection by OnClosing event. But all the Windows itself doesn't know about its associated Guid, so when I remove it, I have to search for every KeyValuePair to compares... I still kind of feel wrong associate ViewModel's Guid for ChildWindow, it would make more sense if ChildWindow has it own ID then ViewModel associate with it... But most important, is there any better approach on this design? How can I improve this better?

    Read the article

  • Process for beginning a Ruby on Rails project

    - by Daniel Beardsley
    I'm about to begin a Ruby on Rails project and I'd love to hear how others go through the process of starting an application design. I have quite a bit of experience with RoR, but don't have that many starting from scratch with only a vision experiences and would appreciate the wisdom of others who've been there. I'm looking for an order of events, reasons for the order, and maybe why each part is important. I can think of a few starting points, but I'm not sure where it's best to begin Model design and relationships (entities, how they relate, and their attributes) Think of user use-cases (or story-boards) and implement the minimum to get these done Create Model unit-tests then create the necessary migrations and AR models to get the tests to pass Hack out the most basic version of the simplest part of your application and go from there Start with a template for a rails app (like http://github.com/thoughtbot/suspenders) Do the boring gruntwork first (User auth, session management, ...) ...

    Read the article

  • Improvements to Joshua Bloch's Builder Design Pattern?

    - by Jason Fotinatos
    Back in 2007, I read an article about Joshua Blochs take on the "builder pattern" and how it could be modified to improve the overuse of constructors and setters, especially when an object has a large number of properties, most of which are optional. A brief summary of this design pattern is articled here [http://rwhansen.blogspot.com/2007/07/theres-builder-pattern-that-joshua.html]. I liked the idea, and have been using it since. The problem with it, while it is very clean and nice to use from the client perspective, implementing it can be a pain in the bum! There are so many different places in the object where a single property is reference, and thus creating the object, and adding a new property takes a lot of time. So...I had an idea. First, an example object in Joshua Bloch's style: Josh Bloch Style: public class OptionsJoshBlochStyle { private final String option1; private final int option2; // ...other options here <<<< public String getOption1() { return option1; } public int getOption2() { return option2; } public static class Builder { private String option1; private int option2; // other options here <<<<< public Builder option1(String option1) { this.option1 = option1; return this; } public Builder option2(int option2) { this.option2 = option2; return this; } public OptionsJoshBlochStyle build() { return new OptionsJoshBlochStyle(this); } } private OptionsJoshBlochStyle(Builder builder) { this.option1 = builder.option1; this.option2 = builder.option2; // other options here <<<<<< } public static void main(String[] args) { OptionsJoshBlochStyle optionsVariation1 = new OptionsJoshBlochStyle.Builder().option1("firefox").option2(1).build(); OptionsJoshBlochStyle optionsVariation2 = new OptionsJoshBlochStyle.Builder().option1("chrome").option2(2).build(); } } Now my "improved" version: public class Options { // note that these are not final private String option1; private int option2; // ...other options here public String getOption1() { return option1; } public int getOption2() { return option2; } public static class Builder { private final Options options = new Options(); public Builder option1(String option1) { this.options.option1 = option1; return this; } public Builder option2(int option2) { this.options.option2 = option2; return this; } public Options build() { return options; } } private Options() { } public static void main(String[] args) { Options optionsVariation1 = new Options.Builder().option1("firefox").option2(1).build(); Options optionsVariation2 = new Options.Builder().option1("chrome").option2(2).build(); } } As you can see in my "improved version", there are 2 less places in which we need to add code about any addition properties (or options, in this case)! The only negative that I can see is that the instance variables of the outer class are not able to be final. But, the class is still immutable without this. Is there really any downside to this improvement in maintainability? There has to be a reason which he repeated the properties within the nested class that I'm not seeing?

    Read the article

  • Design pattern for logging changes in parent/child objects saved to database

    - by andrew
    I’ve got a 2 database tables in parent/child relationship as one-many. I’ve got three classes representing the data in these two tables: Parent Class { Public int ID {get; set;} .. other properties } Child Class { Public int ID {get;set;} Public int ParentID {get; set;} .. other properties } TogetherClass { Public Parent Parent; Public List<Child> ChildList; } Lastly I’ve got a client and server application – I’m in control of both ends so can make changes to both programs as I need to. Client makes a request for ParentID and receives a Together Class for the matching parent, and all of the child records. The client app may make changes to the children – add new children, remove or modify existing ones. Client app then sends the Together Class back to the server app. Server app needs to update the parent and child records in the database. In addition I would like to be able to log the changes – I’m doing this by having 2 separate tables one for Parent, one for child; each containing the same columns as the original plus date time modified, by whom and a list of the changes. I’m unsure as to the best approach to detect the changes in records – new records, records to be deleted, records with no fields changed, records with some fields changed. I figure I need to read the parent & children records and compare those to the ones in the Together Class. Strategy A: If Together class’s child record has an ID of say 0, that indicates a new record; insert. Any deleted child records are no longer in the Together Class; see if any of the comparison child records are not found in the Together class and delete if not found (Compare using ID). Check each child record for changes and if changed log. Strategy B: Make a new Updated TogetherClass UpdatedClass { Public Parent Parent {get; set} Public List<Child> ListNewChild {get;set;} Public List<Child> DeletedChild {get;set;} Public List<Child> ExistingChild {get;set;} // used for no changes and modified rows } And then process as per the list. The reason why I’m asking for ideas is that both of these solutions don’t seem optimal to me and I suspect this problem has been solved already – some kind of design pattern ? I am aware of one potential problem in this general approach – that where Client App A requests a record; App B requests same record; A then saves changes; B then saves changes which may overwrite changes A made. This is a separate locking issue which I’ll raise a separate question for if I’ve got trouble implementing. The actual implementation is c#, SQL Server and WCF between client and server - sharing a library containing the class implementations. Apologies if this is a duplicate post – I tried searching various terms without finding a match though.

    Read the article

  • Why hill climbing is called anytime algorithm?

    - by crucified soul
    From wikipedia, Anytime algorithm In computer science an anytime algorithm is an algorithm that can return a valid solution to a problem even if it's interrupted at any time before it ends. The algorithm is expected to find better and better solutions the more time it keeps running. Hill climbing Hill climbing can often produce a better result than other algorithms when the amount of time available to perform a search is limited, such as with real-time systems. It is an anytime algorithm: it can return a valid solution even if it's interrupted at any time before it ends. Hill climbing algorithm can stuck into local optima or ridge, after that even if it runs infinite time, the result won't be any better. Then, why hill climbing is called anytime algorithm?

    Read the article

  • C# Design How to Elegantly wrap a DAL class

    - by guazz
    I have an application which uses MyGeneration's dOODads ORM to generate it's Data Access Layer. dOODad works by generating a persistance class for each table in the database. It works like so: // Load and Save Employees emps = new Employees(); if(emps.LoadByPrimaryKey(42)) { emps.LastName = "Just Got Married"; emps.Save(); } // Add a new record Employees emps = new Employees(); emps.AddNew(); emps.FirstName = "Mr."; emps.LastName = "dOOdad"; emps.Save(); // After save the identity column is already here for me. int i = emps.EmployeeID; // Dynamic Query - All Employees with 'A' in thier last name Employees emps = new Employees(); emps.Where.LastName.Value = "%A%"; emps.Where.LastName.Operator = WhereParameter.Operand.Like; emps.Query.Load(); For the above example(i.e. Employees DAL object) I would like to know what is the best method/technique to abstract some of the implementation details on my classes. I don't believe that an Employee class should have Employees(the DAL) specifics in its methods - or perhaps this is acceptable? Is it possible to implement some form of repository pattern? Bear in mind that this is a high volume, perfomacne critical application. Thanks, j

    Read the article

  • Dijkstra’s algorithm and functions

    - by baris_a
    Hi guys, the question is: suppose I have an input function like sin(2-cos(3*A/B)^2.5)+0.756*(C*D+3-B) specified with a BNF, I will parse input using recursive descent algorithm, and then how can I use or change Dijkstra’s algorithm to handle this given function? After parsing this input function, I need to execute it with variable inputs, where Dijkstra’s algorithm should do the work. Thanks in advance. EDIT: May be I should ask also: What is the best practice or data structure to represent given function?

    Read the article

  • Domain driven design: Manager and service

    - by ryudice
    I'm creating some business logic in the application but I'm not sure how or where to encapsulate it, I've used the repository pattern for data access, I've seen some projects that use DDD that have some classes with the "Service" suffix and the "manager" suffix, what are each of this clases suppose to take care of in DDD?

    Read the article

  • Efficient algorithm for finding largest eigenpair of small general complex matrix

    - by mklassen
    I am looking for an efficient algorithm to find the largest eigenpair of a small, general (non-square, non-sparse, non-symmetric), complex matrix, A, of size m x n. By small I mean m and n is typically between 4 and 64 and usually around 16, but with m not equal to n. This problem is straight forward to solve with the general LAPACK SVD algorithms, i.e. gesvd or gesdd. However, as I am solving millions of these problems and only require the largest eigenpair, I am looking for a more efficient algorithm. Additionally, in my application the eigenvectors will generally be similar for all cases. This lead me to investigate Arnoldi iteration based methods, but I have neither found a good library nor algorithm that applies to my small general complex matrix. Is there an appropriate algorithm and/or library?

    Read the article

  • Algorithm for Text Wrapping Within a Shape

    - by devongovett
    I am looking for an algorithm to wrap text within a non-rectangular shape, preferably based on the Knuth and Plass algorithm. The hardest part of this is that the lines may have different heights due to differing font sizes in the text. The image below is an example of what the algorithm should be able to generate. Thanks for any help!

    Read the article

  • Clustering [assessment] algorithm with distance matrix as an input

    - by Max
    Can anyone suggest some clustering algorithm which can work with distance matrix as an input? Or the algorithm which can assess the "goodness" of the clustering also based on the distance matrix? At this moment I'm using a modification of Kruskal's algorithm (http://en.wikipedia.org/wiki/Kruskal%27s_algorithm) to split data into two clusters. It has a problem though. When the data has no distinct clusters the algorithm will still create two clusters with one cluster containing one element and the other containing all the rest. In this case I would rather have one cluster containing all the elements and another one which is empty. Are there any algorithms which are capable of doing this type of clustering? Are there any algorithms which can estimate how well the clustering was done or even better how many clusters are there in the data? The algorithms should work only with distance(similarity) matrices as an input.

    Read the article

  • Dijkstra's algorithm: why does it work? (not how)

    - by BeeBand
    I understand what Dijkstra's algorithm is but I don't understand why it works. When selecting the next vertice to examine, why does Dijkstra's algorithm select the one with the smallest weight? Why not just select a vertex arbitrarily, since the algorithm visits all vertices anyway?

    Read the article

  • Repeated properties design pattern

    - by Mark
    I have a DownloadManager class that manages multiple DownloadItem objects. Each DownloadItem has events like ProgressChanged and DownloadCompleted. Usually you want to use the same event handler for all download items, so it's a bit annoying to have to set the event handlers over and over again for each DownloadItem. Thus, I need to decide which pattern to use: Use one DownloadItem as a template and clone it as necessary var dm = DownloadManager(); var di = DownloadItem(); di.ProgressChanged += new DownloadProgressChangedEventHandler(di_ProgressChanged); di.DownloadCompleted += new DownloadProgressChangedEventHandler(di_DownloadCompleted); DownloadItem newDi; newDi = di.Clone(); newDi.Uri = "http://google.com"; dm.Enqueue(newDi); newDi = di.Clone(); newDi.Uri = "http://yahoo.com"; dm.Enqueue(newDi); Set the event handlers on the DownloadManager instead and have it copy the events over to each DownloadItem that is enqeued. var dm = DownloadManager(); dm.ProgressChanged += new DownloadProgressChangedEventHandler(di_ProgressChanged); dm.DownloadCompleted += new DownloadProgressChangedEventHandler(di_DownloadCompleted); dm.Enqueue(new DownloadItem("http://google.com")); dm.Enqueue(new DownloadItem("http://yahoo.com")); Or use some kind of factory var dm = DownloadManager(); var dif = DownloadItemFactory(); dif.ProgressChanged += new DownloadProgressChangedEventHandler(di_ProgressChanged); dif.DownloadCompleted += new DownloadProgressChangedEventHandler(di_DownloadCompleted); dm.Enqueue(dif.Create("http://google.com")); dm.Enqueue(dif.Create("http://yahoo.com")); What would you recommend?

    Read the article

  • RESTful Question/Answer design?

    - by Kirschstein
    This is a toy project I'm working on at the moment. My app contains questions with multiple choice answers. The question url is in the following format, with GET & POST mapping to different actions on the questions controller. GET: url.com/questions/:category/:difficulty => 'ask' POST: url.com/questions/:category/:difficulty => 'answer' I'm wondering if it's worth redesigning this into a RESTful style. I know I'd need to introduce answers as a resource, but I'm struggling to think of a url that would look natural for answering that question. Would a redesign be worthwhile? How would you go about structuring the urls?

    Read the article

  • Design Question on when to save

    - by Ben
    Hi, I was just after peoples opinion on when the best time to save an object (or collection of objects) is. I appreciate that it can be completely dependent on the situation that you are in but here is my situation. I have a collection of objects "MyCollection" in a grid. You can open each object "MyObject" in an editor dialogue by double clicking on the grid. Selecting "Cancel" on the dialogue will back out any changes you have made, but should selecting "ok" commit those changes back to the database, or should they commit the changes on that object back to the collection and have a save method that iterates through the collection and saves all changed objects? If i have an object "MyParentObject", that contains a collection of childen "MyChildObjectCollection", none of the changes made to each "MyChildObject" would be commited to the database until the "MyParentObject" was saved - this makes sense. However in my current situation, none of the objects in the collection are linked, therefore should the "Ok" on the dialogue commit the changes to the database? Appreciate any opinions on this. Thanks

    Read the article

  • Algorithm for matching partially filled words

    - by adnanhb
    Hello All, I am writing a game which when given a partially filled word, searches a dictionary and returns all the matching words. To that effect, I am trying to find an algorithm that can be used for the said purpose. For example, given - - a -, the algorithm will search a dictionary for all the words which have length 4 and have 'a' as the third letter. Is there such an algorithm already? If not, can somebody given a rough idea of how to design such an algorithm? Thanks in Advance.

    Read the article

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