instruction stringlengths 34 19.9k |
|---|
I was reading a book on Algorithm Analysis by Micheal T Goodrich. I came across amortization technique and I got struck in understanding the proof of theorem. I am putting the theorem and the proof and the part that I need some more explanation. Please help me:
Theorem: A series of n operations on an initially empty cl... |
My idea is to write a superset of C# (but question is not language-specific), so that it source-to-source compiles (transcompiles) to C# itself (fall-through switch clauses, default method parameters etc., nothing impossible in C#).
First idea was to parse it, make syntax trees, abstract trees etc. but it seems as a b... |
I'm running tests from the same database as I use in development. I recall using Rails and I used a separate database for testing (mainly coz the tutorial I was going by said so). Made sense though. I was wondering it this was the common way to do things or whether there was an alternative. Can anyone shed a little lig... |
I'm writing a huffman encoding program in C. I'm trying to include the least amount of information in the header as possible, I know the simplest way to decompress the file in the header would be to store the frequencies of each character in the file, but for a large file with 256 characters it would take 2304 bytes ((... |
I would like to make the return type of my method an interface rather than a class for similar reasons stated in c# List or IList, however I am having trouble figuring out how to initialize the interface to return it. I cannot use new IA() and (IA) new A() does not work as I cannot cast the result to B.
interface IA{... |
After a user installs my application, where in the app's install directory should I place information regarding 3rd party software (e.g. FOSS) licenses? Should I just append it to my EULA? Is there some sort of convention or standard that I should following to make it easily scan-able by license detection scripts?
|
I have been looking into full stack developments and I am confused as I am getting different answers from people.
I know that full stack developers are responsible for front end and back end programming, but some people say that they are also responsible for designing websites as well. Can someone clarify this? If thi... |
I'm writing a game client as a personal project and using using it as a vehicle to learn about Java database access, specifically Neo4j, and possibly Spring Data Neo4j if I decide it's appropriate. I'm well aware that my application is a bit unconventional, and this has raised questions that are hard frame narrowly. ... |
In the project I am working, we are using Freebsd and we are creating our software packages for it.
Now we are planning to change distribution to Centos and rpm for packet manager. Since our codes are not platform independent, we have to make many change on it. Also we will continue to use freebsd until migration is c... |
Imagine a long and complicated process, which is started by calling function foo(). There are several consecutive steps in this process, each of them depending on result of the previous step. The function itself is, say, about 250 lines. It is highly unlikely that these steps would be useful on their own, not as a part... |
I have a Java factory method with a varargs array of Objects at the end. The array can contain any combination of Strings and ScaledJpegs. The theory being that an HTML table cell can contain any number of text nodes or <image> nodes and it will line-wrap the images as though they were just funny-shaped words.
// con... |
I've been reading about database testing in PHPUnit. I'm not exactly sure what it's purpose is. Should I use this to test schema? E.g. if I have a UNIQUE email column then ensure that I'm not allow duplicate email addresses? (I shouldn't put this in my class tests then?)
Is there anything else? I've been reading throug... |
From my vague understanding of this subject I assumed that if I make an installer for my program and it contains a GPL library my code would have to fall under GPL. However, I noticed yesterday when installing Ubuntu that its installation had checkboxes (selected by default) to install non free software.
This question... |
I'm working on learning Haskell, and I've come across three different ways of dealing with errors in functions I write:
I can simply write error "Some error message.", which throws an exception.
I can have my function return Maybe SomeType, where I may or may not be able to return what I'd like to return.
I can have m... |
I need to schedule a small number of CPU-intensive tasks to run every so often, reading from shared data and writing to dedicated buffers. I don't necessarily want to roll my own scheduling, but am unsure if libraries like Quartz are appropriate for this small of scale. I'm using Java 8 in a server environment, but wit... |
I understand what dynamic and static type systems are, and what duck typing is. But I don't understand how you can have a static language that supports duck typing. To my understanding only a dynamically typed language can support duck typing.
This answer from StackOverflow explains that "Duck typing is something that... |
For a while I have been pondering the question of, given a standard interface specification, whether there is a way to allow multiple programs to control multiple hardware devices across the network. The program I am working with is the standard implementation of the ASCOM standard.
In short, the principle is that any... |
I've been involved in helping out doing support for an open source project for a year or two now, and the project has gained a lot of popularity since I started. The program sees more than 100,000 downloads per week, and is used by more than 60% of people in its primary field, so we're obviously delighted that people h... |
I have a series of points with lengths and rotations like this:
I need to create separate chains from points whose lines overlap but I’m having real trouble doing this efficiently.
I have an array of simple Point objects, in no particular order, and I can loop through them and test them with a simple "intersect" funct... |
While browsing around on SO, I came across an answer that suggested using a try-catch-finally clause to fix the problem he was having. (A rare bug that sometimes happened to his users). Someone commented that it was a valid solution, but he said it was not recommended for production code.
Is this true? Why is it not r... |
We're using an internally-built ORM. Each table is represented by a Model class, which inherits from a base model class that has a handful of methods like GetAll, GetWhere (to get rows with specified column values), GetFirstWhere, etc. to access data from the table. There's a question of whether these methods should be... |
Specifically in regard to a drag and drop operation, how does a button, text box or whatever know that it has been clicked (or vice versa how does the display manager know what it clicked).
I read some about the COM way of dragging and dropping and I think I get the general idea: on MouseDown, detect what was clicked.... |
I think this question has already been asked many times, but I can't find any of them. I have a game project (I'm using Marmalade),and a few trusted developers, but I want to invite more. For adding some functionality, for writing scripts and so on. The question is - how can I don't give them the whole source code (onl... |
Assume an application with a rich domain model with many classes (e.g School, Classroom, Teacher, Student, Course, Exam, Submission, ...) linking to each other. Model and links are mapped to the database which uses appropriate FKs and constraints (without cascade delete). In the admin panel the user has delete buttons ... |
I've noticed that the string library doesn't require one to allocate space before writing the input/output. How does the string library allocate that memory dynamically, i know of the 'new' keyword in c++ and 'malloc' in c but when i try something like this, my program stops working.
char* str = new char[strlen(str) + ... |
I made a simple Python script that takes user input in order to generate a series of mathematical responses. In one part I did this:
while True:
And iterated through the loop until I used an if statement to break out of it, something similar to:
if answer == something_whatever:
break
I know that the examples are va... |
In No Silver Bullet, Fred Brooks makes a variety of predictions about the future of software engineering, best summed up by:
There is no single development, in either technology or in management technique, that by itself promises even one order-of-magnitude improvement in productivity, in reliability, in simplicity.
... |
I was checking out the Java 8 standard library source code just out of curiosity, and found this in java/lang/Object.java. There are three methods named wait:
public final native void wait(long timeout): This is the core of all wait methods, which has a native implementation.
public final void wait(): Just calls wait(... |
My team is new to versioning and we're trying to keep things simple, as to not overwhelm ourselves with tools-headaches. Also, our product can't be compiled and run locally, so our work is actually more like the whole team modifying a single test server.
So we're thinking that we don't want to make too many branches wh... |
Why is it that browsers do not provide a mecanism to set the printing defaults regarding headers and footers from within the app?
Web apps are fully fledged apps nowadays, and modern browsers are capable of sending a very well formatted page to a printer (or even download it as a PDF), but web apps cannot rely on this ... |
We recently moved a large application to two machines, both running the same codebase.
I. Machine A
Web server for public facing application
Receives web hook call backs from our ESP
Handles a few large, list-processing jobs (uploaded spreadsheets with data)
II. Machine B
Manages a massive set of (background) j... |
I understand protected method is good for unit testing since you can easily mock by the class by overriding the protected method for the sake of testing.
However, protected variable is just a global variable (although limited) and should be avoided at all.
Especially if you've all the essential getter/setter declared, ... |
I am working on a system that controls a label printer and occasionally the label printer will print the same label 2,3,...,10 times. The error is transient, occurring once per 3000-4000 (once a month) or so labels.
I am adding tracing to a log file to see what commands are being sent to the printer and state of the... |
Eventually, I would like to generalize this solutions to work with a Tuple of any length. I think recursion is required for that, but I haven't been able to do it.
def combineRanges(maxValues) :
for x in range(0, maxValues[0]) :
for y in range(0, maxValues[1]) :
for z in range(0, maxValues[2]) :... |
I've been reading through Introduction To Algorithms 3rd Ed, and I am having difficulty in implementing some practical situations. It's not the theory, or implementing the internals of the data structures themselves, but rather how to design a good interface that makes the data structures useful for storing real data (... |
One day I went to a Stack Overflow chat and saw a phrase, that was stating that inheritance, encapsulation, and polymorphism are the pillars of OOP (in the sense that they are fundamental, a construction sole).
Also, there's a similar question, that I have been asked very often on college exams and job interviews, and ... |
Using Reverse Lookup Tables, you create a lookup table consisting of the password hash of user accounts. Then you use another table which consists of hashes with guessed passwords. Then you compare the two to see if the hashed password of compromised user account matches hashed password in lookup table.
Using Rainbow T... |
For those of you who don't know, WCF allows you to attach interceptors to methods in the service contract. The interceptor is capable of performing custom logic before and after a method call, and is (as far as I know) used mainly for validating parameters and doing custom authorization schemes.
But what's the point o... |
There are some similar questions I've found here, but none of them fully answer the question I'm asking. Similar questions: here and here
In my company, I develop C# .NET applications and our Server Admins in IT don't allow direct table access so we're required to use stored procedures to insert, update, and delete fro... |
I need to come up with a design for real-time data update from a COTS product (a Point of Sales system) to a custom-built .NET application (an Inventory Management system).
Particularly, any sales transaction happening in POS system needs to update the inventory database (present in Inventory Management system) immedia... |
I'm always writing observer/subject interfaces in a particular Java project, e.g.:
/**
* Registers the receiver to the dispatcher.
* When data arrives that the receiver can process,
* it will be passed to the receiver.
* ...
*/
void addReceiver(IDataReceiver receiver);
/**
* @return
* True, if the receiv... |
I've used various dependency management tools for installing software: homebrew, cabal, rubygems, etc. Invariably, despite someone's simple instructions for installing their package, there are times when dependencies don't get worked out by the package manager and the installation fails. This is more common than it o... |
I have an Express app built with the Yeoman Angular fullstack generator to build an API to send JSON to Angular.
I'm trying to work out the best way to pass back information from my model to my controller, further processing may occur in the controller. I'm currently using promises. I feel uncomfortable about my model... |
I'm learning groovy and I've just learned about the new feature added in 2.3, which is the addition of Traits. Now to me it seems like Traits allow you to do basically everything a super-class and an Interface can do.
Does the addition of Traits to Groovy make Inheritance and Interfaces obsolete?
And if not, then wha... |
I am a very solid Relational Database guy and understand all the way to 3rd normal form, appreciate the algebraic set theory roots of SQL, and can probably relationalize a broken heart (or not).
I haven't figured out a relational database structure FOR date nights with my wife, but I HAVE thought about relational datab... |
Lets suppose we have a binary tree . Tree node structure is as
struct node
{
int val ;
struct node *left , *right ;
}
Now we have to sort the tree in level order manner . For example lets suppose we have original tree like this
root = 6
root->left = 1
root->right = 9
root->left->left = 8
root->right->righ... |
I reached a design/architectural issue on the large application I'm working on, at the point of writing possibles solutions on a chalkboard. Our product consist of a client-server information system whose implementation was built on REST paradigms.
A particular use case defines the use of multiple resources (most of th... |
In our organization, we are using various data access/persistence technologies in different projects. The ones used till now are Hibernate, JPA, Spring Data JPA, JDBC, Spring JDBC, MyBatis, and QueryDSL.
How do I find out what is the industry usage of these technologies? i.e. which is used more widely than others - or... |
Does any programming language exist to support the explicit, property-level object copy?
For example, assume this code:
public class Student
{
public string Name { get; set; }
public string Code { get; set; }
public List<string> Interests { get; set; }
}
public class Item
{
public string Name { get; ... |
I am trying to write an angular service to interface with a RESTful API.
For sake of simplicity, lets assume the API is
+ Company
|___+ Department
| |____ Person
|
|____ Person
Notice how person can be under Company > Department or directly underCompany.
Each of the entities (Company, Department and Person) supp... |
Should one log success of an operation within a try-catch-block, or after it?
Example:
try
do x
log('successful')
catch
log('fail')
end
or is this better:
try
do x
catch
log('fail')
end
log('successful')
I would say that a logger should never fail, but what if, for some reason, it does anyway?
In ... |
I'm working on a PHP framework called Carbon CMS. This framework will be used as base to build larger web applications on top of it. This framework should provide all kinds of interfaces such as database access, caching and so on.
Currently I'm working on the IO and file handling part of the framework. This question wi... |
What transports/pipes/interops are available that most or all languages support across OSs? Not necessarily, network, but interprocess. Or is interprocess communication OS specific? I mean, for instance, the COM interop is on windows. Is there an equivalent on Linux, for instance, that would work the same and a program... |
I have bunch of REST style web services which support XML and JSON type responses. Now I have to modify existing web services such that they provide Protobuf type of responses.
Developer who has developed these services has created three layers. Service layer, DAO layer and Processing layer.
Service layer calls one of ... |
"Minimize mutable global state" is a more or less accepted program design principle. The reason often cited is that having global state can affect two components that don't are seemingly unrelated. In other words, a component mutating global state would have no idea who else it is effecting since it doesn't know what o... |
consider the following:
(i+j)/2
i and j are both 32 bit integers and the result should also be.
But in the little equation, there's a hidden overflow, i+j could become larger then a 32 bit integer even though the result would always be a 32 bit integer.
public class Sum{
public static void main(String []args){
... |
at company we're developing quite a big project and we're arguing at the testing strategy. The question is: should all of the tests be executed in isolation of external services like database or APIs (facebook etc) or just part of them? Of course what I have in mind is using mockups.
We discussed following strategies:
... |
With centralized source control like Perforce and SVN, when they create a branch, they create a whole new directory. However, git and other distributed source control solutions, in my experience, are able to update the branch in place as it were. That is, they apply the differences between the two branches to the files... |
I've checked a few other threads around the topic and search around, I am wondering if someone can give me a clear direction as to why should I consider NoSQL and which one (since there are quite a few of them each with different purposes)
Why NoSQL over SQL?
Is MongoDB the right choice in my case?
https://softwareen... |
Here's a scenario.
I am building QueueUnderflow, a community-edited Q&A site for people who haven't yet grasped the basics of data structures. My users don't like it when people edit their posts so, because I want to encourage as much conflict as possible, I want to send email notifications whenever a user's post is ed... |
I am trying to find a way to organize the branches in my repository in a sensible way. I would like the main branch to contain only "clean" commits: features that are (mostly) complete, no superfluous code that has no role in the current version of the application, etc.
I thought that for each feature I should have a s... |
I am coding in a multitier architecture in Java, and I perform a query to a web service.
Is it better form for the errors returned by the service be handled in the data access layer or in the business layer?
For example, the service records a response something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Ret... |
Polyfilling, when is it too much?
I've summed up this question into one sentance.
Is it practical to polyfill all of the IE8 deficiencies with one solid javascript file, as in, would there be any drawbacks (performance) or blockages (impossibility to polyfill some features)?
Question Deprecation: (history)
I've been wo... |
No matter the programming language is and whatever the database is, the concept should be the same:
I have 2 threads, each locking some database entities and inserting new data in database.
Let's suppose the fact that those threads run simultanously may cause deadlock exceptions.
Obviously, the main action we can do f... |
I have a situation here, where I have a loop that loops x amount of times. The value x is determined by the user. Everytime it loops, I want it to wait for a button click before continuing the loop. ie. something like this (pseudocode):
loop(x times){
Button b;
wait until a click
when clicked{
b.onclicklistener... |
In C#, I started seeing all these magic methods popping up, without being backed up by an interface. Why was this chosen?
Let me explain.
Previously in C#, if an object implemented the IEnumerable interface, it would automatically be iterable by a foreach loop. That makes sense to me, since it's backed up by an interfa... |
My applogies for probably the worst written body of text I have produced in my life and many thanks to those willing to plough through it all.
I was (and still am) not able to clearly express what I was asking for, since by the nature of my question I cannot be clear about what exactly it is I am after. Fundementally I... |
When using planning poker for estimates, we've ended up with effectively a non-linear points scale. By that I mean that point value is inconsistent for one-pointers and, say, eight-pointers. Couple examples each:
1 point: add tooltip text to a couple of icons; format date&time strings
3 points: create new user role an... |
I have some designing problems with my project. To illustrate my problem, I'll use the following two classes from my project.
public class RAM_UserManagement{
private Map<int,User> userList;
public User addUser(User user){//do stuff}
public User deleteUser(User user){//do stuff}
public User updateUser(User user... |
I am implementing what I thought was a simple object wrapper around a database where one object "PartRecord" represents one row of a database table.
I want a client to be able to request a given record and to receive an object that contains the data. The data read and exposed properties are all a piece of cake, but I ... |
I see some of the more preferred logging frameworks like log4j, log4net etc all use 'trace, debug' etc methods.
Why do they use these instead of methods that take something like a enum level?
|
I have seen the history of several С# and Java class library projects on GitHub and CodePlex, and I see a trend of switching to factory classes as opposed to direct object instantiation.
Why should I use factory classes extensively? I have pretty good library, where objects are created the old-fashioned way - by invoki... |
Who exactly presented the idea that letter "X" should be used for closing/exiting a window or an application?
According to Medium.com,
The first appearance of [x] in GUI design was likely the Atari TOS, possibly influenced by the Japanese batsu and maru conventions. Thanks to a last minute design change in Windows 95,... |
Some books or master told us this principle: Equal or less than 15 lines per method(function), and the perfect is under(or equal) 8 lines.
Does the principle make sense for most conditions?
There are many cases break the principle in Windows OSX Android UNIX SDKs, so how to deal with the principle?
What are the excepti... |
I understand the general Erlang conventions for functions are using snake case or camel case, but what about exported functions?
For example, say I have a gen_server module that defines a check to see if a username is in use:
I have a call along the lines of handle_function(is_username_in_use, UserName).
I also have ... |
If I skip the back story and any thoughts I have on this topic, there's really only one question left to ask:
How can I find out if I have a "good grasp" on OOP?
(I am specifically using PHP, but it probably won't matter...)
Right now I kind of think of classes as a collection of functions with some global-ish variabl... |
We have completed a user story for a sprint. Near the end of the sprint there was a new functional addition requested for the same user story.
Here the user story will remain the same. ie
As a <user> i want to <> so that <> will remain the same. Only difference is that there is a new value add that is to be done.
So sh... |
Iv'e seached the internet for a while but am not able to find any examples how to test ravenDb query speed.
What I'm trying to achive is to compare two session.query and find out witch of those two has the best performance speed. How can I do that? //Thanks
EDIT:
I'm buliding a mvc Notes-app were a user can create an a... |
I see two obvious approaches to the architecture for an iOS app which needs to talk to a server to do its job.
Pretend to be a web browser
Under this approach, the app fetches a chunk of data (typically JSON) from the server in response to a user action (navigating to a new view controller, tapping an "Update", whateve... |
After asking about the implementation in Ruby of the Identity Map pattern because the potential memory leak in long running server apps, I am considering my initial concept of that pattern.
Initially I thought it was intended to cache database results AND guarantee that only one instance of the same object exist in mem... |
Should functions that return tuples, always return tuples?
For example, I have a function is_user_name_allowed that returns a tuple in this he form if the username is not allowed:
{false, ["Reason 1","Reason 2"]}
If the I want to return true, is there any convention/benefit to returning a tuple as opposed to simply ret... |
Here are some examples of 5x5 Magic Squares found by some good solvers :
Magic Square Generator by Marcel Roos
this program state using 2.4GHz Intel takes about 95 hours to generate all solutions.
open source tool
Magic squares 5x5
Sum must be: 65
Solution: 1
1 2 13 24 25
3 23 17 6 16
20 21 11 8 ... |
As developers we are always eager to learn new things and better ourselves at what we do.
You've all had moments when you look at your old code and get that feeling:
"WTH, I can't believe I used to write code like this"
Well, when it comes to long term projects that you're working on, what do you do when you look at ... |
I was explaining a proposed build system (Gradle/Artifactory/Jenkins/Chef) to one of our senior architects, and he made a comment to me that I sort of disagree with, but am not experienced enough to really weigh-in on.
This project builds a Java library (JAR) as an artifact to be reused by other teams. For versioning, ... |
If I want to put random source code snippets in a publicly accessible git repository, does it make sense to license by CC-BY(-SA) given that CC-BY licenses are generally not recommended for software? To me there is a difference between a full software project where CC-BY clearly isn't appropriate and small random sourc... |
Here is a flat version of my datamodel. It is sensor readings for various data acquisition equipment.
https://i1295.photobucket.com/albums/b628/colnewman26/Work%20Screen%20Shots/RobinDataModel_zpsdfc40151.png~original
Here is my Relational Database model. Does this make sense.
https://i1295.photobucket.com/albums/b6... |
Currently my database is not under some kind of vcs, we can get deltas but that's about it. I would like to try and make product deployments more automated, and less time consuming. I understand that placing a db's schema files under source control allow you to manage versions, and that these files are basically for dr... |
I know we have some extra advantages in using the cookies over IP address, but my question is Why can't the container just remember the IP address of the client in identifying the client when he visit his site again? Is it possible for the container to remember the client with the help of IP address?
|
I'm trying to wrap my head around this article on OSS service discovery and I'm having a tough time seeing the forest through the trees.
In that article, the author poses the main problem for service discovery:
The problem seems simple at first: How do clients determine the IP and port for a service that exist on mult... |
I've always used one class model in all 3 area's of my projects. User Interface, Hardware API (for data collection), Database (entity database context). Every new project only seems to grow in size, which means it gets hard to change the class model because everything uses it.
It was suggested to me by seasoned progra... |
Situation:
We have a desktop application.
We also have a web application.
We need the two to interact with each other. So when a button is pushed in the web application, the desktop application needs to start running a process (pulling data from the cloud using an API we've created). With two local applications, this c... |
Given:
some sort of widget based web app
lots of JS functionality
high coupling (communication/callbacks between widgets)
widgets draw themselves
certain widgets need to do a complete and fairly expensive redraw every time one of their dependencies is changed.
Problem: there can be complicated dependency chains and i... |
I'm reading uncle Bob's Clean Code and it completely revolutionizes my programming style. In this book author claims that best methods are small methods. What about controller's action methods in modern frameworks? Do you try to follow the "20 lines per method" rule, or you delegate some tasks to private methods? I do... |
I was told this is better place to ask this
TLDR
Has anyone tested dual pivot quicksort performance with expensive-to-swap elements? It seems that in this case, it should massively underperform compared to standard quicksort.
And yes, I know about Cycle Sort (if it is only the original array that is expensive to modify... |
Whether error handling by throwing exceptions is good or bad is contentious.
Are exceptions as control flow considered a serious antipattern? If so, Why?
The common line is that exceptions are for "exceptional circumstances". But what if a library author has decided to throw an exception? The library author cannot pred... |
The purpose of the algorithm is to create n routes on a geographical map, where n is being given, whereas all routes take no longer than t time units by foot and end where they start, while trying to have as little overlap as possible, meaning the user walking the routes walks on as few streets twice or more often as p... |
I came up with this solution :
if (Take(2).Count() == 1)
is there any more performance solution (or better syntactical sugar) to do this check ?
I want a performance way because this will be an extension used on Linq To Entites and Linq to Objects.
I'm not using SingleOrDefault because that will throw and exception if... |
Long ago the small team of web developer I work with started using git for web development. Back then we just committed to staging or master directly and then merged frequently between the two. It was better than nothing, but it was also a mess.
Not too long ago we adopted the gitflow work flow. While it's certainly b... |
I'm looking into building a new PHP commercial app for a client that will be hosted as a paid service and possibly resold to third parties with a non-compete clause.
I've tested a few frameworks and chose Laravel which is licensed under the MIT License. The framework itself will not be modified but the app will be heav... |
I am working in a jsp project an got stuck in a big problem.
My project consist of accounts table for super admin, reseller, admin
and users for executives and manager mapped in the account
Permission
Super admin can see or add details of reseller, admin, executives and manager, and edit its own account
Reseller can s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.