instruction
stringlengths
34
19.9k
Using C# and WPF I have a situation where my data is organized hierarchically. I am using a treeview to represent this (each node is a Class type that containts a Children property that is an ObservableCollection: Group_01 Object_01 Material_01 Texture Material_02 Texture_02 Group_02 Object_02 Material_03 T...
The users for our software will want to upload potentially large amounts of files in bulk to our servers. It is then desired that we display the upload status any time the user views the upload screen. This doesn't have to be any more fancy than a progress bar with a percent status. My question is, how can I keep trac...
Using C# and WPF I have a situation where my data is organized hierarchically. I am using a treeview to represent this : Group_01 Object_01 Material_01 Texture Material_02 Texture_02 Group_02 Object_02 Material_03 Texture_03 I would like to be able to switch the order of the hierarchy, for example be ab...
Where should the Models be instatiated in a MVC arhitecture? I understand the preferred way would be outside controllers, in a bootstrap file and injected using a Dependecy Injection Container. But most of the models I'm working with depend on run time parameters. //PHP Example class UserController { protected $objU...
I am just learning computer networks so please forgive me if this question is naive. I know the TCP protocol binds itself to a port till the transfer of messages is over (port 80) and UDP is best effort (ie no binding). My question is if I try and access two websites at the same time (multiple tabs on my browser), assu...
I've started a project that involves at least three repositories on GitHub. One of the repositories is a generic documentation-and-examples dump, and the other two contain the implementation of two programs that form the backbone of the project. Should I use a GitHub Organization to handle such a configuration? Or sho...
First of all I have gone through this question Why is #include <iostream.h> bad? and there the reason was simply that it is outdated but I personally think that as a header iostream was better cos you don't have to declare objects like cout and endl in global scope cos they were already in global scope and moreover sin...
I need to find an optimal set of "n" parameter values that minimize an objective function (a 2-hr simulation of a system). I have looked at genetic algorithm and simulated annealing methods, but was wondering if there are any better algorithms and guidance on their merits and limitations. With the above optimization me...
In my current OSS project, I knew literally nothing about what I was doing when I began. I was integrating with a larger project as a plugin, and that in and of itself had a steep learning curve. If I had begun with TDD it would have never been written as my code was changing as I was learning. This has worked for quit...
My manager has recently really been pushing to use velocity as a target and measure of productivity. We are currently working at an average velocity of 50 story points. My manager wants us to increase it by 40% to 70 story points (with no increase in team members). If we don't achieve this increase he wants us to deliv...
I appreciate all help and feedback. Parts bolded are critical parts if this is too verbose. Perhaps it will help to mention I am a green developer. I have found some useful info from related questions posted here and on Stack Overflow but nothing that felt 100%. Background Currently at work we are developing a web a...
If a controller gets too fat and model instantiation starts to add up, a service layer could be used. If I just wrap the logic inside a service class, I will get a bunch of Services with one/two methods. This feels like a code smell. Any best practices regarding this? Can a service instantiate models? If a service ins...
I'm currently reading C++ Concurrency in Action by Anthony Williams and I'm facing an obstacle in thought. First he describes deadlocks as when two threads lock simultaneously (at least, that's how I understood it), which makes sense. However, he goes on to explain how you can lock two mutexes at the same time. Obvious...
I'm making a website in PHP where the user can search a big MySQL database. The user is shown the first result. I want the next button to take the user to the next result, and so on. The trivial solution is for each result page to execute the user's search query again and use OFFSET and LIMIT to get the n-th result tha...
Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO language, but it would not be idiomatic to do so in a staunchly OO way. It seems like ECS separates data (E & C) from behavi...
How should I approach writing comments for callback functions? I want to explain the "why" behind the function when the function and parameter names are insufficient to explain what's going on. I have always wonder why comments like this can be so ordinary in documents of libraries in dynamic languages: /** * cb: cal...
If I have a grid of rectangles and I move one of the rectangles, say above and to the left of another rectangle, how would I resort the rectangles? Note the rectangles are in an array, so each rectangle has an index and a matching tag. All I really need to do is set the proper index based on the rectangles new center ...
I've started working at this company, and the software is managed in a Visual Studio solution that includes hundreds of projects (C++ and C#). After poking around the solution for couple of weeks, I started wondering why there are so many projects. Not only does it slows down VS considerably, but a rebuild can take up ...
I am trying to run a large amount of sites which share about 90% of their code. They are simply designed to query an API and return the results. They will have a common userbase / database but will be configured slightly different and will have different CSS (perhaps even different templating). My initial idea was to r...
The Clojure docs regarding (reduce f val coll) state: If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. So I tried: (reduce str ["s1" "s2"] "s3") Which leads to: "[\"s1\" \"s2\"]s3" However, when I try (apply str ["s1" "...
I am doing a page speed optimization for my website and studying how other websites do it. I noticed that some websites such as as Facebook or Ringgitplus show 0 bytes for some of their resources in Chrome's developer tools, Network tab, while the real content size is several kilobytes. I read some articles that says ...
We are redesigning an old VB6 application in Net. The application makes extensive use of a database and includes management of club members and their results in the competitions that they partake in. So, if we are editing a club member's name, address, etc. it is obvious not to send the data back to the database until ...
Our team has recently inherited a relatively large project from another company (~250k lines). It was developed using C++Builder and we intend to port the Ui side to Qt. Most of the Ui code is separate from the business logic (yay!) but the logic side is quite a mess. There is a lot of diamond inheritance going on (vi...
I'm writing my first Objective-C Class. It's responsible for interaction with an HTTP SSO authentication service. The process requires multiple HTTP transactions in order to complete. The Class acts as a NSURLConnectionDelegate for its own NSURLConnection object. The NSURLConnectionDelegate object operates asynchronou...
I just want someone to clarify the following questions as Demis Bellot had announced a couple of weeks ago that ServiceStack would go commercial. Refer link below. https://plus.google.com/app/basic/stream/z12tfvoackvnx1xzd04cfrirpvybu1nje54 (Please note that when I say ServiceStack or SS I refer to all associated SS li...
If we get assigned to do multiple works simultaneosly, is it good for growth for a developer? If there is a development project and if you are assigned to work on a maintenance project as well, is it good for the growth or will it inhibit the progress?
Can anyone explain me what's the point of overriding base class implementations (if its not abstract), because it's not ethical move to modify features of the parent class according to the wishes of derived classes. The best way is to make the base classes abstract and carry on the inheritance chain. Whereas when desig...
I'm researching what's needed for EDI as far as protocols and server/application setup. This is transportation industry and I'm interested in X12 format for transactions like 204, 210, 214. Specific question is: Do BOTH trading partners have to run servers? With AS3 it seems like SFTP server and it seems like one partn...
I am currently involved in the implementation/design of an existing application for a large scale customer. The application has a similar model as e.g. vCenter Server whereby a number of components store information in and extract information and workflows form a central database. The environment is managed from a cons...
I've been watching a video to learn HTML. I know about HTML but I just wanted to refresh my knowledge. The author declared that he is using HTML5 because the doctype was: <!doctype html> but I noticed that the author used the meta element in a different style that I get used to, he used it without the the forward slas...
For loops are usually inclusice, exclusive, meaning that you start at the bottom, and stops when you reach, but don't to the top. In Python: for i in range(0,a): print(i) would print 0 through a-1. The same applies for Java: for(int i = 0; i < a; i++){ System.out.println(i); } would also print 0 through a-1...
Enumerations1 are often associated with procedural code rather than object-oriented code. They tend to give rise to similar switch statements scattered through the code, and in general, these are replaced by polymorphism in object-oriented code. For example, see Replace Type Code with Class, Replace Type Code with Subc...
We are developing an ERP web application using Vaadin framework where each of the potential client companies will have their own data and file storage. Current implementation only allows having one client company per application instance, what consequently requires separate database schema and file storage. Some of the...
I'm not sure if this is an acceptable question, but compiler-os-design-where-to-start was, so I figured that I'd take a shot at it. I have taken no formal Computer Science classes. I have programmed in Python and attempted C# without success. My technical vocabulary is expansive, yet scattered over a very wide range ...
I'm working on a simple piece of functionality (actually a ruby gem, but that is beside the point) which can be used to receive and persist incoming messages send and persist outgoing messages supplies a hook to the implementing code for performing some action based on a received message. Could for example send a repl...
What is the best way or best resources or tutorials to learn Object Oriented Programming? For instance, when I begin a program with Java and all my code goes into just one class and I can't estimate when I need to create new classes and operate on these classes together.
If I have an ItemContainer class that contains, for example, items in an order, where each item is an Item object; is it best to have a method like: ItemContainer->getItems() that returns an array containing Item objects, or is it better practice to do something like: ItemContainer->getItem($itemNo) which returns a...
I'm rereading this http://docs.python.org/2/howto/functional.html document and hit this line, '...Unfortunately, proving programs correct is largely impractical and not relevant to Python software. Even trivial programs require proofs that are several pages long; the proof of correctness for a moderately complicated p...
Suppose I want to draw a class diagram of a DAO and an Entity. The DAO is used to load instances of the Entity from the database. How can I represent this relationship on my class diagram? Is this considered one? I think it should be displayed on the diagram somehow: TL;DR: should I draw something between them or not?...
I'm programming a jQuery functionality for doing a search on articles while the user is typing in the search field. I implemented a bind in jQuery that at every keyup, it sets a clearTimeout and a setTimeout to the actual function doing the post to the server. This is because users can be writing something and I want t...
Would you consider it appropriate if you were asked for your Stack Exchange username in a software job interview (or as a pre-interview screening question)? To me, it seems like a very reasonable request, and one that would be extremely informative -- I'm sure I could learn more about a candidate in five minutes by lo...
This could be either for the .NET or Mono compilers. I know that under certain conditions the compiler can inline functions (e.g. small, single call site, etc.) as an optimization. However, if the function is public, then it needs to have an external entry point. In these cases, is duplicated code generated (public ...
I'm a freshman Computer Science student and we just started doing some actual projects in Python. I have found I'm very efficient when I use the pen and paper method that my professor suggested in class. But when I can't write my problem down and work my algorithms out on paper I am really slow. During labs, I always s...
I am not sure if this is a clear question. I work on a python project that is based on terminal(console), for which I am planning to implement a GUI. I am not major in CS so I really have no idea about how to effectively design a message system such that: In console, it provide nice look info when runtime. In GUI, it ...
I have a question that I really can't find a straight answer to. Let me start by saying I'm not asking for a step by step tutorial, or even plan on doing anything. I'm just curious. I've been reading up all day on the development of operating systems, and how they're built from scratch. I have a pretty firm grip o...
I have recently started a new job and am being forced to use VS 2005 and .NET 2. This has been quite painful for a number of reasons, but the one big change from VS 2005 to its successors was the introduction of LINQ and extension methods. A common pattern that I used to follow when using enumerations was the following...
I've been using ASP.Net WebForms for the last year or two at work for development, but I've used PHP for personal projects for 10 years. So, I'm far more adept at developing with PHP. When it comes to ASP.Net MVC, I have no experience with it because I've avoided it because I assumed it would just be a more complicate...
Our SPA (plain HTML and Javascript) makes use of huge volume of javascript and other resources that are downloaded via XHR. Given the sheer number of components and browser simultaneous request limits, we're thinking for ways to deliver our resources in a more efficient manner. A method we're considering is bundling se...
Why do we still embed natural language descriptions of source code (i.e., the reason why a line of code was written) within the source code, rather than as a separate document? Given the expansive real-estate afforded to modern development environments (high-resolution monitors, dual-monitors, etc.), an IDE could provi...
While studying the C programming language and learning safe practices, I'm inclined to write a layer of functionality over several parts of the standard library. This would serve two purposes: I could use standard parts of the language in ways that feel more familiar or rational to me, and I could easily replace that ...
I have some difficulty understanding the concept of "fixture". I know what a test suite is, a test case, a test run, but what exactly is a "fixture"? A parameterized test case? It seems to me that the meaning or semantics of the term "fixture" can vary slightly by programming language or by testing framework? I think ...
I'm just wondering if anyone knows about some well designed .NET Open Source Applications using WPF? I have already tried to search at the usual sites like GitHub and Sourceforge, but I wasn't very satisfied by the results at all. Actually I'm interested in the right usage of MVVM, Data Binding etc. in the context of r...
I've recently applied for a position as C# developer, and during the interview, the interviewers asked me many times if I contribute to develop one or more open source project. Since they let me write a lot of code (from basics to TDD,MVVM,MVP), I didn't get the meaning of such a question, especially cause they insiste...
Which of below two shuffle algorithms (shuffle1 and shuffle2) is more random? public final class Shuffle { private static Random random; public static void shuffle1(final Object[] array) { if (random == null) { random = new Random(); } for (int i = array.length - 1; i > 0; ...
Currently, I'm developing an architecture for a system of the following kind: There are a couple of existing applications (front end) with which one can define UML profiles capturing some specific domain aspects. Since the tools are proprietary the produced models are not exchangeable by default. On the other hand ther...
I have a fiery debate running in the office. We have an app with two buttons of different size. (One is 40 px wide and one is 150 px wide). They have the exact same look in terms of background image. I would like to know which is best practice: 1: Make one image for the background that is 40px wide, and another image w...
Today I learned about eager boolean evaluation. In the following example, Bar() will be evaluated even when Foo() is true. if (Foo() | Bar()) This answer on SO has an example: if ((first = (i == 7)) & (second = (j == 10))) { //do something } The use-case here would be that you want to reuse the results, but I would r...
As I am reviewing a BSD license for an open source library to use it in my commercial product, I found this paragraph: Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising...
I am working in QT . Can a static library depend on another static library?(Static Lib is made by linking another static lib) If yes, is it possible that after linking to lib2, the generated lib(lib1) would not contain all the codes of lib2? In my Qt Project I am using a static library, which depends on multiple lib...
This may be a question more suited some Programming Meta Discussions. I was trying to delve deeper into the inner plugin management feature for QT Creator 2.x IDE provided by Digia Inc. So I effectively downloaded the source code for QT Creator and built it to debug how this functionality is implemented. Hence I used a...
I want to provide some library functionality and a reference application, which will run on a fully-featured, POSIX-compliant platform. The app and library will need bi-directional serial port communication, user input from keyboard, user display to text console, and probably timers. I also want to provide a porting gu...
When opening pdf's in Chrome and Firefox, the "view source" button is greyed out. "Inspect elemet," however, reveals HTML. Are the browsers simply downloading the file and generating html to display it?
I'm working on a Bitcoin-clone block explorer (specifically Mincoin) which has a block timer of about 1 minute. For those unfamiliar with Bitcoin, basically a new data structure called a block is propagated to the network about every minute. A block itself holds a lot of information, but three things are the most impor...
I've got a neat (so I thought) way of having each of my modules produce a unit-test executable if compiled with the -DTESTMODULE flag. This flag guards a main() function that can access all static data and functions in the module, without #including a C file. From the README: -- Modules -- The various modules were wr...
I have a legacy project which I have been approved to work in a knockout.js module. This is great, however the application is extremely complex and I need to use some of the pre-built form validation of our application. My form validators work fine until a dynamic template gets switched out. I can't for the life of m...
If I am loading a whole load of items (un-ordered words from a file or something) would it be more efficient to load them all to a Ruby array, and then use the built in sort! method or to do a binary lookup for the place of each item in the list as I load it, and add it in that position. Basic code: array = [] lines.ea...
Hi I'm developing a Wordpress plugin which accesses a couple of API's (Amazon Product API, Flickr, Freebase, Ebay). I've already started writing unit tests for it but I'm still wondering if its really the way to go since it takes a lot of time downloading data from the API primarily because my download speed isn't tha...
When doing table driven predictive parsing on an LL(1) grammar, (as explained in good detail here for example), how can we augment the algorithm to allow processing of semantic actions while doing the parsing. One technique could possibly use the same stack in the algorithm by defining the production rules with marker...
An interesting discussion about the distinction between callbacks and continuations over on SO has prompted this question. By definition, a continuation is an abstract representation of the logic needed to complete a computation. In most languages this manifests as a one argument procedure to which you pass whatever ...
I am developing an application which is using JTransforms to compute FFT and InverseFFT. I am planning to sell that application on Play Store. The JTransforms Library is covered under MPL/LGPL/GPL tri-license. Does that mean I have to disclose my application's source code to the community ? Does that mean I cannot use ...
I run a database for a sequencing centre. There are other developers getting data out of this and running automated and semi automated processes from the database. We are discussing a change to the database. At the moment we have a library that has a one-to-one relationship with a multiplex_index, which can be used t...
Apparently, there are some resemblance between objects in JavaScript and dictionaries in Python. Each language defines an object a little different (and there is some logic that all definitions to be the same as in physics). How are objects alike and how do they differ between JavaSscript, Python and PHP?
From some open source projects, I gathered the following coding style void someFunction(bool forget); void ourFunction() { someFunction(false /* forget */); } I always have doubt about what false means here. Does it mean "forget", or does the "forget" refer to its corresponding parameter (like in the case above...
Assuming I have an API to consume that uses JSON as a data transmission method, what is an ideal way to decode the JSON returned by each API resource? For example, in Java I'd create a class for each API resource then initiate an object of that class and consume data from it. for example: class UserJson extends JsonP...
I'm building an application with lots of components, a lot of which are third-party so I only know what I can get from their documentation. From time to time, by pure luck, I find out one of these components was pretty heavy and had an option to cache stuff. I can't stop thinking that if I weren't lucky, one of these c...
I have AS3/PHP background and some basic understaning of enums from C++. Saying shortly: I read this: http://haxe.org/ref/enums http://haxe.org/doc/cross/more_on_enum And though - good heavens! What the sorcery is this??? Enum Constructors Parameters? Enum Type Parameters?? Could someone explain with working examples...
This is in reference to the question posted here. As I would judge it, the question there should be closed simply because it seems to ask why the Borland developers made one thing a function and another a procedure (function that returns a void result). Now the example was given there of some string manipulation funct...
This question on SO talks about correcting what the OP thought is feature envy code. Another example where I saw this nifty phrase being quoted is in a recently given answer here in programmers.SE. Although I did drop in a comment to that answer asking for the information I thought it would of general help to programm...
Due to the diversity of Linux distributions, it is quite common for programs to be distributed in source format together with scripts in order to assist the configure, make, make install sequence. When it comes to commercial programs, however, distributing the source is usually simply not possible. So if anybody wants ...
I am working on a piece of code which performs a set task in several parallel environments where the behaviour of the different components in the task are similar but quite different. This means that my implementations are quite different but they are all based on the relationships between the same interfaces, somethin...
During 1990s when there were no advanced frameworks/paradigms available for S/W development , knowledge on data structures was critical... which I can comprehend. But nowadays, for most of the problems (at least from Java/Android development) we can rely on an existing class to provide solution. As such I believe, an i...
I asked this question on SO but someone pointed out that I would be better off here. He's most likely right. So here I go! So I just wanted an opinion. I have 2 different ways to approach the problem. Okay so I have a system that I wanna design toward the future. I have some types of objects wich takes as parameters an...
I need to find an approach to the problem of generating texture maps for non-convex polyhedrons without using a design tool like Maya. Specifically, I am mapping simulation results data onto a 3D surface, and I need to write code which generates the maps. One generic approach uses a gradient color brush as an overall ...
To my understanding, when you access a variable, that variable and the surrounding area of memory is put into the L1 cache. If I'm wrong here, please tell me. Now my question is, say I have an array of pointers, and I want to iterate through them all performing operation X. If I first have to access the pointer, to get...
Suppose I have a mesh of relationships, such as Friends who trust some friends and not others A IPv6 router that needs to locate peers across the Internet A PGP Web Of Trust that needs two people to locate each other's trust level I'm interested in determining not only the shortest path, but the cost of each (an ar...
In process concurrency and thread concurrency it's quite obvious how the kernel sees these as they map directly to real things that the kernel manages. When it comes to Golang goroutines and Ruby Fibers (these are similar things right?) I'm clueless as to how these are managed. Are they managed by the respective langua...
So someone peer reviewed my work, and he told me that I should always sign my commits and tags cryptographically. When asked why, he didn't know to explain it to me, and said "It's just a good thing to do". Trying to avoid an obvious chimpanzee scenario, why should I really? Are there really so many distinct advantages...
When making mockups for Responsive Web Design projects, should I separate them by Page or by Screen Size? Which one would be more helpful when I start writing the source code? What are the pros and cons of the following: Page based: All the home page mockups in all different screen sizes Screen-size based: All the pag...
In one of my projects, I have data for hotels, and other booking sites are able to book this hotel. For example: Hotel A - Booking (ID = 4002), Expedia (ID = 123), Priceline (ID = 147) The three booking engines each uses their own Id to reference to Hotel A. I would need to check manually and make the right reference t...
I recently wrote a couple of WordPress Themes in PHP and was wondering what license I should put on it. I don't mind users reusing my code, but I don't want them to be able to sell and redistribute my themes as I want to retain that right. I heard somewhere that an all rights reserved link would stop the distributing e...
Is it possible to build a custom email client for Gmail using Java APIs? Or only Google can do that?
Let say that library "A" is published under GPL. Library "A" exposes some API functions for dynamic linking. I wrote a wrapper library "B" for usage of "A" in another language. Library "B" dynamically links to the library "A" (calls are made to the exposed API functions) . I would like to publish my "B" wrapper libra...
[Potentially misleading title, but I'm not sure how best to word it.] Theoretical question on compilers and language design. Say I'm re-implementing a method in a code base. Instead of removing or commenting out the method that I'm re-implementing I leave it where it is, for reference and testing purposes, and just rem...
I need to escape special characters which are sent to Apache Lucene. Since the code will run on a production server, I want the code to be the fastest possible. I've seen multiple ways to do it: Using Pattern Using Replace Using Library See: http://www.javalobby.org/java/forums/t86124.html I'm wondering: For trivial...
A bit of background information: We have an old database application written in Access that lets users monitor their workload, and the code is... 'procedural' might be too kind. The vast majority of code is hard-wired to form events, there's a lot of duplication, and little to no abstraction. If it needs to fetch data ...
Sometime we really need to choose a multi-threaded design, because single-threading will block the UI or block another thread. But sometimes using multiple threads is just one of the choices, for example, you may able to replace multi-threading with timer. In that situation, you may want to avoid the effort of investig...
I have 3 solutions, one of them is a dataccess solution with all the repositories etc. At the moment when a change is made to it, the others have to go get the latest nuget version locally, we have a nuget server on the LAN. Its a pain to debug though. Would a git submodule work here to enable debugging and not worry a...
Given a constructor that will never, ever, have to use any different implementations of several objects that it initializes, is it still practical to use DI? After all, we might still want to unit test. The class in question initializes a few other classes in its constructor and the classes it uses are pretty specific....
Assume that I have library X which contains class A with method b and that library X is realeased under GPL licence. public class A { public void b() { // this is an example of b method's body. But assume that the body of method b // is very complex System.out.println("operation a"); System.out.p...
Please bear with me, I could only explain the problem in the comments of the code snippet below. Please read through them carefully. Question at the end: I usually tend to name the variables used in for loops with i, like this: for (var i = 0; i < arr.length; i++){ // do some COMPLEX operations here } This loo...