instruction stringlengths 34 19.9k |
|---|
Being a electronics engineer, I was never exposed to any algorithms. Now I am a experienced programmer and want to learn Algorithms. I started with CLRS. But I was overwhelmed by the maths in the book. So which are the minimum maths topics should I know before I start Algorithms?
Are there any good tutorials or books ... |
Is there a design pattern for dealing with overlapping UI actions and animations? A few examples:
Let's say I have an interactive table row that expands to reveal an extra control when the user clicks on it, and vice versa if they click on it again. If the user clicks on the row while the expand animation is in progre... |
I'm having trouble finding an algorithm that matches (or fails to match) a substring of a string to a suffix from a list of suffixes. The hits I'm finding are for suffix trees and suffix arrays, but they are not quite what I am looking for.
My particular problem is a fully qualified hostname - possibly malformed - and ... |
It seems to me like pre-order traversal and DFS are same as in both the cases we traverse from root till the left branch and back to root and then to the right branch recursively. Could any please correct me if I am wrong?
Thanks in advance!
|
I'm writing an app and referring to some open source, source code (copyleft licensed.)
I am not using the original source code because it's for a completely different operating system using a different language, and as far as I am aware, no-one has ported that source into the language I am using nor my target operating... |
This is the very first time that I think I want to create a program which really uses OOP principles and I want to do it in the most effective and efficient way.
First of all we are given this (great) riddle :
100 prisoners are imprisoned in solitary cells. Each cell is windowless and soundproof. There's a central liv... |
I have an API written in C, which produces a result by returning a pointer to allocated memory.
For using it with C++ (C++11) I've wrapped the function calls in objects, which keep the result in a std::shared_ptr. So far so good.
However, the C library features two functions for every operation. One produces possibly a... |
When programming, I often end up naming some generic class (think of an abstract base class for stuff you manage in your project) something like FooObject, FooComponent or FooItem (where Foo is an abreviation of project name). The problem is, that these names are used so often, they become meaningless - I mean, when I'... |
I start every .java file in my project with a license (BSD, in my case). And its first line says:
/**
* Copyright (c) 2011-2014, Firstname Lastname
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
etc.
The question is, why ... |
I have a C# .NET app that downloads a users Tweets using LinqToTwitter. This is for TV broadcast - the client wants to show Tweets on air. We have two other apps that need to access these tweets. One is a C++ app and one will use MS Script Host. These two apps don't run at the same time - it's one or the other.
My ques... |
I recently had a back and forth over at StackOverflow about my answer to this question.
The question was simple. The author wanted to transform a number into an abbreviated version that appended a K, M, or B depending on the size of the number.
One user suggested a very straightforward and naive answer:
function round_... |
My company is in the financial sector and it is using PHP as programming language. I am a PHP developer myself.
I am leading a big project started from almost scratch. I can see how PHP is not the best candidate for building robust platforms.
I want to convince my company to gradually switch to Java (which I have exper... |
Proposals for new Python features are collected in documents called PEPs (Python Enhancement Proposals). There's a master list at http://www.python.org/dev/peps/ which links to (for example):
Labeled break and continue
http://www.python.org/dev/peps/pep-3136/
Asynchronous IO support
http://www.python.org/dev/peps/pep-... |
I have a factory method as given below
public class AutomobileFactory
{
Dictionary<string, ICar> internalFactory = new Dictionary<string, ICar>();
public AutomobileFactory()
{
internalFactory.Add("fiat",new Fiat());
internalFactory.Add("ford", new Ford());
}
public ICar Create(strin... |
I am working on a project where at some point, I needed to make a decision on whether or not, in the database, I should have a single table with multiple columns that not every record uses, or multiple tables with duplicated schema.
I am creating a Sports information application which can handle multiple sports. We can... |
I've become aware of an itch due to some non-DRY code pertaining to view model classes in an (ASP.NET) MVC web application and I'm thinking of scratching my itch by organizing code in various 'partial view model' classes.
By partial-view-model, I'm referring to a class like a view model class in an analogous way to how... |
For an academic exercise, we have been tasked with creating a small website. We have already gathered the requirements and fleshed out the business domain to see the classes we are supposed to support. It is to be on Microsoft stack, so I decided to use ASP MVC with code first Entity Framework. I am now looking for the... |
I've always recognized the importance of utilizing design patterns. I'm curious as to how other developers go about choosing the most appropriate one. Do you use a series of characteristics (like a flowchart) to help you decide?
For example:
If objects are related, but we do not want to specify concrete class, conside... |
After doing some interviews, I've realized that I usually know what I want to do to solve a problem, but I often get my logic complicated (and introduce a lot of bugs) when I'm actually coding.
For example, when I tried to code up insertion into a sorted singly linked list, this is what I knew I had to do:
I had to c... |
From what I understand, each mapper outputs an intermediate file. The intermediate data (data contained in each intermediate file) is then sorted by key.
Then, a reducer is assigned a key by the master. The reducer reads from the intermediate file containing the key and then calls reduce using the data it has read.
But... |
I want to build a template engine (ITT not another template engine...) based on Razor.
I've been at it for quite a long time not getting anywhere and quite frankly I'm at my limit. I've tried rolling my own, I've tried generating using ANTLR and I reckon I just need someone to tell me if I have to bite the bullet and d... |
I usually try to follow the advice of the book Working Effectively with Legacy Code. I break dependencies, move parts of the code to @VisibleForTesting public static methods and to new classes to make the code (or at least some part of it) testable. And I write tests to make sure that I don't break anything when I'm mo... |
I have a design question. Let us say you were tasked with building a chat application, specifically for iOS (iOS Chat Application). For simplicity let us say you can only chat with one person at a time (no group chat functionality).
How then can you achieve sending a message directly to an end user from phone A to phon... |
Hi I'm new to programming, and I've always wondered what would be the point of contributing open-sourced codes if there is no way to ensure everybody who uses the code will adhere to the licenses (or is there?).
|
I'm trying to understand the use of fixtures in the context of unit testing models in a web MVC system.
The problem I am trying to understand is that fixture data does no give a true representation of the data that the system accepts.
A simple example is say I have a user model that has email validation. Fixtures will... |
I have three baskets of balls and each of them has 10 balls which have the following numbers:
Basket 1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Basket 2: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Basket 3: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
What would be the possible variations If I were to pick one ball from each basket? I... |
I am moving my companys source control from TFS to GIT.
We have TFS currently defined as.
Project Collection /
/ Client A
/ Product A
/ Product B
/ Product C
/ Client B
/ Product D
/ Product E
/ Product F
What is the best way to do this in Git? I have thought about the following:
Repository (Client A)
Branch ... |
I am working on a pricing algorithm where I want to generalize the calculation of certain components/charges. There are 3 components to the charges.
1 - a basic/core charge, 2- a handling charge (may have many number of
these), 3- tax components (may have many varieties of these as well).
I am wondering if I can s... |
I've created a ZF2 view helper PageTitle (extending Zend\View\Helper\AbstractHelper). As the name of the helper suggests , it is responsible for rendering the page title for each action view script.
So within each action view script (not layout) I would call :
echo $this->pageTitle('My Page Title', 'some-icon-class-na... |
Suppose I have this class hierarchy...
public abstract class Animal {
public abstract void eat();
public abstract void talk();
}
class Dog extends Animal {
@Override
public void eat() {
}
@Override
public void talk() {
}
}
class Cat extends Animal {
@Override
public void eat() ... |
I am using Postgres 9.3.
I have to store range data like <$250K, $250K-$4M, etc which we will display in a dropdown.
now I am making a table for all possible options that can be configured from an admin interface.
Should I take separate column for min,max,currency_type(dollar,euro) and a column to store K,M etc or ther... |
Is saving SQL statements in a MySQL table for executing later a bad idea? The SQL statements will be ready for execution, i.e. there will be no parameters to swap or anything, for example DELETE FROM users WHERE id=1.
I guess I'm being lazy, but I thought of this idea because I'm working on a project that will require ... |
You have a form that has an object injected into it. The user interacts with the form and updates the injected object via the UI. If the user then 'Cancels' the form, whose responsibility is it to undo those changes?
Should the form have created a clone of the object passed in, and return that to the client? Or should ... |
I have the Customer entity, this entity has a huge list of attributes, so you are thinking in separate in small entities (for example: "basic info", "document", "declarations", etc). This approach will be used in the view layer, where the user can fill your info, step by step, making possible stop and comeback later. B... |
I just wonder if there exists better (i.e. faster?) way to get the next
power of 2 for a given number than the following one (maybe some
better sort of "bit-twiddling" hack is possible?) ...
static size_t
npow2(size_t n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
... |
I am working on ANSI C and having some issues with the pointers.
That is that after a point in my program the pointer's values change without me interfering, is something like overwriting them.
I know that this could happen in C, but while being a beginner, can not find a remedy for that.
Is there a straightforward way... |
I'm a programing student.
I've been having problem to organize Java classes that use inheritance and static final variables.
Let say I have an abstract class named Form that has two children named Rectangle and Triangle. Those two children have a final static variable named NumberOfSides.
Both children classes need ide... |
I have a very small and basic web site on a web server. Usually I'm doing the changes on a localhost where the development version is, and after that I upload it to the server with FileZilla. That's the very obvious way, but it's not the most convenient.
I've worked with SVN, but I've never needed to set anything - ju... |
I have a software application which is currently a win forms application using an embedded IE web browser control. The win forms application provides access to an attached credit card machine and cash drawer to the web site running in the IE web control. Its does this by creating JavaScript objects in the IE web browse... |
Recently in an interview I come across a question:
We have an unsorted array, we need to sort it with minimum number of swap. We have in sort a 'tax' of 1 is deducted from the number we are swapping.
so suppose initially we have an array as
2 4 1 3 5
^ ^
on swaping say 2 and 1, the new state of the array is:
0 4... |
In a conversation earlier this week I was discussing certain language features, and I realized I don't have a good word / phrase to describe a particular feature.
Some languages, such as PHP, have a language construct which allows break and continue statements to accept a numeric parameter indicating which block should... |
I am using a function to compare over 100 variables inside of classes to each other an am curious if one method of comparing multiple condition statements is more efficient than another. I am currently considering one of these methods. I think the 'single If using And/Or' looks the cleanest but performance is more im... |
Is there an easy way to visualize the step between assembling code to machine code?
For example if you open about a binary file in notepad you see a textually formatted representation of machine code. I assume that each byte(symbol) you see is the corresponding ascii character for it's binary value?
But how do we go fr... |
I like using Hibernate for regular simple CRUD operations.
However, I am trying to understand why anyone would resort to its Criteria framework to assemble complex recordset criteria as opposed to simply creating a view at the database level.
E.g. here is a paraphrased snippet I am working with:
Criteria tableCriteri... |
I am currently looking for ways to optimize an application that is consuming unacceptable amounts of memory.
The process basically takes input and parses it into a tree. The tree is currently stored in memory. For an average input, it may consume 100 MB to 2 GB of memory. For larger inputs, it may consume up to 6 GB, ... |
I came across this question a second ago, and I'm pulling some of the material off of there: Is there a name for the 'break n' construct?
This appears to be a needlessly complex way for people to have to instruct the program to break out of a double-nested for loop:
for (i = 0; i < 10; i++) {
bool broken = false;
... |
I wanted to know if there are some default standards for writing c# code. By default I mean may be something officially from Microsoft, or any other organization.
I am looking for something where I can find answers to questions like following:
should I do this:
public void DoSomeThing(int id)
{
//method body
}
or:... |
I am the main developer of a library, licensed under the MIT license, and hosted on Github. The Github repository includes a LICENSE file.
When someone sends me a pull request, do I have to list those as copyright holders in the accompaning license.txt, or should I list these in a special section there? Am I required ... |
As far as I can tell, services like Travis CI and CircleCI take your project and run its test suite whenever you push a new change to your repository.
Assuming that it's also possible to either manually or automatically run such test suite locally before you commit or push your change, what's the point in using a servi... |
Say I have an e-commerce with a data model like the following, which allows a Sale to describe how a single Product is sold. This division allows a product to be sold multiple times in different ways (different pricing, or offered at a different point in time). This works great when a sale is selling a single product.
... |
After some discussion, I have come across a rather complicated situation. Say I intend to display an email address. I have, obviously, limited space available on the screen - be that browser or application UI. Email addresses are, however, limited to 64 + 1 + 255 = 320 characters by RFC5321, while the same RFC also cap... |
I am new to the MVVM pattern. I have a window which has 3 text boxes (Name, Address, Description), a save button, and a listview which displays the above fields. When the save button is clicked I want to save the fields into database as well as show the record in the listview.
How do I design my Model, ViewModel for th... |
I brought up in a meeting an annoyance that code changes were not commented within the code itself. We use SVN (Subversion) for source control, and it was relayed to me that you can just go into SVN and check the history and see the changes.
My question is is this a best practices? It seems easier to me to place the co... |
I am in the midst of writing a web application for work. Everything is from scratch. I have been a PHP programmer for about 13 years, Node.js programmer for the past 2 years, and have no shortage of experience with JavaScript. I love Node.js, and recently rebuilt the company's API in it...
So, in planning this web a... |
What exactly is Component Oriented Programming, and how is it different from Object Oriented Programming?
Thanks
|
I am new to MVVM pattern I have a window which has 3 text boxes namely Name,Address,Description ,a save button and a listview which displays the above fields Name,Address,Description respectively .When the save button is clicked I want to save the fields into database as well as show the record in the listview as well.... |
I'm creating an app in javascript/nodejs and using neo4j as database.
Let's say I have an entity User in my database. It has a bunch of properties, like boxes_collected and places_visited, which keep updating independently of one another throughout the course of running my app.
So far I have functions that talk to the ... |
I have a website with quite a lot of registered users, they are stored in a PostgreSQL database. I also running Google Analytics on the website to track the users. Is there a way to individually combine the GA data with the registration data from the website, e.g. finding out the e-mail address of a user we found in GA... |
I am working on a retail application where currently I'm using raw SQL like
insert into some_table values (Textbox1.Text, Textbox2.Text, ...)
and
update some_table set some_column = value
for save and update, but the problem is I need to write this everywhere that a save or update is needed.
Is there a better solut... |
Is it ever justifiable to write production-code without also writing tests for it when doing Test Driven Development?
|
Is it a good practice to put bug numbers in the file itself inside a header comment?
The comments would look something like this:
MODIFIED (MM/DD/YY)
abc 01/21/14 - Bug 17452317 - npe in drill across in dashboard edit mode
cde 01/17/14 - Bug 2314558 - some other error description
It seems helpful, but is it c... |
In Java and other high-level languages, a reference leads to an object.
In C++, as far as I know, a pointer can also lead to an object.
So what's the difference between a reference leading to an object, and a pointer leading to an object?
|
The agile approach is to structure the work into vertical user stories and deliver a focused but fully functioning piece of the application from end-to-end. Because this is the new approach to building software I read a lot of literature about why this is better than horizontal stories but I do not find much about the ... |
I'm currently working on a project with a partner where we analyze large datasets of past sporting events. There are approximately 30,000 events per year and we have historical data for five years. Thus, we're looking at analyzing 150,000 events.
I wrote our first version in Python with a heavy reliance on Pandas (grea... |
I need to encode data into a user token that describes the user's Country, State, and city. I understand that different descriptors apply to different government hierarchies, but am looking for a standard of some type that has already sorted this out.
What ISO standard, binary format, etc is best at describing a user ... |
I have an ASP.NET MVC web site working in this way:
(In the controller)
var user = _applicationService.GetUserById(1);
user.ChangeEmail("mynemail@somewhere.com");
user.ChangeAddress("my new street", "21");
(In a HttpModule)
void EndRequest(){
if (HttpContext.Error is null){
_sessionFactory.GetCurrentSessio... |
I am using Genymotion to test an app. The app is basically a browser that connects to my website. I do not have the app's source.
I do the development and testing of the website in a domain like this: dev.mywebsite.com
The app connects to mywebsite.com. Genymotion allows me to use an HTTP proxy. My question is, is ther... |
This is one of the best algorithms to calculate the nth Fibonacci sequence. It only needs O(log(n)) time to do its job, so it's very efficient. I found it somewhere but don't know how it works!
Can anyone tell me how this algorithm works?
int fib3 (int n) {
int i = 1, j = 0, k = 0, h = 1, t;
while (n > 0) {
... |
Does a cracker need to know the number of iterations a hashing algorithm uses to compute a hash?
If they don't know it, how do they figure it out? How much longer does it take to figure it out, than if they didn't know?
I can only guess that they try a number of the most common passwords, and try it with different iter... |
I've been reading about software licenses for a few hours because of the reason that I want to release a software commercially. I'm no lawyer and I'm incredibly bad at understanding licenses.
Perhaps my question is very trivial but anyways pardon me for my ignorance. So the question is if I include any standard C libra... |
I don't know if this is a good or bad idea, or if it's technically even possible... but I'd like to have something of the following sort:
public class Math {
public int gcd(a,b) // Method for Greatest Common Denominator
public int lcm(a,b) // Method for Least Common Multiple
public int factorial(a) // Method for ... |
Working on a Java and Scala code-base, there's a debate about whether to use Java's Jackson JSON or the Play Framework's JSON Library.
After reading the Play JSON Docs, as well as Chapter 9 (JSON) of Play for Scala, I also ran through an example from Mykong on Jackson.
Based on looking at a few simple examples, Play's ... |
As someone new to programming, I am building a chess web application in JavaScript, both for fun and to learn more about design patterns. I keep running into a wall, which is how to decompose the program.
To start, I have picked a straightforward representation of a chessboard, here:
Board = function() {
var turn = 0... |
In an attempt to solve one problem I encountered another. I would like to have an easy and memorable way of creating unique error numbers, across projects and across developers. The scheme I came up with was to use the initials of the developer, find their position in the alphabet, and append the date and time.
Example... |
I currently have a class Foo,
i've decided I need a second type of Foo where I want to test out a significantly different implementation. It will no doubt share some functionality with Foo so I'll need to create a Abstract Class parent for both of them.
At the end of the process I want to have:
AbstractFoo: an abstrac... |
I'm separating my software into three main layers (maybe tiers would be a better term):
Presentation ('Views')
Business logic ('Services' and 'Repositories')
Data access ('Entities' (e.g. ActiveRecords))
What do I have now?
In Presentation, I use read-only access to Entities, returned from Repositories or Services, t... |
I have a class ("Class A", we'll call it) which calculates the value of a private variable (which we can call numLoaves) with a public function. I need to use the value of numLoaves in a public function in Class B.
What is the best and most efficient way to pass in this value? I'm new to programming and have been look... |
In python a module private function or variable is named _foo.
If it is private to a class it is names __foo,
The mechanics behind how these work are different, however that is of little relevance to the question.
Why, during the design of the Python language was the double underscore characters chosen for class privat... |
In my company mostly the architect does code reviews. He is a very experienced and smart software guy, so he is very good at it. When developers do the code reviews they don't do it half as well. We tried giving developers to do more code reviews, but the quality of the code reviews wasn't good. We use Scrum for as de... |
Background:
I am writing a small/partial IDE. Code is internally converted/parsed into a graph data structure (for fast navigation, syntax-check etc). Functionality to undo/redo (also between sessions) and restoring from crash is implemented by writing to and reading from journal. The journal records modifications to t... |
When looking through Java documentation or answers for Stack Overflow / programming forum questions, I often see people referring to methods like String#format, Object#clone etc, rather than String.format.
Is this something to do with it being a non-static method, or is this just some convention?
This is quite hard to ... |
I´m with trouble, because I want to make faster my code using threads, fork in join or any kind of parallel.
I did a code using fork in join but I saw my arraylist isn´t getting the correct values.
I don´t know if is my implementation. But I want to take off all messages without attachments, later separate by sender.
O... |
I am asking this question as an extension to the following question:
https://superuser.com/questions/713409/how-to-message-any-user-on-your-lan
I don't think I have a real answer. I found it quite difficult to get the net send command working on Windows 7 and even if I could have it would have been enabled only for adm... |
Few days ago I started to read Robert C. Martin "Clean Code" book and it encouraged me to look more detailed at my code. After I opened eclipse I saw this:
entityManager.createNamedQuery("CarriageRouteEntity.listCarriageDirections");
and I decided to move string CarriageRouteEntity.listCarriageDirections to constant s... |
I didn't get a complete understanding of static constructors in Java. If it is allowed, why it is allowed? In what scenarios would you use it? What purpose would it serve? Can someone give me a simple example please?
|
Is it exists any alternative to SIP protocol? I want implement voice & video chat option in my application. I don't want use SIP, because I need only simple communication without call for landlines etc. It seems to me, it maybe doing with sockets, and audio records, but I'm not sure. I care about the fact that many peo... |
My small team and I have created a decent sized web application (~50k lines), with a fully featured API, all in Perl. As us perl hackers know.. it is easy to get sloppy. We had to port over a lot of legacy code.. thus perl whale guts code ensued.
Long story short, we were under a fairly tight time constraint which now ... |
I am going through a tutorial on OOP in JavaScript (javascriptissexy.com using OOP in JS: What you Need to know).
The instructor is explaining the Constructor/Prototype pattern of object creation. I understand what is going on, but I have a burning question that he doesn't answer!
We begin like this:
function User(name... |
Here the scenario I'm imagining. Two messages are transferred, both will require 2 packets each (I know you don't deal with packets directly with TCP, but on the IP level each message will consist of 2 packets [or segments as they're called in TCP])
The problem I'm imaging is buffering the first packet of the first mes... |
It seems the V Model is just the Waterfall Model with the bottom half of the Waterfall bent upwards to form a V. I don't see how it adds anything new.
From the diagrams, I also don't understand the flow. There are arrows pointing in all directions and I can't understand what comes first. Do we follow the V from the upp... |
I'm curious about the difference in space complexity between map and map! in ruby.
If I have the methods:
def mult_by_two(arr)
arr.map {|i| i * 2 }
end
def mult_by_two!(arr)
arr.map! {|i| i * 2 }
end
While there's no explicit assignment in the first method, it's implicitly collecting the result of the map somewhe... |
Various programming books suggest that methods should not return null values (Clean Code for example). Instead of returning null default values (0 or empty string or empty object) should be returned or an exception should be thrown. This is recommended in order to avoid many != null checks or to avoid NullPointerExcept... |
I wish to search for an integer in a vector of integer. I have two candidates for the job:
Binary Search
Find
It seems that Binary Search is the best candidate for the job as although I have to sort the vector, the total running time will be O(NLog2N) assuming quicksort take O(NLog2N) and searching takes O(Log2N).
Th... |
I have an android app in which users have sets of items, and each item has about 10 properties.
What I do at the moment:
items are stored in the server database
when the user logs in, I get all the items (say 37) via the API and put them in a LinkedHashSet< UserItem > (UserItem is a POJO with setters and getters)
then... |
Say I have a software project for which the technical documentation should include
A license document
A list of used terminology
An introduction about what the software does
A short quick-start guide
Complete documentation of tools covered by the project
Documentation of file formats and protocols
An API Reference
A l... |
On StackOverflow I found multiple advices to stick with BigDecimal in Java instead of reinventing the wheel.
Despite that, I decided to create my custom class, and I would ask if that was a good idea and pros or cons about my design in comparsion to BigDecimal. The reasons to choose custom implementation and characteri... |
I'm currently in a high-performance computing class taught in C++. Usually, I do work in C#, meaning everything is taken care of for me, and optimization comes behind maintainability and higher-level features. It's like... a nice productivity furnace that keeps me nice and warm in the programming project winter at the ... |
I am creating a MVC-ish framework in PHP. I am trying to implement a DI Container to allow the creation of controller objects (among others).
My MVC framework is pretty typical. Each module (or component if you wish) has a controller responsible for executing requests. These module controllers typically extend a base C... |
I need a simple enum declaring the Java reference types, as:
public enum ReferenceType {
STRONG, SOFT, WEAK, PHANTOM;
}
Does such enum exist somewhere in the Java API or a general utility library such as Guava ? I have not been able to find it in either place, although I found third party projects that declare it ... |
Intro/Question
I fear that frameworks in many cases have become a fashion or trend and are being abused. In many ways people are sacrificing speed just because they want to keep up with every single lib that comes out. I am for a more conservative approach that only makes use of new libraries and frameworks when it abs... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.