instruction stringlengths 34 19.9k |
|---|
This question applies to both parameters and arguments, since I've seen this style used in both.
I usually write parameters like this
someFunction(arg0, arg1, arg2)
but I've recently noticed that many people write theirs like this
someFunction(
arg0,
arg1,
arg2
) // the bracket doesn't have to be on its own line
I ha... |
I have some windows c++ code (pure winapi c++, no MFC etc) that I would like to build a GUI for. My code does not know about windows GUI, it is completely decoupled from any type of UI.
The question: How could I build a UI around the existing code. Ideally, I am imagining something like this:
GUI <--> Mediator <--> MyE... |
I'm coming from a Java background and trying to learn Scala. At the moment I'm feeling pretty overwhelmed, there seems to be so much more to learn with Scala, so many different ways of doing the same thing.
I was wondering if anyone has any advice on where to start, and how long it took them to feel reasonably competen... |
How is the end() function implemented in deque-STL of C++ with array?
As per my knowledge it returns past-the-end element. But when a loop is run like, for(i=deq.begin();i!=deq.end();i++) and the whole array is full (suppose size=4), then I think end() will point to the position where begin() is pointing, in this way i... |
Why
for(k=1;k<=n;k*=2) grows logarathmically = O(logn)
but I feel it grows exponentially, as the seq look like 1,2,4,8....
and for fibonacci series people say it grows exponentially.
which for me doesnt look like 0,1,1,2,3,5...
but for tis they tell O(2^n).
PLease explain
|
I am a QA/Test manager in my organization and until today I verified the quality of the software (tests written and executed and bugs fixed). Who will verify this in Scrum? How do I know that the team wrote and executed all the right tests? On the other hand I'm afraid that if I continue to do the verification the team... |
I know many people have asked the same question but I think it really depends on the type of the website. So that's why I am asking the question about my website.
I am developing a PHP web application for an insurance company. the application contains all information about the customers but this app is only used by the... |
Given a string variable variable, for example, the convention to expose it is:
public class SomeClass {
public String variable = "";
public String getVariable() {return variable;}
public void setVariable(String variable) {this.variable = variable;}
}
Which looks like:
class.getVariable(); // Gets "variable"
class.s... |
There are several times where you're coding a method which has two parameters with the same type, lets say, integers, NumberOfUnitA and NumberOfUnitB. Given that we're coding in a language that doesn't support named parameters, why is that we don't see people creating types closer to the domain logic, in this case, Uni... |
Recently, I came across a number of open source Ruby (or majority of it was Ruby) projects on GitHub that when checked with a code analyzing tool like Rubocop, create a lot of offenses.
Now, most of these offenses include using double quotation marks instead of single quotes (when not interpolation), not following the... |
Now I'm thinking about the architecture of my program. I plan to provide access not only for Desktop usage, but for mobile platforms as well.
I want to create a bpl package as separate file. That is I want to have in Windows version next files: program.exe + logic.bpl. It can be usefull because logic.bpl may be often ... |
Scrum advocates assume that a team without a designated team leader (as it is in Scrum) is more effective than a team with a designated leader (as in traditional hierarchy). Although I can understand this point of view, I am not entirely certain that's the case.
In Scrum teams leaders always emerge. Power vacuums get f... |
I'm new to C# coming from a Java background. I'm working on a take home assignment for a coding interview. I normally write my code as following(Java):
public class Test {
//fields
private string fieldA;
private int fieldB;
public Test () {
//.....
}
public String getFieldA() {
return ... |
We all know that it is good to use descriptive identifier names. However, the convention in java is to use a single letter for a type parameter identifier. The default most people go to is T, but if you are dealing with elements in a collection, you often see E. Now I can see how it makes sense to use single letter ide... |
I'm working on a social network website and I'm not quite sure when I should store the date/datetime. The service includes some of the following events:
Register/Login
Follow
"Like" (images & comments)
Post a comment
Post an image
In my eyes, I would use DateTime for all of them... Although I'm not sure if that's pro... |
I've been thinking of creating an online database creator (think DabbleDB, Zoho Creator, Intuit Quickbase, etc.).
I've been thinking of a couple solutions:
Have 4 database tables: Tables, Rows, Columns, Items. To create a database as a user, you'd go to the "Add New Table" page, give a name and type to as many columns... |
Earlier, I was messaged about a potential security risk in one of my projects.
I checked it and found that it allows for "arbitrary code execution". (Quotes because it is running in a VM, but the damage that can be done is huge nonetheless)
Since it is an open source project, I imagine other people have found it and ex... |
I've recently realised that my workplace doesn't comment their ASP.NET MVC applications. By 'doesn't document', I mean there is probably 1 line of comment per model/view/controller. No file purpose, date created etc. The excuse is that the MVC should be self documenting, with skinny controllers, self-documenting view c... |
I'm new and I am trying to figure something out. I have a simple program which executes a method either when an event happens or when my timer ticks. Lets just say the method takes 5 seconds to complete. During that 5 seconds an event could happen. What would I use/do to make sure my method isn't called while its alrea... |
I am trying to understand how and where to implement domain model factories. I have included my Company aggregate as a demo of how I have done it.
I have included my design decisions at the end - I would appreciate any comments, suggestions, critique on those points.
The Company domain model:
public class Company : Do... |
I am starting to learn Lisp, using the SICP book. The authors mention that a procedure (i.e. function) can be recursive or iterative. Additionally, the process those procedures will generate will also be recursive or iterative, and that, surprisingly, a recursive procedure can sometimes generate an iterative process.
T... |
In my organization when we move a task to the "Done" column we write the number of hours it took to complete the task. It can be useful when during retrospective the team tries to understand why certain stories took longer to implement than anticipated. However it is also burdensome and developers feel somewhat microma... |
I'm currently working on a php frontend. Specifically, the authentication process.
I'll spare everyone the exact details of the decision tree, but it includes a lot of checks and about half of them branch to a call to do_logon() which generates the login page and then calls exit to stop processing further.
Currently, I... |
Most Java applications don't look the same as C/C++ applications. Swing might have been designed on purpose to have a distincitve look, but based on what I've read, SWT for example tried to 'look native', and doesn't completley succeed.
My question is:
Why is it hard for the developers of the Java language to design a ... |
Assume we have an abstract class having several concrete classes which
interfaces publish an information under several equivalent forms, with
the difference that each class has a preferred form which can be
consulted at no cost while consulting the others might require a
time-consuming computation. How to implement a ... |
In iOS, the coordinate (0, 0) means the top left corner. In macOS it is the bottom left corner.
What is the Apple's rationale or technical advantage of this coordinate system?
|
My manager wants me to refactor a gigantic amount of terribly-coupled, macroed, full of private namespace methods, hierarchy-perverted (even 10+ levels of inheritance) code which hasn't been (indeed) designed with a "whole-vision" concept.
I tried to explain to him that this code needs to be rewritten, not just refacto... |
I want to write a refactoring tool for the Java programming language.
For this reason I need to do structural queries against the abstract syntax tree. Given this AST how do I get answers to the following statements:
Get superclasses of an object.
Give me the expression where I call a method x() on type XClass
Is meth... |
I am interested in finding an approach that will detect what language a string of text is. As Google translate does.
|
In my Android application, I am using a couple of open source libraries. The only requirement these libraries have is that I must show their respective copyright notices in my application. I am trying to understand where would one typically display third-party copyrights. I could probably create a menu item "About" and... |
I have a large (≈ 20 million nodes) directed Graph with in-edges & out-edges. I want to figure out which parts of of the graph deserve the most attention. Often most of the graph is boring, or at least it is already well understood. The way I am defining "attention" is by the concept of "connectedness" i.e. How can i f... |
Tried to search the web and couldn't find an answer. It might have something to do with "load", but that doesn't make much sense to me.
Obviously, "ln" was already taken, but where does that "d" come from?
|
There are a lot of algorithms which will tell you whether or not a given point is found inside a polygon.
I'm looking to write an algorithm which, given a non-convex polygon, will return a point which is inside the polygon.
I don't need the point to be in any specific location inside the polygon, but I prefer to rece... |
I have a codes table that stores name value pairs and a group name.
So for this example let me demonstrate with two rows, each row would represent one value in the same drop down.
Group Name = 'Drop_Down_1'
Name = 'Value 1'
Value = 'This is my value'
Group Name = 'Drop_Down_1'
Name = 'Value 2'
Value = 'This is my value... |
I have encountered the following pattern while programming in Haskell (but the pattern could occur in any language supporting lists, option types, and mapping of a function over a list). I have types a and b and a function
f :: a -> Maybe b
Now I want to define a function that maps f on a list of type [a], but I am no... |
What's the name for a class that has only methods? There are no fields/properties. Just two methods with the ability to parse some file in two ways. I have named the class Parser, but it just doesn't seem right to have a class do only that. Or?
Should it be in a class ?
EDIT:
Dummy Example
class Parser
{
public in... |
I can understand this:
List("one word", "another word") unzip (_ span (_ != ' '))
But don't get what's happening here below in the span. span takes a predicate and I think the braces can be omitted as span is used inline and has only one parameter but why isn't there any _ and what is ' '.!=
List("one word", "another ... |
So I've taken on a project at work that I'm having a hard time attacking, and I'd love some feedback and suggestions.
I work for an online retail store where we have an old, +7k-line script that we use to create various product feeds (mostly for CSEs like Google Products, Pricegrabber, etc). It's become a complete mes... |
Some quick background - we don't have PMs or upper management breathing down our necks about status of features, etc, as we almost always deliver ahead of time and have built up a high level of trust with them. In other words, we have a huge amount of flexibility as far as process goes. We do very well with our current... |
I have recently come across a requirement related to our release/SDLC process that seems a little out of the ordinary to me so I am writing this to inquire whether this practice is common and, if not, whether our deployment process should be changed to eliminate a burdensome constraint.
I work for a small software shop... |
We are considering using BitBucket rather than hosting our Git repositories internally. Does anyone know if this breaks any rules of PCI compliance? I haven't been able to find much information on this.
|
I don't work too often with Java/C# iterators directly but when I do I always wonder what was the reason to design iterators in "next" fashion.
In order to start you have to move iterator, in order to check if there is some data you have to check if there is next element.
More appealing concept for me is this-iterator ... |
I'm creating a fictional architecture and other fictional components for this computer/emulator. I'm facing an issue, this being the virtual display.
I need to be able to create a Window in which my program has access to all pixels contained inside, this is to emulate video memory/access.
For the best speed I was thin... |
I have two plug-ins. One has the GNU LGPL 3 license and the other has the Apache Software License, Version 2.0. Can I use them in my commercial app?
And if yes, what precautions should I take?
|
What algorithm would pair parcels with a high proportion of property x to a parcel with a low proportion of property x so that the weighted average of the two parcels falls within an upper and lower bound? The algorithm needs to pair a set of parcels to maximise the quantity that fall into the given range. The parcels... |
My organization was flat two years ago, and people felt that the general manager had disproportionate almost dictatorial powers. Also the general manager didn't have time to coach employees, so some employees were dysfunctional and nothing was done about them. However on the plus side everyone was involved in the decis... |
Before forming a class in Java or other programming languages that support OOP, should I use underscore (_) in each (local or private) field declaration.
More precisely:
private String _customername;
Is this a correct declaration?
|
When you are reading about web application development, "front controller" and "single point of entry" are frequent words you are confronted with. To my understanding, the point is to provide a single location where you decide what to do in your program. That's all nice and well in theory, but I am confused as to how t... |
We are a small team of programmers, and we are now facing a situation where we have to outsource some of the work in order to complete it in time.
Project is about website that was previously build with asp.net webforms, EF and SQL server. We have previously build a data layer and optimized SQL, but we need to complete... |
I have inherited an API implemented using ASP.NET WebApi 2. The actions on the controllers are all like this:
public object Get(long id) {
LoginContext loginDetails = GetLoginDetails();
if (loginDetails.IsAuthorised) {
return _dependency.DoSomething(loginDetails, id);
}
return new HttpResponseM... |
I came across the idea of using function points as a metric for the velocity of a Scrum team. I saw it in a team and I found two articles mentioning a link between estimates and function points (http://www.ifpug.org/ISMA5-2010/Amol%20Keote-FunctionPointsAndAgile-Hand-in-Hand.pdf and http://www.cosmicon.com/portal/publi... |
has there ever been a proposal for establishing a formatting style file for programmers? In web programming, we have CSS files that help separate style from 'code', so two people can see the same code while each can see it in his/her preferred way.
I was thinking something like this could theoretically be achieved for ... |
I recently put up a project, called Hebel, that I've been working on to GitHub. It's a framework for GPU accelerated deep learning written in Python and Nvidia CUDA. I posted about it on Google+ and soon afterwards it was picked up on Hacker News and went slightly viral for a few days. I later posted about it again in ... |
Few days ago, I started to work in new company. Before me, all front-end and backend code was written by one man.
As you know, Django app contains two main directories for front-end: /static - for static(public) files and /templates - for django templates
Now, we have large application with more than 10 different mod... |
Background
I'm been contracted to help a company maintain their server. I work on some minor PHP projects but also look over performance issues and recently, scan logs for hackers.
These guys have been running their server for some time and have what I would call a legacy application on its last legs. It uses magic quo... |
So I have the following code, which connects and then binds to an LDAP server.
The question is in the first method.
public function getUsers() // This is the method in question
{
if( $this->connect()->bind() ) {
ldap_query(self::$connection) // Here, should it be aware that class succesfully loaded
... |
I currently have a .NET app that I want to convert to being cross platform, as a growing number of my users want a Mac version. Since this forum doesn't seem to like questions that are "what languages are suitable for these requirements", I'll focus this question on Python as the language of choice. Will Python be a ... |
I'm refactoring code and have reached a horribly gigantic switch statement. Every single API method available to end users is represented as an enum and we have a switch statement iterating over the enum and responding to each possible API call.
Each individual enum option has only a few lines of code. Any sufficient... |
I need this algorithm for one of my projects. I will paraphrase the problem.
There are 'n' ropes that have different colored rings on them. (The colors might repeat on the same rope or across different ropes).
My job is to pick a few of these ropes and join them such that all the colors in the n ropes are included in t... |
I'm having trouble understanding a past quiz question I got:
Bobby works at Starbucks in San Mateo (V). He is doing quality assurance testing and needs to visit stores in Palo Alto (B), Tenderloin (C), and San Jose (S) - and then return to San Mateo for a meeting.
The distances between the stores are:
V→B = 2
V→C = 3
V... |
I'm working on an algorithm which routes tasks through a chain of distributed resources based on a hash (or random number).
For example, say you have 10 gateways into a service which distribute tasks to 1000 handlers through 100 queues. 10,000 connected clients are expected to be connected to gateways at any given time... |
I have started using Pivotal tracker for a project I'm working on. Conceptually, this seems really cool and I'm interested in using the agile model. However, I have one problem with everything talked about in the video.
At 4:19 in the linked video they talk about story acceptance and how it should be done by the proje... |
My team is considering a department goal of doing Test Driven Development next (fiscal) year.
TDD sounds good and my manager is on board. The only problem is measurement.
Our company rules require that department goals be measurable.
Is there any (sane) way to measure if a team is doing TDD?
Note: We had a goal for ... |
I need some ideas on how to protect a private API key in an application, specifically in a c# .NET application.
Firstly, I understand that it is theoretically impossible to hide anything in the source code, so I came up with another idea, but I'm not sure how plausible it is. Anyway, would it be possible to somehow com... |
I'm working on designing a new programming language and trying to decide how I will do variable comparisons. Along with many different types of languages, I've used PHP for years and personally had zero bugs related to its comparison operations other than situations where 0 = false. Despite this, I've heard a lot of n... |
I am currently a software developer on coop that was in an interesting situation today. I cannot say too much, as the things I do are under NDA, but I make Grasshopper 3D (which is a Rhino plugin) components.
Our firm has under three software developers including me. We all specialize in different languages. This proje... |
Is there any decent work around to PHP's lack of Generics that allow static code inspection to detect type consistency?
I have an abstract class, that I want to sub-class and also enforce that one of the methods changes from taking a parameter of one type, to taking a parameter which is a sub-class of that parameter.
a... |
I've been reading up a lot on Domain-Driven Development, and I came to the question of how to preserve lack of distinct identity with value objects (VOs). While in the DDD world, this is a requirement (yet I'm not sure I understand the full power of this) it poses problems for the lower ORM layers in terms of persisten... |
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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.