instruction stringlengths 34 19.9k |
|---|
Is else while without intervening braces considered "safe" maintenance wise?
Writing if-else code without braces like below...
if (blah)
foo();
else
bar();
...carries a risk because the lack of braces make it very easy to change the meaning of the code inadvertently.
However, is below also risky?
if (blah)
{
... |
I've been looking into the details behind these two different categories:
Web runtime environments
Web application programming languages
I believe I have the correct information and have phrased it correctly but I am unsure. I have been searching for a while but only find snippets of information or what I can see as ... |
In this SO Question there is a comment by starblue that
A computer without loops is a calculator
Is this true?
Is that the only difference?
Is there a set of criteria to differentiate or has the line become very blurred?
|
I am not sure weather it is a proper question to ask out here but it is really bothering for a while. As the official website writes:
The Rails Rumble is a distributed programming competition where teams
of one to four people, from all over the world, have 48 hours to build
an innovative web application, with Ruby... |
I am developing an app in ddd maner. So I have a complex domain model. Suppose I have a Fare object and Airline. Each Airline should contain several or much more Fares.
My UI should represent Model (only small part of complex model) as a list of Airline, when the user select the Airline, I must show the list of Fares.... |
Assume I have a public source code repository. Am I violating copyright laws if there's any old commit where I have not yet added all copyright info for other people's open source code?
Details: Consider this theoretical scenario:
I copy-paste someone else's open source code files into a repository.
I commit.
I prefix... |
How do people define the minimum hardware requirements for software? For example: how can a software development company tell the customer that they will need 8 GB of RAM to run the program properly?
|
Background:
There are around 60 students at the boarding school I work for. The counselor asked my colleague and me to come up with a better way to come up with seating arrangements for dinner than by hand. He would like assignments for the rest of the school year. He also asked us to try to solve some of the issues he... |
I've recently started with a new firm and I'm trying to understand the mechanics behind something, so I'll anonymize the code and present but a sample:
[Test(Description = "Retreives the New view for XXXX.")]
public void New()
{
"~/XXXX/New".ShouldMapTo<XXXXController>(x => x.New());
"~/XXXX/New".WithMethod(HttpVer... |
Possible Duplicate:
I’ve inherited 200K lines of spaghetti code — what now?
I'm dealing with legacy code. It contains some BIG classes (line count 8000+) and some BIG methods (line count 3000+). For one of these methods I wrote a unit test that covers at least some code. This function has no specific structure, it i... |
I have to extend/fix a large online form written by other developer. There is a lot of code, mixing PHP and JS. It's kind of write-only style of coding and I want to redo it completely, but currently I can't.
It works like this:
It is a wizard-style form with 12 steps - let's call them phases to not confuse with steps... |
I have a class that I'm testing. The class has a function: apply(List<IRule> rules, List<ITarget> targets);
In one test I want to ensure that each target has been passed to one rule, a la:
rule1.AssertWasCalled(fnord => fnord.Test(target1));
rule1.AssertWasCalled(fnord => fnord.Test(target2));
rule1.AssertWasCalled(fno... |
I'm working on re-factoring certain aspects of an existing web service. The way the service APIs are implemented is by having a kind of "processing pipeline", where there are tasks that are performed in sequence. Unsurprisingly, later tasks may need information computed by earlier tasks, and currently the way this is d... |
I saw a conference by Herb Sutter where he encourages every C++ programmer to use auto.
I had to read C# code some time ago where var was extensively used and the code was very hard to understand—every time var was used I had to check the return type of the right side. Sometimes more than once, because I forgot the ty... |
I've recently read the article The Problem with logging and was wondering about my current logging strategy.
Usualy I use Log4J in my projects and just have to decide which line/attributes I would like to log.
This strategy worked well for me in the past for all my projects without user-interaction.
Now I want to set u... |
Can I license a program under Apache License 2.0, if it is using/including EclipseLink?
(EclipseLink under Eclipse Public License or Eclipse Distribution License)
I did not change anything in EclipseLink.
I would realy like to distribute a Version that includes the needed EclipseLink jars, so that it is working "out of... |
How would you implement / design a class which has to represent a bitmap?
I'm stuck at handling the different possible color modes and I keep thinking that this should be somehow implementable using templates / design patterns in an elegant AND efficient way:
Suppose you have a file.bmp. You then want to open that file... |
I came across this article proposing a style of coding in c++ that looks a bit weird at first. But after reading it over and pondering for a bit I'm really considering giving it a try.
The most appealing benefit is the ease of refactoring methods. I find myself constantly changing method names, parameters and so on whi... |
Quercus is an implementation of PHP written in Java, and released under the GPL.
If I use it, does my PHP code fall under the GPL?
What about my Java code?
Assuming I write new Java code, and new PHP code, and use Quercus to run my PHP code on the JVM and call into my Java code, which pieces fall under the GPL?
Also, a... |
Assume you are using APIs from a vendor, how to make sure their API is working as expected?
My main concern is sometimes the vendor pushed the changes to their code and break the API, we want to have some sort of automatic software to test them continually. How to deal with this?
|
Most security threats that I've heard of have arisen due to a bug in the software (e.g. all input is not properly sanity checked, stack overflows, etc.). So if we exclude all social hacking, are all security threats due to bugs? In other words, if there were no bugs, would there be no security threats (again, excluding... |
When subdividing intervals for arithmetic coding, the worst case scenario is that the final interval will have size 2^(1-n), where n is the number of unique symbols you are encoding. This will reach the limits of machine precision, when using regular datatypes, really quickly: For instance, I've made a JavaScript imple... |
Background
I have a requirement where I need to remove a few nodes in a network based upon a command given by the user. To keep the nodes from transmitting or receiving data I thought of changing its IP address to some other address. Before I change the address I want to save the node's IP so that I can re-assign the... |
Our Architecture team is proposing a framework that would see our SQL queries moved from coded strings within our applications, into a file based system where we would invoke them with function calls. Our application makes heavy use of SQL queries ranging from the mundane, to very complex. This is a .NET solution.
The ... |
I am taking a C++ class in my school. Since I've programmed in Ruby I know some OOP stuff.
But in C++ there are member functions, member variables, and static functions. In Ruby we have instance methods, instance variables, and class variables. And there are more...
Any reason they're different? Are they quite differen... |
If we have double numbers, let's say I want to see if some double parameter is equal to zero that is passed as double:
public bool AlmostEqual(double x, double y)
{
double epsilon = Math.Max(Math.Abs(x), Math.Abs(y)) * 1E-15;
return Math.Abs(x - y) <= epsilon;
}
considering double shows 15 accurate digits.
So ... |
We use Drupal 7 as our base CMS tool.
For one specific product, something like an ERP, we've created sort of a non-drupal layer, to keep our specific business code in.
It would be something like this:
-------------
| Business | -> This would be our business specific code layer
-------------
| Glue | -> This is wh... |
I had originally posed this on StackOverflow. The question was closed and I was asked to post this here instead. Here is the original question I had posted there:
I have been programming using procedural method for a while now. I have done some good amount of reading pertaining to OOP and I know how to use it. It's ju... |
I asked this question over at stackoverflow and it was suggested a tighter form be posted here.
Many early career numerical researchers face the prospect of having to create performance critical software from the ground up. Most are ill equipped to do so, and my lab is no different. I currently work extending a sophist... |
This is related to my recent question regarding naming awkward domain objects. A number of answers indicated I was using the wrong representation for the domain objects. To summarize, I chose to use an enum to represent some domain objects used as keys in lookups.
For this question, I want to review my decision to ... |
I'm helping to reogranize several redmine projects; although I have a lot of experience with issue tracking systems, I've never worked with redmine before.
What is the best way to organize Issues in Redmine so that they can be easily grouped by:
feature (e.g. "Upload a file", "Login to site", "Send message")
system co... |
My aim is to, via pattern analysis and statistics, (as well as piece mobility and position) build a chess position evaluation analyzer (rather than simply going brute force ply-searching).
Id like to hear some thoughts a language that will be interesting/fun/challenging to learn and reason with. Ideally the language w... |
I'm coding a server/client application pair in Java, as I learn about it. I have basic functionality of sending a message to the server and parsing it but in thinking about the big picture of their communication, I'm stumped about where to go from here.
Both the client and the server have to be able to initiate an exc... |
I've noticed that a lot of companies use "reverse domain name" namespaces and I'm curious where that practice originated and why it continues. Does it merely continue because of rote practice, or is there an outstanding architecture concept I might be missing here?
Also note questions such as: https://stackoverflow.com... |
With a YYYY-MM-DD HH:MM:SS date I always store the UTC time. When I pull to display I translate timezones with built-in PHP functions and classes.
I believe that is one correct way to do it and it makes sense to me.
May I handle YYYY-MM-DD the same way?
|
I'm pretty sure that someone has already thought about it and researched it extensively, but I'm having trouble finding any materials or even keywords to look for, for the idea that I was thinking about recently.
I thought about this concept, where in distributed systems, actual computation and processing would happen ... |
In SICP 2nd Edition section 2.2.3,
the authors have the following code:
(define (even-fibs n)
(accumulate cons
nil
(filter even?
(map fib
(enumerate-interval 0 n)))))
My question is why did they use accumulate in this case? Couldn't they ha... |
I need to write a cross-platform GUI application to process (in multiple threads) and visualize fairly large quantities of data. Ideally the application should be relatively fast and look good.
The app's interface will consist of a table widget, a tree widget, and a custom figure-drawing widget. The user will be able t... |
It seems like FILEHANDLER is more commonly used as a handler naming convention than $filehandler.
But it can give a bareword error if one forgets to use *FILEHANDLER in some constructions.
What are advantages and disadvantages of HANDLERS and $handlers?
Which naming convention is a better practise, and why?
|
I am implementing an application in Haskell and, for sorting, I use the library function Data.List.sort. However, I was wondering whether this is the fastest sort implementation in the Haskell standard library (perhaps lists are not the best choice for efficient sorting).
I have found different alternatives, e.g. heap ... |
This might sound like a naive question but when are database table indexes in mysql required? How do such indexes affect performance and why?
|
I'm trying to learn recursion. I copied this bit of code from my book and added the displays to help me trace what the method is doing and when.
public static void main(String[] args) {
System.out.println(sum(4));
}//main
public static int sum(int n) {
int sum;
System.out.println("n = " + n + "\n")... |
I have an array of dimension 5. But, I can't figure out how to visualize that array?
int[][][][][] array = new int[4][4][4][6][2].
Is there a good way to visualize arrays with dimension counts of 3 or more?
|
I am starting a software project that I want to have the option to keep it proprietary. However, since I generally use a Linux environment, I want to know: How do people write proprietary software in Linux and not violate the GPL/LGPL/etc licenses that seem to restrict uses of libraries needed to build the project?
Al... |
I have a conceptual problem with a proper implementation of code which seems require multiple inheritance, that would not be a problem in many OO languages, but as the project is for Android, there is no such thing like multiple extends.
I have a bunch of activities, derived from different base classes, such as simple... |
I am not talking about simple UI logic like clicking a button directs you to another page, but where one action may result in several different of behavior depending on current application state, and may also trigger response in other parts of the application. Currently my view publishes all UI event so the response ca... |
When manually inspecting unfamiliar code (to review or modify), I seem to have three options.
A top-down read of the code, choosing each next source file by how fundamental the filename seems. I usually end up reading nearly everything. Some files twice.
A breadth-first read, where I find and read all of the invokin... |
I've been tasked with creating a dashboard application to show real time updates for our servers. The raw data comes in from an XML file on our intranet which I need to parse and present to the user.
It is not an option to have every user of the dashboard pull this XML file at the same time for their updates. From what... |
I ran into the following issue where a keyboard shortcut I was used to was no longer working in Ubuntu. That's just an example. For programming, this kinds of thing happens a lot, but it also happens in any aspect of work and life.
I'm always tempted to fix it right away because I have an idea of what might fix it in a... |
I have trouble drawing a clear line between Presentation and Application layer in Domain Driven Design.
Where should Controllers, Views, Layouts, Javascript and CSS files go?
Is it in the Application or the Presentation layer?
And if they go all together in the same layer, what contains the other one? Is it empty?
|
Look at this:
<?php
echo "Hello World";
?>
<br />
<?php
echo "Welcome";
?>
And now look at this:
<?php
echo "Hello World";
echo "<br />";
echo "Welcome";
?>
Which one of the above examples is considered to better (at least from performance point of view)?.
I know the examples are trivial but I want to follow good pr... |
A rather simple question here, With regards to web design and the paperwork behind it (Which I am sure many people/companies don't actually do).
Would there be any reason for using a Cumulative Chart?
Specifically a Cumulative Resource chart, although I am unsure what the resources could even be!
More to the point, ... |
Design Question
Recently, I've been doing more and more FP in C++, mostly in the form of function templates and lambdas, and heavy overloading of a single function name. I really like FP for some well-defined operations, but I've also noticed that as with OOP, one could easily fall into anti-patterns of spaghetti-code... |
Problem Statement -
Given a 2xN grid of numbers, the task is to find the most profitable tiling combination (each tile covers 2x1 cells; vertically or horizontally) covering all tiles.
I thought of approaching it in the greedy way, enqueuing the max possible for any cell, but it has a fallback that a low-profit choice... |
I just read Beating the Averages, and Mr. Graham writes that they had a significant advantage over competitors because they used Lisp.
From what I understand, Viaweb was a WYSIWYG editor that ran in the browser for customers to create their own 'stores'. This is obviously inconceivable now to do without JavaScript, yet... |
Problem Statement -
The task is to find the most profitable contiguous segment of tests, given a sequence of test scores, with being allowed to drop any k tests from a chosen range.
The problem appears to be a DP problem at the outset, but complexity arises when the test drop condition comes into the picture.
What mo... |
This is a web application based on actionscript 3.
I have all of my modules enumerated in a class, but I never know which modules actually come from database.
Let's say I have 20 modules in my application, but the user only has access to 10 of them. All I get are 10 strings from database (the module names) whenever the... |
From a given tree, subsequent trees have to be generated. Nodes can be marked as "variant" in the given tree (the example uses an asterisk to mark the node). All possible combinations between the variants form the resulting trees.
From the following tree:
- Product
- Packaging *
- Small box
- Heavy ... |
Any idea why the C# version of sqrt (System.Math.Sqrt) is ~10 times slower than c++ version ? Furthermore, C# version seems to have one extra digit of precision. I have run my test under MSVC2012.
I have used double and call System.Math.Sqrt once before doing the bench in order to force Jit
|
In functional programming since almost all data structure are immutable, when the state has to change a new structure is created. Does this mean a lot more memory usage? I know the object oriented programming paradigm well, now I'm trying to learn about the functional programming paradigm. The concept of everything bei... |
I'm a beginner-level C++ programmer, but I understand the concepts of the language fairly well. When I began to learn external C++ libraries, like SDL, OpenGL (maybe something else too), to my great surprise I found out that they don't use C++ concepts at all.
For example, neither SDL, nor OpenGL use classes or except... |
I have some legacy code, which uses Lisp as it's scripting language. To broaden, ease and accelerate scripting I'd like to replace Lisp by Javascript.
In order to be able to built on all present scripting files, I first need to translate all lsp to js.
Now I found parenscript but am not yet sure what it is good for (se... |
In the context of the Ruby programming language, what is a closure and when do you use one? What are the uses for it in Rails?
|
Lets say that I have hundreds/thousands of objects(entries) in a database and each object contains 10 attributes. I have a way to quantitatively measure each attribute where a higher number implies that the object is better in that area. I also have a final price associated with that object. Is there any way to program... |
Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by:
Writing the functions to be used as classes by yourself
Use a nifty class system in a framework (such as mootools Class.Class)
Generate it from Coffeescript
In the beginning I tended do write class bas... |
Wikipedia says that Agile is a type of "RAD" which I guess is incorrect. From what I know, Agile was developed becasue RAD itself was not that sucessfull in 90'S (too rigid for changes).
Or am I wrong?
(Remark: apparently the Wikipedia article on Agile software development was improved in between, it just lists RAD as ... |
I am creating a free nokia application for which I am about to use images from a creative common website. Now my question is if a free application come under creative commons as it is not a paid one?
Thanks in advance.
|
Imagine a small calculator GUI, with basic operations (+,-,/,*), and in the menu we can check for example scientific calculator and a small new view with the extra functions appears beside.
I was thinking that the decorator pattern is the solution but after reading some documentation on it, I am confused now. Which pat... |
Problem Statement -
The task is to find the minimum number of swaps required in the given arrangement of cartons to get the desired arrangement of cartons. Only adjacent cartons can be swapped.
I have tried an ad hoc approach, but it proved inefficient towards the upper limit of the data range. Here it is for referen... |
I do not have the access to the IEEE standard and information on the net are contradictory. Can I capture user requirements in SRS using use cases? Or I should keep use cases separate as they are more like scenarios than separate requirements?
|
I'm developing a software documentation in a project, and much of it are just CRUD or CRUD based functions. As you can imagine, a lot of the rules are constraints about fields validation, things like length, range, data type and masks of the field.
Writing all those rules would be cumbersome to write and to read, so I... |
We have developed a job-portal where users can view jobs and and also post jobs. We have used Php and MySQL. We hosted this on web faction. Now we want to develop the mobile app of the job portal for android, ios and windows. As the database should be synchronous and aligned dynamically with apps and website database. ... |
I find it that when languages are considered the same as commercial software, there is always a constant need to add new features to justify new releases.
Can there be or are there languages where version 1.0 is the final version? Of course bug fixes are exempt from this, but the feature set always remains the same?
Th... |
The definition of a Y combinator in F# is
let rec y f x = f (y f) x
f expects to have as a first argument some continuation for the recursive subproblems.
Using the y f as a continuation, we see that f will be applied to successive calls as we can develop
let y f x = f (y f) x = f (f (y f)) x = f (f (f (y f))) x etc.... |
Recently, I've been trying to implement some working version of the Glicko Rating System for fun.
However, I fail to understand how to programmatically isolate R in Step 2. As you can see R appears on both sides of the equation and for a variable number of instances. How would I programatically solve for R using pytho... |
This is my understanding of the Application Layer:
• It implements Application logic
• this layer contains Application Services, which are used by external consumers to talk to your application
• Application Services are coarse-grained and orchestrate operations which map directly to use cases ( hence also the term ... |
I'm working on a pretty standard LAMP based web application. The server itself has a standard MySQL database and the application is written in PHP. The kicker is, we also use SQL Server databases with this application.
The current data setup is this:
MySQL stores the user account information (Username, password,
pri... |
When browsing open-source projects that are primarily developed for Linux systems and downloading the latest packages, the source code is always stored in a .tar.gz or .tar.bz2 file.
Is there any reason for using .tar.gz or .tar.bz2 rather than something like .zip or .rar or some other compression algorithm (or even le... |
Say I'm developing a bug tracker, where a ticket belongs to at most one milestone, and a milestone can have many tickets. When a milestone is deleted (from the database), all tickets associated with that milestone must have their relationship unset (i.e. set to null). This is a simple relationship.
The classes are fair... |
When writing page generation in PHP, I often find myself writing a set of files littered with database queries. For example, I might have a query to fetch some data about a post directly from the database to display on a page, like this:
$statement = $db->prepare('SELECT * FROM posts WHERE id=:id');
$statement->bindVal... |
We have an application that we need to ensure that our APPLICATION DATA should not be used (or opened) in different computers with same users. For that we thought about getting harddisk GUID as a part of data encryption private key. In this case raid disks, virtual PCs would fail and wouldn't be able to open the data. ... |
Do NSURLConnection service objects and XML/JSON parser objects fall within the controller layer or the model layer? Why?
Is it OK to have business logic in the controller? Or should it be in the model layer only?
Can the model layer be represented by NSArray/NSDictionary objects or should it be strictly structured with... |
I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in
auto x = 1;
Since
var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and
As far as I understand the new semantics of auto breaks backward compatibil... |
Word processors (e.g. Microsoft Word) display documents to the user as styled text. The user can select a part of this text and apply styles to it, and edit the text.
The word processor must (I guess) have an internal representation of the document that indicates which bits of the text displayed to the user should be s... |
E.g.
- $stream1 is the STDOUT of a child process and $stream2 is the STDERR of the same child process
- $stream1 is one child process and $stream2 is another child process
Is there a possiblility in perl to monitor two or more streams at the same time?
So we loop as long as anything pops-up in any of the streams and we... |
I'm developing a tool that handles (electrical) parts. The parts can be created, viewed, modified, deleted, grouped and so on...
In order to make this question useful for future visitors I like to keep this question universal since managing parts in a DB is very common no matter what parts are in the DB (CDs, cars, foo... |
One of things that annoys me about SQL is that it can't think in terms of objects and it's lack of encapsulation makes me constantly have to escape commands to prevent injections.
I want a database language that can be polymorphic and secure. I have searched online for non-procedural database programming languages and ... |
I work on a rather large code base. Hundreds of classes, tons of different files, lots of functionality, takes more than 15 minutes to pull down a fresh copy, etc.
A big problem with such a large code base is that it has quite a few utility methods and such that do the same thing, or has code that doesn't use these ut... |
Just wondering if text such as the following, which appears inside the source files of a free, open source API, means anything in a court of law
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
//... |
For example, if I have a Customer Transactions Table and I create a REST for it. The fields are: date, description, and total_amount.
I am trying to figure out which one is much more efficient when you get the sum and the count of the transactions:
You create a REST for /transactons URI and it lists down all the tran... |
Note: after writing this I realize that this question is perhaps philosophical, but I'm interested in how the industry handles this scenario regardless.
I have recently been working with a code base that is not yet as testable as it should be. I've seen some junior developers check in code that breaks use cases, whic... |
I want to uderstand why there is a method in C# that could reurn a value, for example:
public int Accelerate()
{
Speed++;
return Speed;
}
and a method that does not reurn a value (void)?
What is the difference in the following example of the above one:
public void Accelerate()
{
Speed++;
Console.WriteLine(Sp... |
I'm in the early stages of designing a client/server application. The clients will be batch programs that read a file of customer contact data (name, address, email address, phone no's) and pass these components to the server, which will add them (if not already present) to corresponding mySQL tables and return id's ... |
Say we have a view page where users perform actions in multiple steps, some of these actions would involve DB operations with transactions (the snippets are in pseudo-code like from):
View 1:
Step 1:
...
Step 2:
...
Call ActionX
Step 3:
...
ActionX: # can be called fro... |
My programming friends are always telling me that HTML is a markup language and C++ is a programming language. When I ask them what's the difference, they never give me a reasonable answer.
What could make one call C++ a programming language, and HTML not?
|
I am trying to figure out a better way to decide table storage configurations whether it will use static configurations using tables or dynamic configurations using EAV (entity-attribute-value)
When creating database tables, forms, and reports, when do you decide that a program should use a normal database (wherein eve... |
I was using this feature in earlier Windows release like XP and NT. I was able to run a GUI from a Windows service. But it is not possible in the later versions.
What is the reason behind the removal of this feature? Why can't Windows services have a GUI?
|
During a job interview, I was asked to explain why the repository pattern isn't a good pattern to work with ORMs like Entity Framework. Why is this the case?
|
I have a program I'm working on that my company uses internally, but is also sent to vendors. The vendor version will be identical, except that it will be missing some features, and use an installer. I only have to remove 2 lines from an XML file, and it's good for external use.
Is there some "typical" method to creat... |
I'm about to leave a project, and before I go my boss has asked for me to document code (I've not documented very well). It's not a big deal, the project is not terribly complex. But I'm finding places in my documentation where I would like to say, "Notice on line XYZ that such-and-such happens."
In this case, it doe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.