instruction stringlengths 34 19.9k |
|---|
Empty glasses of water are arranged in the following order:
When you pour liquid into the 1st glass if it's full, then the extra liquid would be flown into the glasses 2 and 3 in equal quantities. When glass 2 is full, the extra liquid would be flown into 4 and 5 and so on.
Given an N liters of liquid and maximum capa... |
I am creating a tree where some nodes have a reference to their parent as well as their children. It feels like a tree version of a doubly linked list.
Is there a name for this?
|
My question is conceptual, yet extremely vital for me.
I'm an intermediate Python developer. I know fair enough about it, and actually use it on a daily basis. Now, I would like to transform my capabilities from a library/API user to "designer" one.
I found that "Python Requests" library by Kenneth Reitz is an extreme... |
I'm going through a MVC tutorial, and I notice that convention seems to be to expose a tables primary key on detail pages/urls (ie. /Movies/Details/5 as an example from the tutorial).
It's obviously not a problem for things like a movie record or a SO post, but it might be a bit different for an invoice or transaction ... |
I am new to UI development, but I feel very uncomfortable with how CSS works.
My use case is that I wanted to apply some specific styles inside a particular div on a page.
CSS attempt:
div.class1 {
font: normal 12px arial, helvetica, sans-serif;
font-color: #f30;
}
div.class1 div.class2 {
border: 1px solid... |
I have good number of Service and DAO classes which has the same set of 30 line exception code block which gets repeated and it shows up in Code Duplication report.
The approach which I can think of is to
Extract the common exception code blocks to a common method and call
the method in one shot
Re-organize the me... |
I've recently been going through the Learn You a Haskell for Great Good guide and as practice I wanted to solve Project Euler Problem 5 with it, which specifies:
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
I decided to first write a function determining whether a ... |
I assigned a POC project to someone where I asked to implement both Command Query Responsibility Segregation, Inversion of Control (with Dependency Injection) and Repository pattern. “Someone” gave me a POC solution project but I am not sure whether this is the way it is done. I will brief here about the POC project
... |
It seems to be a generally accepted good practice not to push invalid, broken, or incomplete code. But one of the huge advantages of version control systems is that it gives you a remote place for your code, so you can work on the same codebase from more than one place.
Suppose you are working on a feature with a coupl... |
I don't have a specific context in which I'm asking the question, but while I was reading a beginner book on C++ I noticed the use of both an endl stream manipulator and a newline escape character when dealing with a stream object.
The exmaple is as follows:
cout << "Hello World" << endl;
cout << "Hello World\n";
My q... |
In our software environment, we often run a/b tests, as is probably good practice. However, our environment is set up such that, in very short order, the code starts to become very crufty with dead tests. The testing registry is little more than a collection of internal wiki pages.
I thought of a "dead man's switch" st... |
I'm working with a new plugin (flexbox), and I ran into the MS-PL license, which I had not run into before.
In the past, I've used mainly MIT and Apache licensed projects, so I have no idea what the main differences are with this one.
Here's a link to it: http://opensource.org/licenses/MS-PL
Can anyone help explain the... |
We've been thinking of using GPL components to make a GPL application, and freely give it away. We then want to use that as a loss-leader. In that free application, where even the source code is available, we plan to have an advertisement for some payware. The payware would be for functionality that is completely diffe... |
There are plenty of compilers and REPL services on the web. For example: Fay ide.
I find that implementing some similar technology would be very interesting. But it seems like a major security hole. Am I wrong in thinking that exposing a compiler would be risky? An interpreter seems even worse.
update: I can be a bit m... |
I was asked an interesting question: Should a database contains all data? Or heavy binary files should be stored in file system?
Example of heavy binary files : videos or heavy pdf files (+200 MB)
With an old aspx web app (1.1) I tried to open a 200MB pdf file stored as a blob in an Oracle 11g database, and it just run... |
This question is asked on SO and this site often it looks like. "How do I do a dynamic enum?" Answers range from you shouldn't to possible compile time solutions. Now my question is do I want a dynamic enum that is generated from look up tables in the DB, or do I want something else that is similar?
I have a solut... |
I'm wondering what's better design wise for usability/maintainability, and what's better as far as fitting with the community.
Given the data model:
type Name = String
data Amount = Out | Some | Enough | Plenty deriving (Show, Eq)
data Container = Container Name deriving (Show, Eq)
data Category = Category Name derivi... |
I recently started learning to write code, and in my book I came across this question. "Why is a Boolean value stored as a byte inside of a computer when it only requires one bit?" can someone shed more light on this question?
|
Unlike C++, in Java, we cannot have just function declarations in the class and definitions outside of the class. Why is it so?
Is it to emphasize that a single file in Java should contain only one class and nothing else?
|
I'm designing an abstraction over ASP.Net's built in caching to make it not so horrible to use. One design decision I'm having to look at is if I should restrict people to using just one cache policy on each item.
For example, say you're caching the HTML generated by your blog post or some such. Would you ever want to... |
I know that Python, Perl, Java, Lua and obviously C (as it's the only array that's in ANSI standard afaik) support faster looking of numerically indexed arrays than doing a hash lookup or anything like that. Does Javascript also?
As an example in code of what I mean, in the case of Perl:
for(i=0;i<10;i++)
{
# Do so... |
I am a native PHP developer, and have been for about a year or so. I love PHP and it was very easy for me to learn, but I have developed some bad habits along the way due to never having a formal education in programming. It's pretty easy to get the job done in PHP without writing the best code.
I am looking to work m... |
There is a lot of information about tools and techniques for improving legacy codebases, but I haven't come across any successful real world case studies. Most advice is on the micro level, and while helpful, doesn't convince many people because of a lack of evidence it can help at the macro level.
I am looking specif... |
Recently my Scrum team has received several requests for optimizing certain parts of our code. Looking at the software with a profiler found some spots where the code could be improved.
We agreed to plan mostly based on user stories to ensure that everything we do has actual benefit for an end user, but how would this ... |
I have a number of business logic methods that store and retrieve (with filtering) objects and lists of objects from cache.
Consider
IList<TObject> AllFromCache() { ... }
TObject FetchById(guid id) { ... }
IList<TObject> FilterByPropertry(int property) { ... }
Fetch.. and Filter.. would call AllFromCache which would... |
I have a set of user queries from a search engine that I want to cluster. The only clustering algorithm I have come across so far is the K-means clustering algorithm, which requires defining the number of clusters up front. But in this case, I do not know how many clusters exist in the data. Is there any clustering alg... |
Context:
I've got a web service that deals with request / response objects. There are strict, externally-defined schemas constraining both the structure and the content of both requests and responses. I need to validate all requests as they are received and all responses before they are sent back (on the web service en... |
Context:
I recently had to deal with a class file generated by XSD.exe. It was 3500 lines long with ridiculously-verbose class / variable names (think someRidiculouslyLongPrefixThenMaybeOneThingUniqueAtTheEnd - difficult to compare at a glance with someRidiculouslyLongPrefixThenMaybeOneOtherThingChanged) and annotation... |
I have plotted my team burn up chart and its velocity per iteration. To me it looks really bad (velocity fluctuates a lot). What should I be looking for to diagnose the root cause of this behaviour?
|
I have "best practices" question about OOP in C# (but it sort-of applies to all languages).
Consider having library class with object that is to be exposed to public, say via property accessor,
but we do not want the public (people using this library class) to change it.
class A
{
// Note: List is just example, I a... |
I'm writing a custom password reset application that uses a validation technique that doesn't fit cleanly with ASP.NET Membership Provider's challenge questions.
Namely I need to invoke a workflow and collect information from the end user (backup phone number, email address) after the user logs in using a custom form.... |
When writing unit tests, should I specify the query that will be performed for interacting with the database?
I can see both sides of this. On one hand, I want to make sure that the query that I specify is being performed. But I can be making the test more brittle due to the formatting of the query.
EDIT:
Basically t... |
I'm designing a custom web-based inventory management and workflow system for a client of mine. One of their remote sites has fairly sketchy internet access, and needs to have no (or very little) interruption of business when their connection to the universe goes down.
I'm picturing some sort of local installation of t... |
I have been working on an ASP.NET MVC 4 application that uses forms based authentication. Users are validated against a membership provider based on a provider selection on the login form. For example, at this moment there are two providers: active directory and a custom provider that calls an external web service. ... |
I keep hearing that c# is "better" than vb... but as far as I can see, aside from syntactical differences, both compile down to the same IL. I've found some good articles by googling that explain what the differences are between the two and so I feel comfortable in "diffusing" conversations between developers arguing o... |
I wish to simulate a projector screen in OpenGL, where an image is truly being projected onto the wall in real time. By this I mean if an object were to get in between the projector and the wall, that portion of the image will appear on the obstructing object.
Is this functionality possible in OpenGL? And what technol... |
I am building a java desktop application where I am attempting to implement MVC. The GUI interface has multiple views (think pop-up windows) from the main view. Each view has its associated model that it receives updates from.
I am running into scenarios where two views need to access a particular data field from one ... |
I need to do complex dependency processing during the installation of our solution, install a few related programs from their own installers and also probably run a few simple tests to determine performance of the machine to choose the right parameters for our application.
I'm thinking something like Lua would be a gr... |
I'm under the impression that OAuth is for authentication between three parties. Does it make sense to implement OAuth in a context where there is just a client and server.
We have a server, and a client (HTML/javascript). Currently we authenticate via the normal "post credentials to server, get a cookie, use cookie to... |
I would like to propose a solution to our companies problem with building consistent installers for different environments. Our current process is to build an installer for test, perform testing, update app config, build installer for production.
Unfortunately this has lead to issues in the past where the installer w... |
I've really just begun to learn OOP. I started about a year ago and have written probably 15,000 lines of it. But I wrote it all with hardly any experience looking at other people's OOP.
Most of my class functions return a value or make a change to the class properties and return true/false. Some of the ones that retur... |
I've run 3 different experiments involving C++ lists and vectors.
Those with vectors proved more efficient, even when a lot of insertions in the middle were involved.
Hence the question: in which case do lists make more sense than vectors?
If vectors seem more efficient in most cases, and considering how alike their me... |
In order of importance, if its possible to do so and it may not be, what are the most important foundations of knowing how to program. Algorithms, iteration, recursion, etc?
Note that where I put etc. is where my question lies. I recently read an Internet post that said 9 out 10 programmers can't gasp program!
http://... |
Example: I have a method that formats the output based on a parameter from an object. The question is, should I pass the object that holds the parameter to the method, or just the required param?
Still trying to grasp clean coding so I might be wrong, my take is that the 2nd approach is cleaner because it doesn't requi... |
I am working on my .NET open source project for generating SQL...
Initially, I wrote the project so it spit out exactly one SQL format... ugly. I started using this project in the real world and decided it would be nice if I could generate pretty SQL in debug mode and ugly SQL in release mode.
My first go involved a lo... |
I'm not a C++ guy, but I'm forced to think about this. Why is multiple inheritance possible in C++, but not in C#? (I know of the diamond problem, but that's not what I'm asking here). How does C++ resolve the ambiguity of identical method signatures inherited from multiple base classes? And why is the same design not ... |
There is a software we run as a windows service. Its currently not designed to take a huge load. So we kind of need this service to be hosted over http so that multiple clients can make use of it. Its not the whole windows service as such, but some modules it uses. Those modules are currenly not designed to work as "we... |
For his 1990 Turing award speech, Fernando J. Corbató listed reasons why complex systems will inevitably fail. In his conclusion, he gives some suggestions for decreasing the probability of failure. He lists one idea as follows:
[U]se of constrained languages for design or synthesis is a powerful methodology. By not ... |
I am working on a GUI application which generates a configuration file. I have a class hierarchy for the configuration model and I use an object tree of that hierarchy in several different contexts. Currently, I use the Visitor pattern to avoid polluting my model classes with context specific code.
interface IConfigura... |
A client of mine is holding a conference and we have the task of creating a booking system for them. However they have requested that we use QR codes so that on the door, a person can simply present their QR code, be scanned, and boom! they are signed in.
This isn't so much of a problem because I thought well I could u... |
Why does PHP's dechex(4000) not return a signed hexadecimal value?
It returns:
fa0
As opposed to:
0xfa0
And is signed the correct term to use in describing this problem? Or is there a better term to describe the 0x portion? Is that called a prefix?
|
I am attempting to learn c# from the head first series, in addition i also consult other books such as Pro C# by Andrew Tolson.
Now the thing is that i perfectly understand the interface,generics syntax and can also use it for the programs given in the exercises.
What i find difficult is using these concepts into my ow... |
I want to understand the pros and cons in generating dynamic web application controls.
The idea is to generate all the controls dynamically based on the database procedure output and populate the controls to a say a grid structure / independent controls.
I know that creating user controls and populating to layout is o... |
I am a junior software developer and I have been working for a company less than a year.
While I always thought being a software developer means to develop software and CODE something, my tasks are more in administration type of work, such as setting up Jenkins, SQL Replication and etc.
Are these type of jobs included ... |
I am quite familiar with TCP and UDP. I understand the process by which TCP establishes connections and other theoretical facts about TCP but when reading up about TCP hole punching for NAT Transversal, I have become stumped by how connect(), accept() and listen() is done in TCP. Is it a single or multiple sockets that... |
I'm curious if there are any templates using annotations such as ambiguous, needs update and so on. Industrial or Academic does not matter.
If there are, are there any way tools available that use these annotations to show that "22% of the requirements are tagged ambiguous" and so on?
Bonus points for Academic papers o... |
Having simple code like this:
int A=5;
object X=Console.ReadLine()
if(Condition)
DoSomething();
else
DoStuff();
DoSomethingElse();
Some sources say there are actually 4 branches: First unconditional, two for the IF and another unconditional after the IF statement.
Some say there are only two branches.
What would... |
Many of the readings I've done on DDD, both in books and online, seem to represent code that, often times, is difficult or impossible to unit test. For example, there are numerous samples with static factories, calls to concrete domain classes and static extension methods (in C# samples only). I find it frustrating and... |
Does anyone know of an existing name for a bug that disappears the moment you call someone over to look at it? It's a funny phenomenon, but it has happened from time to time that I'm working on a bug that consistently appears, but as soon as I call over a colleague to look at it with me, the buggy behavior stops and d... |
I need to play devils advocate on this question a bit because I cannot defend it well because of lack of experience. Here is the deal, I get conceptually the differences between unit testing and integration testing. When specifically focusing in on persistence methods and the repository, a unit test would use a mock po... |
I'm working on a legacy system (by that I mean it was written without tests). We've tried to test some of the system by writing integration tests that test functionality from the outside.
This gives me some confidence to refactor parts of the code without worry about breaking it. But the problem is these integration... |
I understand that the model should generally consist of data manipulation and the view for data display from the model, but how do I keep my model and view layers decoupled?
My simple view has a few tables that display data. Its associated model manipulates the data based on the view's type of TableModel. Most of its m... |
I don't use design patterns very often, besides an occasional factory and MVC, and I want to start using them more.
I have a concrete case at hand that I would like your opinion on the use of design patterns in this case.
In my application I have to convert objects pretty often in different situations. I might have to ... |
I have not personally come across a situation where I've needed to use WeakReference type in .Net, but the popular belief seems to be that it should be used in caches. Dr Jon Harrop gave a very good case against the use of WeakReferences in caches in his answer to this question.
I've also often heard AS3 developers tal... |
I'm currently using an open source project called CodeFirstMembership for one of my projects. There's a critical issue that I need to get past, and the more I use it, the more I find things I need to modify. It's extremely useful, except it doesn't look like the developer has much time to update it (totally cool, we'... |
In the field of web development, is it good practice to do a POST/Redirect/GET when fields in a form submission are invalid, as well?
Typically, no sensitive transaction would have taken place, in this event. However, can an argument be made that, nonetheless, it is still good practice to utilize the POST/Redirect/GET ... |
A small group of friends (including myself) decided to develop a simple 2D game. We are all fairly new to software development, so I wanted to ask which software development model would likely work best for such a group. From the list on Wikipedia, the Waterfall and Spiral models seem to be the two best options.
Our pl... |
I am currently working on a rails project and have a requirement where I want to be able to map a country name's initial letters to its ISD code. eg: IND => 91, USA => 1, etc.
The broader question here being (notwithstanding which framework you work on), what should be the best practice to store these things.
Should yo... |
As all of us know that after IPv4 it came IPv6. How this transition happened?
I just want to know was there any IPv5 also? or there is any other logic in naming this version of IP as IPv6?
|
I have worked as a software engineer for more than 6 years. Recently, my boss has asked me to build and manage a virtual team. While I'm glad I can do some management work, I don't think it will be easy to do the management.
My team members are only part-time on this project, they come from several teams, and their di... |
According to the commonly used TDD strategy, to implement something, you write a test that fail the code first, write the simplest code, refactor, and then repeat. I am trying to imagine this scenario with implementing a flexible length list (e.g. List<T> in .net.
Let's say I first test by inserting one item. Probably ... |
Having read SO, just found this question:
if (x > y)
print (x)
else if (x < y)
print (y)
else
print (x,y)
How many branches and decisions are there? It mentiones there should be 3 decision and 5 branches, yet I cannot see how. For me I can only imagine 4 branches (2 Ifs with two possible results).
Origi... |
I've a maturing idea regarding a knowledge store.
For the purposes of this question, the store would be used by a police force for the recording and querying of crimes. I believe that historically, police forces used to hold vast index card systems, allowing cross-correlation and querying.
The knowledge store would ... |
Reading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit patterns, to use them as markers or pointers (the book mentions that WebKit uses this technique).
I'm not really sure I understoo... |
I want to read Purely Functional Data Structures. I've easily found the thesis (which is freely available as a PDF), but see that there's a book available also. So I'd like to know what the differences are, if any, between these two publications.
|
I have an existing Scala application that I am trying to refactor in order to use Akka. One of the problems I have is how to manage error-checking in actor-based applications.
Usually error-checking is done through one of two mechanisms:
either one returns a value indicating an error condition, such as Option[A] or Fa... |
What is a hidden AJAX request?
I've noticed an increase in the usage of hidden AJAX requests designed to make a user's action appear to happen immediately. I'll refer to this type of AJAX request as non-blocking. It's an AJAX request made without the user being aware it's happening, it's performed in the background and... |
I'm working on a web application that sits on top of a number of RESTful web services, interacting primarily with those services through JSON formatted messages over HTTP. Our application has a great deal of static data that are read from these services (internationalization lookups, configuration, etc.) during operati... |
I have a C#/SQL Server program that sometimes needs to store data. The data could be a response from a web service, a result of a database query, or any number of other things. There's no way of knowing before the data is stored how many fields it might have or what the data structure might be. We have this kind of pai... |
We are about to write our first WPF application and are becoming familiar with the MVVM pattern. We've built many Winform applications and have an architecture that has been very successful for us. We're having a little bit of trouble translating that architecture or determining where certain pieces of our architectur... |
I've just released a small Java library that offers only a few classes and methods. Since I built the project with Maven, I immediately used several third-party libraries to achieve my goals, specifically:
commons-lang3 (for some general Java stuff)
slf4j-api (for logging)
commons-io (for a tiny bit of file stuff - li... |
Given the concept of 'skinny controllers, fat models' and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and display' parts of requests within the Views and not the Controller? For example (attempted to keep code fairly generic):
Contr... |
We're using final builder to build a Delphi project and the person managing the build server noticed that projects with no .dres files were not building because they're not in SVN and because they're not in SVN they're not on the build machine.
So he put them in SVN.
I'm a little skeptical about the necessity of pu... |
First off, I'll admit that I'm a newbie to DDD and need to read the "blue book".
I'm building a system that has an AggregateRoot of type "Match". Each Match can have a collection of "Votes" and also has a readonly "VoteCount" property which gets incremented when a user up-votes or down-votes a Match.
Since many users ... |
I want to better write code with pen and paper. Whether it'll be in pseudocode or real code, doesn't matter.
Could you kindly advise me sources for this?
|
I have this problem called out by PMD (static code analyzer) more often that I would like, and would like to know how someone with more experience than me would write it. My code is functional but I find it inelegant, so I want to know how other programmers would write this piece.
The case is, in a network/IO petition ... |
So, we have just migrated from SVN to Perforce.
I'm having a little trouble trying to figure out the best workflow.
For Subversion, I did the following (via TortoiseSVN):
Check out repo
Do work
Update repo
Resolve conflicts, if any.
Commit my code.
Do work..
What is the best approach for P4? I know that you must open... |
I'm parsing a set of XML files of different kinds (these kinds are known in advance).
These are my requirements:
I want an object to represent each XML document (object-xml mapping)
I'd rather have a different class for each kind, so that identifying the type of the XML file is equivalent to looking at the class of t... |
Let's say I have a hierarchy of Item classes: Rectangle, Circle, Triangle. I want to be able to draw them, so my first possibility is add a virtual Draw() method to each:
class Item {
public:
virtual ~Item();
virtual void Draw() =0;
};
However, I want to split the drawing functionality to a separate Draw libra... |
I started building a web crawler and read somewhere that it's a very hard problem to find a good seed page for the crawler. Can anyone explain me if there is any pre-defined procedure/ guidlines of finding a good seed page? or how you say that a particular page is a good seed page?
|
I'm working on a project where exist one method with title
string ValidateNewPasswordExpireCurrentPasswordAndCreateNewPassword(...)
I'm sure the method name must be changed. But can't found good and descriptive alternative.
Also I can't separate method in multiple methods, like ValidateNewPassword(), ExpireCurrentPas... |
I am working on a module which is dependent on other module for some functionality. Now the dependent module provides a lot of functionality and I need only few of them, hence got the idea to create an abstraction of the same in my module which is again be a singleton only.
My question is when to abstract out and when ... |
The W3C spec on the class attribute says
There are no additional restrictions on the tokens authors can use in the class attribute, but authors are encouraged to use values that describe the nature of the content, rather than values that describe the desired presentation of the content.
Reference
I work on a massive ... |
I'm currently working on an open-source project. Currently, we put our copyright notice at the top of every Java source file.
I was wondering whether it was advisable or common practice to put copyright notices in CSS or XML files.
|
Today I read on Fossil SCM's mailing list:
The problem with BSD is that you really should get a signed form from each
contributor stating that their contribution is BSD. This is automatic with
GPL, since releasing your contributions under a compatible license is a
prerequisite for viewing the code in GPL. This... |
So I understand the importance of Polymorphism, including how vital it is. But something I don't quite understand is what about the Constructor and any inherited Class the initial Base Class may have.
For example, I have a class to test some criteria- Level of account, Windows Version, and some other checks.
// Base C... |
I have almost a 'best-practice' question that's been nagging at me for a while.
When I use JavaScript libraries and APIs such as JQGrid or Google Maps, I tend to find myself creating server side libraries to render the JavaScript for me.
For example I might have:
$map->setZoom(10);
$map->setDimensions(200,250);
in PHP... |
I just learned about currying, and while I think I understand the concept, I'm not seeing any big advantage in using it.
As a trivial example I use a function that adds two values (written in ML). The version without currying would be
fun add(x, y) = x + y
and would be called as
add(3, 5)
while the curried version i... |
I have applied and have been approached for different roles in web development recently. The one thing that keeps coming up is that I am more suited to front end development than back end development. This makes sense given my background starting out as a designer.
The problem is that while I have worked on a large ap... |
I am looking for feedback on the design of my program.
I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh in a C program. I am doing this so that I don't have to rewrite the bash functionality (in functions.sh) again in C. I wa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.