instruction stringlengths 34 19.9k |
|---|
I've noticed that a coworker and I have opposite practices regarding the ordering of methods in our Java classes. One of us begins a class with its major public methods, and then put all of the private helpers afterwards. The other one of us makes sure that public methods are at the very end.
Clearly, this is just a st... |
I know this has a great chance of being marked as duplicate, but couldn't find exactly what I'm looking for
This is a common problem and I'm sure it has some well defined best practice solution
Background
A single page SaaS app, has lot's of drag and drop, user can
interact with it without much server communication fo... |
I am currently working on a project that makes use of the OpenSSL library for secure communications. Since this library is a requirement for building the project, I am considering including it in the project's repository. Here are the pros and cons as I see them:
Pros:
Self-contained build - with one exception, everyt... |
I have read at many places including this - http://msdn.microsoft.com/en-us/library/seyhszts.aspx - that you should use exception handling when something is truly exceptional.
The .Net File.Open function throws FileNotFoundException, etc. instead of returning error codes. Now it can frequently happen that the filename ... |
Consider the following code, in which the setter is deliberately broken due to a mundane programming error that I have made for real a few times in the past:
<?php
class TestClass {
private $testField;
function setField($newVal) {
$testField = $newVal;
// deliberately brok... |
Let me preface this with saying I am not a Business Intelligence (BI) developer. I'm a .NET developer, and I have only a vague notion of what BI is, and encompasses.
I've been an evangelist for a secure development lifecycle in our company, and recently convinced the rest of the development team that we should be doin... |
C is the best language (or maybe the single language) suitable for operating systems, drivers, embedded systems etc. For more complex domains like computer graphics C++ is a better choice. But these applications have thorough performance requirements and they are only feasible to be built in C/C++.
Now the question is,... |
I wrote this class that does a few things (perhaps this is a violation of the Single Responsibility Principle). I realize now that some other part of the project needs a piece of that logic and the way I'm going to expose it is to extract a class out of my original System Under Test.
I anticipate being able to do this... |
I wrote a sync tool to synchronize folders/files from Alfresco to Windows.
PROBLEM:
In Alfresco, /files/can/have/very/very/very/long/filepaths/like/this.txt
The Windows API prevents me from creating a path with more than 260 characters.
In addition to telling the user there is a problem, what is the best practice in ... |
Just moved this question from Stack Overflow. Since, adding my code snippets itself would make this question really long. Instead, I am pretty interested in knowing a better ways for data retrieval on application that needs to handle limited amount of data which isn't updated regularly. Let's take this example:
I am wr... |
I'm building a web-app where users can keep track of who owes whom money.
I have users and debts.
Given a user I want to be able to find out all the debts to other users, and all the loans to other users.
Given a debt I want to be able to find out who the debtor and lender are.
The asker of this question ran into a sim... |
I have across a thread mentioning that Erlang would not be suited for a web application serving files.
I was curious whether anyone had any experience building such webservice with erlang? Would Haskell be more suited for this, if so how ?
|
I have a site where a regular user can delete records, where what happens is that an IsDeleted flag gets set. On administrative pages, a privileged user can delete records where an actual SQL DELETE permanently discards such records. The difference is important for obvious reasons, and I want to use a consistent term t... |
I have started a project where I need to design an application that will work as a code-block editor, much like lego mindstorms and this google project. http://code.google.com/p/blockly/
What are the possible approaches for designing such an application in Java?
More specifically, assuming I have one block A, how can I... |
I would like to study the source code of the standard command line functions in Linux such as ls, echo, cat, etc. But I have been unable to find the source code (a Google search was useless).
Does someone know where it's available? I know it's a naive question but I really can't find this source code.
|
I am a young engineer recently employed at a small company that sells products to the general public. We use Ruby On Rails and MySQL. Our database has a lot of customer data, but a great deal more of "static" persistent data. This data is so rarely changed that some of the more senior engineers have begun to talk about... |
I've always been taught that having side-effects in an if condition are bad. What I mean is;
if (conditionThenHandle()) {
// do effectively nothing
}
... as opposed to;
if (condition()) {
handle();
}
... and I understand that, and my collegues are happy because I don't do it, and we all go home at 17:00 on a ... |
In C# it is legal to write
Animal[] a = new Giraffe[4]; //with obvious relationships
Because arrays are covariant. However, this is a breaking relationship. It's a runtime exception to then apply a different type of Animal to this array because the backing store is a Giraffe.
a[0] = new Cat(); //KABOOM
Why doesn'... |
Say I have:
interface Thing
{
GetThing();
}
class FastThing : Thing
{
public int GetThing()
{
return 1;
}
}
class SlowThing : Thing
{
public int GetThing()
{
return GetThingFromDatabase();
}
}
Is this a violation of the Liskov Substitution Principle?
|
On a number line of length M, where 0 < M <= 1,000,000,000, you given N (1 < N <= 100,000) integer pairs of points. In each pair, the first point represents where an object is currently located, and the second point represents where an object should be moved. (Keep in mind the second point may be smaller than the first... |
I am deeply confused the difference. I've read so many definitions and they always explain functional test as testing the requirement is satisfied. Well, that's just rephrasing the name functional test. That doesn't clarify the difference.
I am interested in some real code to demonstrate the difference.
Suppose we have... |
Erlang, Go, and Rust all claim in one way or another that they support concurrent programming with cheap "threads"/coroutines. The Go FAQ states:
It is practical to create hundreds of thousands of goroutines in the same address space.
The Rust Tutorial says:
Because tasks are significantly cheaper to create than t... |
If a server certificate is published to Github, a la:
-----BEGIN CERTIFICATE-----
is that necessarily a bad thing? Is there ever a legitimate reason to do this?
I ask because of a recent wave of attention Github has gotten since allowing users to search for certain things as .ssh/id.rsa and the like in public reposito... |
I have a Silverlight application that uses Entity Framework.
The application are protected with a login made in ASP, so only valid users get the xap file.
Have do I secure the WCF calls to the Entity Framework? I have to make the calls over https, but have can i make sure that only valid users can get data from the WC... |
I'm starting a game project in C++ using the SFML.
It provides various classes for handling graphics, input, etc, but I would like to wrap it all up in a single Media class.
I believe that by doing so, I could simplify my effort and have the class take care of the details, limiting the amount of code I have to write an... |
I'm doing a full-time job (developer) and at the end of the day, I work on my part-time job (developer).
How do you work, with different projects, without loosing focus? Often, my focus on the full-time job still remains at my head when working on my part-time job or the other way around.
|
I've read plenty of articles around different patterns in use with WPF and this is something I've yet to understand: should a code-behind file be considered part of the view? As a consequence, should code-behind files be allowed utilise knowledge of specific elements in the markup?
I have a number of scenarios where th... |
I'm rewriting somebody else's code at the minute, and I came across two classes which reference each other directly and call methods on each other. Like so (example in C#):
class A {
B otherClass;
public A() {
this.otherClass = new B(this);
}
// Other methods here call methods on B
}
class B {
A otherCla... |
I've been programming in various languages for about 10 years now. And I still haven't figured out when it is a good idea to import something into the global namespace (using x::y in C++, from x import y in Python etc.), so I hardly ever do it.
It almost always seems like a bad idea to me, if only because it limits the... |
I want to know the differences between normative and informative annexes in Ada 95.
I am just able to find a list of each of them but not the differences. What are the differences?
|
I have a problem with Visual Studio 2012 and Environment Variables under Windows 7.
I added a variable called {LIBS} with the value C:/libs/.
In C:/libs/ are folders containing C++ libraries.
So far, so good. I added the paths to the project's settings (linker etc.), like {$LIBS}boost to include the boost libraries.
I ... |
In the long debate of using arrays vs lists in the public API of Java classes, I tend to prefer lists in most situations.
However, I also found convenient to use var arguments in many constructors and methods, which require declaring an argument of the method (the last one) as an array (implicitly adding "..." before t... |
Years ago, I used to suggest Visual Basic 6 to rank beginners as a way to learn what programming is. Key point: This was NOT for career training, but just as a primer to the basic concepts of programming. I subscribe to the KISS principle (many programmers do not) Detest Microsoft as we may, the instant graphical... |
I plan on migrating a website from PHP to ASP .NET MVC. However, since the website is large and this migration can't be done in a short time I plan to use both MVC and PHP pages together. So the idea is to replace each PHP page or group of pages with an MVC equivalent.
I have to refactor each page and rewrite it overa... |
I'm interested in the conceptual (programming language agnostic problem) process of sending a game object to another player of the game in exchange for another game object without a face-to-face online presence of both parties. This should be done so that in theory in game exploitation of inherent bugs of the trading s... |
This is one of the definitions that I asw for user stories -
When the time has come for creating user stories, one of the developers (or the product owner in Scrum) gets together with a customer representative. The customer is responsible for formulating the user stories. The developer may use a series of questions to ... |
Some development teams in my company are switching to Agile development practices and their developers' work seem to be diminishing to discuss and program minutia about trivial software features because of two week iteration cycles. And also because of "any developer can fix any bug" mentality. I have recently joined o... |
I'm developing a suite of software tools that I need help with which is why I want to release my software open-source. People should be able to use and modify my code as they please while contributing to my project. Ultimately, the tools that I develop will require a paid commercial license, but may be free to those fo... |
When I read pro and con lists of using Entity Framework (or any modern ORM really), I'm surprised that the following point doesn't arise (self quote):
Using strongly-typed domain entities allows for type checking at
compile-time which essentially performs a verification of all your
database operations. This is so... |
I am doing some research on the ScalableColor descriptor in MPEG-7 and I came across this passage:
The descriptor extractions starts with the computation of the colour
historgam with 25 bins in the HSV colour space with the Hue (H)
component quantised to 16 bins, and Saturation (S) and Value (V)
quantised to 4 ... |
What traits / skills does the Business Intelligence Developer role expect over a traditional Web Developer role?
|
I'm currently working on a project that need to be dynamically scaled on demand according to the need.
My question is about scaling spring context. My web application has a classical multi module core (service, persistence, domain), which use use by client application (webapp, api).
The user end application could be cl... |
This may be very naive, but I was wondering, it the context of binary trees (plain, sorted and balanced), of all the traversal types:
depth-first pre-order
depth-first in-order
depth-first post-order
breadth-first
what's the actual utility of pre and post-order ones? I mean, is there some type and/or configuration of... |
Recently i was re-visiting the basic concepts of operating systems. Since I am a java developer, I have inherently started looking at everything from java point of view. I am also reading 'Inside the JVM fundamentals' from
http://www.artima.com/insidejvm/ed2/jvm.html
so when I see the basics of operating systems and JV... |
We have a tricky question in a project using Java & Hibernate, with a model containing bi-directional relationships.
As it's a small project with few users, few entities, and few rows involved in relationships (not more than 100 in 1-n relationships), we don't really need a 2nd level cache.
Operations done with entiti... |
The organisation I work for has recently employed a testing officer to run manual tests, but when I asked about being given time as a developer to write unit tests the response was that the manual testing would provide a bigger bang for the buck. That is something that feels wrong to me and I'm looking for a means to r... |
I know that when building applications (native or web) such as those in the Apple AppStore or Google Play app store that it's very common to use a Model-View-Controller architecture.
However, is it reasonable to also create applications using the Component-Entity-System architecture common in game engines?
|
I have a list of varying length where items is strings of varying length. I want to print them by (a mirrored N)/order by column.
Major points being:
Columns shall have fixed width == widest data in that column.
It shall be as compact as possible.
Number of columns is varying/induced by available width of canvas.
Or... |
I've recently been working on a project and I've been seeing two different forms of url's being used.
src="../MyLinkUrl"
and
src="/MyLinkUrl"
We are using MVC .NET and the times I have seen the .. usages have been in Javascript code files and not when it's been generated by the MVC URL helpers. Typically the usages ... |
Has anybody got an idea why the area of main memory where objects are allocated is referred to as the heap. I can understand the rationale for that of the stack LIFO but would like to know what the rationale is for the 'heap' name.
|
I'm using Shiro as my security manager for a Spring MVC web application.
The login basically happens in these lines:
Subject user = SecurityUtils.getSubject();
user.login(new UsernamePasswordToken(username, password));
Where should I put this logic? login() can throw exceptions if the requested user doesn't exist or ... |
This website is supposed to be a game where the players have some 'buildings' and these buildings produce resources. E.g. an iron mine may produce 30 pieces of iron ore per minute and automatically add it to the user's inventory. It doesn't matter whether the user is online or not, it should be running 24/7. So when th... |
I have a silverlight app that connects to a entity framework over WCF ria service.
These calls have to be secure. What can I do so only valid users can call the ria service, and to make the call secure?
The user has to log in to get to the silverlight app, so maybe that login in some way can be saved for authenticatio... |
I've read in multiple places that the requirements must not be influenced by solution and must not contain solution. So in the below example , please can you help in letting me which is correct -
Application A is interacting with Application B to install a new service / change the service type and disconnect a service.... |
Do you think that using akka actors in front of transactional service beans, is a good idea ?
Actors are waked up by a facade used by a client application, and actor use a message to handle right service call.
Is it a good practice ?
This article (http://honeysoft.wordpress.com/2012/08/05/akka-actor-dependency-injecti... |
I recently started at a new company, with a handful of programmers. Its a medium sized company, with around 70 employees, but IT only has 9-10, and there are 3 "programmers" beside myself. However, these guys have very limited experience and are doing a lot of stuff really terribly. For example, one of our projects is ... |
I currently report my production exceptions to a mysql database, where they have been collecting dust for the most part. The problem I faced is grouping the stack traces. I would like to be able to see kind of an aggregate of the stack traces that are the same, so that I can work them into the workflow.
I know one issu... |
I just learned you can write
'{}{}'.format(string_a, string_b)
instead of
'{0}{1}'.format(string_a, string_b)
in Python, i.e. you can omit the numerals for the string format parameters when you want things to slot in one by one in order.
Is this considered Pythonic?
NOTE: "Pythonic" is a commonly used term among Py... |
I am working with a trading application (reading data from the exchange) which generates a bucket load of data on a per second basis. We have different "log-levels" but even the minimal log-level generates so much data ! This process of log creation is quite I/O intensive.
Since I can write assembly using __asm__ , I ... |
Firstly, I'm not exactly sure if this question is a better fit over here, or on workplace.SE. So forgive me if it is in the wrong place.
We are interviewing some candidates for a development position, and currently they are not in our city.
We would like to give them simple coding tests to see how they will perform on ... |
I'm working on refactoring a legacy application where I implemented the State pattern successfully as shown in the following diagram:
As you see there is a common behavior between the 3 states, so I decided to extract the common method Refund() to a parent abstract class RefundableState where I implemented it:
Refact... |
One of my team members, a junior programmer, has impressive programming skills for his level of experience.
And during code reviews, I believe in emphasizing learning, not pointing out mistakes.
But should junior programmers be involved in code reviews for more senior programmers? Or should code reviews be attended on... |
As an example, if I have a Post service and have a method to retrieve all posts for the logged in user, is it OK to have a findPosts() method that uses an injected Security service to get the user ID and then pass that user ID to my post DAO to get the records? Or should the findPosts() method explicitly require the us... |
I recently started at a company and am working on statistical data analysis and data handling (market research). A lot of my tasks were previously done entirely by hand, so I created a few tools to automate much of my work.
My boss asked if I could go ahead and look for other automation-possibilities. I certainly have ... |
I'm a complete beginner to Java, only in my second quarter of classes. I'm having trouble understanding our current chapter about calculating big-O for methods. So I thought I was right in saying that the big-O for these two methods is simply O(N), since there is only one loop that loops through the entire list, but ap... |
What are the major obstacles (and potential solutions, if known) for implementing "continuous delivery" software development when an application relies on varied programming languages or modules... especially when the same version-control and/or automated testing packages do not exist for those disparate platforms?
For... |
I've been wondering about applications that have a set of checkboxes or radio buttons, even collections of form fields in their UI.
At this moment I'm handling all the choices separately but of course this becomes a complete mess very quickly. There has to be an established way to deal with this that I don't know of.
I... |
I have come across many blogs and books where it is stated that it is bad for a system requirement to contain conjunctions like "and". However in reality I am often coming across scenario where a requirement is satisfied when a certain set of conditions are met. For instance, Shopkeeper should sell alcohol only if the ... |
I have a very basic game loop whose primary purpose is to check for updates & changes to a list.
I have contemplated using event driven programming to replace the game loop/list idea with an ObservableCollection, however I just have this big cloud of doubt on event driven programming. I'm posing these questions to tho... |
I'm currently re-designing my Entity System, for C++, and I have a lot of Managers. In my design, I have these classes, in order to tie my library together. I've heard a lot of bad things when it comes to "manager" classes, perhaps I'm not naming my classes appropriately. However, I have no idea what else to name them.... |
According to the Wikipedia article on Spurious Wakeups
"a thread might be awoken from its waiting state even though no thread signaled the condition variable".
While I've know about this 'feature' I never knew what actually caused it until, in the same article
"Spurious wakeups may sound strange, but on some multi... |
I have read in few blogs that as part of agile development , the product owner closely interact with developers to state their requirements and come up with a solution. However in case of a large project (in terms of number of applications involved) involving multiple systems , is this possible? Shouldn't the project h... |
I have an abstract class called Address and I am deriving three classes ; HomeAddress, Work Address, NextOfKin address.
My idea is to bind this to a usercontrol and based on the type of Address it should bind properly to the ASP.NET user control.
My idea is the user control doesn't know which address it is going to p... |
I am writing a library in C++ (making use of many C++11 features) that (as far as I can tell) implements the promise pattern.
The library consists of a class that makes asynchronous network requests. When a user of this class invokes a method that issues a network request, an instance of another class (we'll call it th... |
Functional Requirements state "WHAT" needs to be done from a user's perspective
Functional Specification state "HOW" it needs to be done from technical standpoint.
Do QA teams focus and Functional Requirements whereas development team focus primarily on functional specification though they need to have an understanding... |
I'm developing some code that utilizes generics, and one of my guiding principles was to make it usable for future scenarios, and not just today's. However, several coworkers have expressed that I may have traded off readability for the sake of extensibility. I wanted to gather some feedback about possible ways to reso... |
When you look at the code for the Winforms Designer, you see things like this:
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", ... etc.
instead of
using System.Drawing;
label1.Font = new Font("Microsoft Sans Serif", ... etc.
The same is true of tools like Linq to XSD, XSD2Code and, I suspect, of Li... |
After having had endless issues with INI-style configuration files and parsing them correctly (let along getting binary data right), a crazy idea crossed my mind recently:
What if an INI file like
# settings.ini
[Windows]
DirectorySeparator='\\'
PathSeparator=';'
[Linux]
DirectorySeparator='/'
PathSeparator=':'
Would... |
My coworker who is a senior guy is blocking me on a code review because he wants me to name a method 'PerformSqlClient216147Workaround' because it's a workaround for some defect ###. Now, my method name proposal is something like PerformRightExpressionCast which tends to describe what the method actually does. His argu... |
The global interpreter lock (GIL) seems to be often cited as a major reason why threading and the like is a touch tricky in Python - which raises the question "Why was that done in the first place?"
Being Not A Programmer, I've got no clue why that might be - what was the logic behind putting in the GIL?
|
My company wants to purchase new software for our General Ledger. We want to be able to interface it with various other sytems, all purchased. Nothing is custom built. The software our Accountants like does not have any APIs. However it does allow for imports and exports through various file formats.
The imports (... |
I'm the only software developer maintaining a subset of products at a small company. The main product I'm concerned with here is a web app which is installed on various clients' machines, with a database and background processes.
I make changes on a need-to basis for this program. It's not the company's flagship produc... |
Say I have a function.
function foo(){
//do stuff
}
And then I create an object of that function.
var fooObj = new foo();
What is fooObj called? An instance, An object instance, or something else entirely? Pardon the newbie question, but I am rather new to prototype based programming(and all programming really).
|
I am refactoring a large codebase where most of the classes are located in one package. For better modularity, I am creating subpackages for each functionality.
I remember learning somewhere that a package dependency graph should not have loops, but I don't know how to solve the following problem: Figure is in package... |
A page built so that is has server side scripts implemented on the page.
Should indentation of the code be according to the server side logic (making it easier to read while coding) or according to the HTML/ASP.NET markup (making it easier to read while debugging etc.)?
|
I have following piece of code:
int sum = 0;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
for (int k = 1; k <= N; k = k*2)
for (int h = 1; h <= k; h++)
sum++;
So I'v calculated how much does each cycle executes and then whole script, and I think I might be wrong for... |
I'm currently in the middle of refactoring an important method in a legacy-system. There were almost zero test until I've started working on it, and I've added quite a lot to ensure the correct work after my refactorings.
Now I've came across the most crucial part: the algorithm that calculates an indicator. It's some... |
There are instances which cane be seen while testing the application, both by developers and testers, some NullPointerExceptions arriving while clicking on a node in the table, or while doing an action too fast or under a zillion test-cases which do not come under the Test Cases document used in testing the application... |
I have started to separate my unit tests from my integration tests by using Maven Surefire and Failsafe.
Now I'm wondering what good ways there are to deal with separate environments. Take for example these two integration tests scenarios:
Given a customer id, can I get a list of orders belonging to that customer.
Giv... |
I am working on a Selenium + java project where all Web Element in a class are declared as -
public class CheckoutPaymentConfirmpage extends WebPage{
public final Button btnPrintorder = new Button("//input[@id='but_Print']");
public final TextField txtpassword = new TextField("password", "//input[@id='pass']");
... |
We have developed one product for payroll processing. We have 10+ customers who are using this software product.
Our existing and new customers are giving us customization changes w.r.t. their needs, and now we are facing the problem of product management. Please give some guidelines to us.
How to manage single softwar... |
I was reading up on data structures from Code Complete. This is when I stumbled through this piece about arrays:
Think of arrays as sequential structures Some of the brightest people in computer science have suggested that arrays never be
accessed randomly, but only sequentially (Mills and Linger 1986).
Their argu... |
I have been having a debate about what to do with a trailing slash in a RESTful API.
Lets say I have a resource called dogs and subordinate resources for individual dogs. We can therefore do the following:
GET/PUT/POST/DELETE http://example.com/dogs
GET/PUT/POST/DELETE http://example.com/dogs/{id}
But what do we do wi... |
I was reading this blog post: http://kjellkod.wordpress.com/2012/02/25/why-you-should-never-ever-ever-use-linked-list-in-your-code-again/
and I found there a code to run: http://ideone.com/62Emz
I've compiled it using gcc 4.7.2 with g++ -std=c++11 on my old laptop with T5450 cpu with two cores with 32 Kbytes L1 cache e... |
I'd like to know if it's possible to detect the delete error commented below at compile time? Especially, I'd like to hear about g++ compiler.
ClassTypeA *abc_ptr = new ClassTypeA[100];
abc_ptr[10].data_ = 1;
delete abc_ptr; // error, should be delete []
|
I think I can count WebAPI out, but WebForms, WebPages, and MVC are all possibilities.
I want to create an asp.net web site that is primarily static content and links to other sites. The only "fancy" bit will be a Bing map with pushpins that I add - but even these are static. And there will be a photo gallery. Oh, and... |
I want to do the following:
I have a number of computers. On each computer a programm will run. There is no centralized server.
The program can choose by defined criteria to give another computer specified data. While doing so, the other computer should not do the same. (A sort of 2 way synchronize)
Let's make an examp... |
I am making a simplistic in-browser IDE for some very domain-specific coding. Because I like Bret Victor's thoughts on Learnable Programming so much I thought I'd throw in some draggable numbers ala Tangle.js (click here to see what I'm talking about).
My implementation is a much simpler slider input control but the i... |
Use cases are primarily meant for interaction between user and a system. It could be used for interaction between system and another system. The actors are primarily roles.
It is easy to document the use cases for a front end application like a portal where in all the activities and role performing the activity could ... |
I have a scenario where a specific webservice must be consumed based on the state to setup user info. For instance if the state is NY or NJ call service A , if state is WA call service B etc. But specifying what service must be called is I guess is "HOW" to setup a user info and not a "WHAT".
So should I just have sing... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.