instruction stringlengths 34 19.9k |
|---|
In some ruby on rails projects, I have seen instances where strings are used instead of a foreign key reference to a lookup table.
I usually code in C#/SQL Server and use lookup tables, but am not particularly experienced in ruby on rails.
So my question is, should I be using strings instead of lookup tables in my ru... |
Why is ~0 a sequence of 1 bits and not just a single bit? Where do the extra 1 bits come from? Does this mean ~1 a sequence of 0 bits or just a single 0 bit?
My understanding was that the ~ operator is applied on the specific bits mentioned.
|
I recently tend to design my methods in the following way:
if ( 'A' === $a ) {
if ( 'B' === $b ) {
return 'some thing';
} else if ( 'C' === $c ) {
return 'some other things';
}
}
/* If you made it up to here, then something has gone wrong */
return false;
So basically the idea is to check ... |
For brevity's sake, consider the following scenario:
Part of my application is a wizard for bringing on new clients and it's a dynamic page. One step contains billing information, another step is setup information, etc. Because it's one page, in my mind I have one controller for the entire wizard, but that also means I... |
I'm the technical founder of a startup and I'm currently looking to hire a second developer for our product.
Since I've been the sole developer, there is no formal organization for the project and I wanted to know what would be the minimum organization required to incorporate this second developer.
Right now the code o... |
Consider an application that displays only Foobars belonging to themselves to normal users, and all Foobars to admins:
-- Normal users:
SELECT * FROM Foobar WHERE user_id=:user_id;
-- Admins:
SELECT * FROM Foobar;
Currently, this how the queries are represented in the codebase:
$sql = "SELECT * FROM Foobar";
if ( $u... |
So I have to write a filtering system, which may apply preprocessed ruleset to data - and trigger some actions defined in the ruleset while continuing its evaluation.
<ruleset name="1">
<rule>
<conditions>
<and>
<or>
<match image="aceofspades" level="70" />
<match image="aceofdiamonds" level="66" />... |
I'm currently writing my own PHP Framework (yes, another one) for studying purposes. I'll actually try to use it as my graduation dissertation.
After two failed attempts, I've finally found a way to develop it in a modular architecture, like Zend and Symfony.
I have some loosely coupled modules that can work apart from... |
I'm developing a system to manage "cases". There will eventually be many different "kinds" of cases, so I've started with a "CaseTemplate" table that can be used to define what a case looks like and, via satellite tables, define the specific characteristics for a particluar kind of case.
One such characteristic is phas... |
I'm creating interfaces for a number of our existing classes for mocking reasons. Many of these classes also have package scope methods as an attempt to give some level of encapsulation by ensuring only the controller can modify some of their state. I had thought I could use this change to try to get cleaner encapsul... |
Currently we use Scrum with the exception that our Scrum Masters sometimes act as project managers rather than facilitators of the Scrum process. About half of the time team members pull tasks on their own, but half of the time the Scrum Master assigns the tasks to team members.
I would like us to fully adopt self-orga... |
My GIT repo is stored on a remote Linux server that I'm accessing from my Windows PC through Netbeans.
Once my changes are done I would like to review them quickly before committing.
The server has no graphical components so I can't launch "gitk" from there.
I'm not very comfortable with a text diff on the server with... |
I need to reference the latest version of Bouncy Castle in a project I intend to publish to Github.
In my first posting of the code to Github, someone complained that I downloaded the entire Bouncy Castle library, added it as a project, and uploaded it.
What is the correct way to link to the latest version of this Bo... |
I'm making a web form for editing some objects. I'll call these objects Foos.
I have a Backbone model that represents Foos. I have a Backbone view that renders an editor form, filling in fields based on the state of the Foo model it is given.
My goal is to keep the Foo model in sync with the form fields.
Idea 1: I c... |
I am currently trying to understand more deeply the 4 principles of OOP: Abstraction, Encapsulation, Inheritance, and Polymorphism.
After studying the four principles, I don't fully understand why Encapsulation is considered one of the four primary principles of OOP.
Encapsulation is extremely common and useful in OOP,... |
This is a frequently asked topic... And I have read through many posts, articles and am about to read the book Working Effectively with Legacy Code, but before that and mainly because it will take more than a couple days for book to arrive, and I would like to keep my sanity in check, here's the question:
I am looking ... |
All apologies -- I'm still very much on the outside of Haskell looking in.
Why does the bind for a monad have this signature:
M a -> (a -> M b) -> M b
and not
M a -> (M a -> M b) -> M b
i.e. a function that takes M a instead of just a
a is available to the function in both, but the context that M provides is not av... |
Do software developers write SQL or database developers provide the SQL and the software developers use it? I am a novice to software development. I am just trying to understand the software development process because I have to do an internship this summer. I apologize in advance if this is a basic question.
|
I had my first programming exam recently...and well I pretty much flopped it. Did not do great at all. I have only myself to blame as outside of college time, I pretty much did nothing.
Now I have another coming up near summer time and I'm not allowing this to happen again. For a couple of weeks now I've been reading, ... |
Why does java print the value of the variable that is assigned it in the code below? I want understand what is happening here.
My thought is that the expression inside println() method is evaluated first. For the first example, 5 is assigned to int x. At that point, does x become available for the println() method to ... |
I have a general idea of how the processor handles instructions but spend my time working in mostly high level languages. Maybe somebody who works closer to the iron can provide some valuable insight.
Assuming that programming languages are basically very high level abstractions of a processor's instruction set, what i... |
I've been trying to figure out a way of calculating the estimated time remaining for an item in a queue when there are multiple workers processing items from the single queue.
A client submits a job to the queue, but since processing can take some time I wanted to give an estimate of feedback.
I know
Number of items i... |
I have content that is CC BY-NC-SA 3.0 (see http://creativecommons.org/licenses/by-nc-sa/3.0/), can software that uses it still be produced commercially and just let the user download the content separately?
In other words, if I have commercial software that uses the content with CC license, can the software still be d... |
Is there any particular reason why people use the A tag to mimic a BUTTON in HTML and JavaScript?
|
Most probably my boss didn't write a single word on a keyboard in his entire life.
He saw computers and he has a cell phone. He is a smart man.
How can I explain to him what a 'virtual machine' is?
(VM as in VMWare + virtual Box, not the VM as in Java, LLVM, .NET)
One of the reasons for asking this is that I want to ... |
Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time faster.
This is based on code attempting to do the same thing (processing a very large XML file) - in the case of the VM-base... |
I am programming in Java in a very object-oriented (OO) style. OOP comes very intuitively to me, but I have very little knowledge about other kinds of programming.
What exactly is procedural programming? How exactly is it different from OOP? Is it the same thing as functional programming?
I used to think that all progr... |
On it's latest technology radar, the guys at ThoughtWorks recommended avoiding JSF because it's attempt to create statefulness over HTTP ends up "causing a whole host of problems involving shared server-side state".
I've been using JSF 2.x for almost a couple years now, I like it and I can't say I've encountered any pr... |
I was naughty... Too much "cowboy coding," not enough committing. Now, here I am with an enormous commit. Yes, I should have been committing all along, but it's too late now.
What is better?
Do one very large commit listing all the things I changed
Try to break it into smaller commits that likely won't compile, as fil... |
I have a model Product with attributes sales and views. I need to get sales/views count of all the products. Is more correct to implement this as a method and have a call like Product.all.sales or create a new model Stats and implement as Stat.products.sales?
|
I have started to learn to program. I am interested in it and dont mind how long it takes to learn. But I am using books to start out and I find that there are some things I get and some things I have no idea.
I can understand the code when I see an example but I feel completely lost if I were to go out and do somethin... |
I am building an architecture like this:
These are my SW layers
______________
| |
| Views |
|______________|
______________
| |
|Business Logic|
|______________|
______________
| |
| Repository |
|______________|
My views are going to generate my HTML to be sent to... |
I want to modify one list (actually info stored in a database). A person doesn't have access to update every part of the list, but can update and delete parts they do have access to and add whatever they want to the list.
Here's my pseudocode:
ModifiedList
OriginalList
OriginalListWithUserRights
for each Thing in M... |
I am looking at developing a complete HTML5/JS mobile app that can be deployed to Android, iOS and Windows platforms. I am using DevExtreme tools to help me do that.
I already have a WCF service that serves me with everything I would need for this app. I want to reuse the same and found out how I could use JSONP (since... |
Assume you have a project that (in your opinion) is mostly decently well written, modularized, etc. and you want to keep much of it's functionality. However, an essential portion of this project is not well designed, and it can't easily be fixed with minor changes. The only way to fix it is to rip out a lot of the code... |
In terms of operating system architecture, what does a memory-clean software to get rid of all data that fill the virtual memory? I assume that it simply saves all RAM data into a file, but how does it exactly do this? What happens if you delete a file while a process that has resources on that file is executing?
Hope ... |
You see this phrase or similar kicked around from time to time, generally referring to a program that claims they were not designed to take full advantage of multi-core processors. This is common especially with video game programming. (of course a lot of programs have no concurrency and do not need it, such as basic s... |
Let us assume I have a basic object with a handful of self-relevant points of data.
class A(object):
def __init__(self, x, y, width, length):
self.x = x
self.y = x
self.width = x
self.length = x
And so we go on to instantiate several A objects and shove them into a list, as programm... |
I am currently developing a math-physics program and I need to calculate if two vectors overlap one another, the one is vertical and the other is horizontral. Is there any fast algorithm to do this because what I came up so far, has a lot of repeats. Eg lets say we have vector V1((0,1),(2,1)) and a V2((1,0),(1,2)) wher... |
To estimate PBIs you need to choose an average story and assign it a number of points (for example 5). Then you compare all other stories to that story and assign points accordingly. My question is, are you really supposed to compare every single story to that original story from the beginning of the project? If not, t... |
I have the following sort of directory structure:
part1
build
src
part2
build
src
Now I have a header file that I would like to include in both parts of these projects, it will contain constants and some macro definitions as well as some utility functions, and I want these to be synchronized between th... |
So I have talked my employer into finally jumping on version control...up until now my experience with git has been for personal projects and freelance work where everything is on one server, or small scripts...so, this is a bit above my knowledge.
We are going to have 3 web-servers… test, staging, production. We are g... |
I'm currently facing a issue on a project.
I'm resolving URL's on multiple DNS servers using a node.js server.
Until here, everything is fine.
But some ISP restrict the incoming requests from IPs outside their IP range.
So how could I modify my request to those specific DNS servers to make it look like I'm one of their... |
Let me preface this question by saying that I get the need for unit testing. I painfully get it. You have to do it to ensure that future modifications don't adversely affect the application in ways you did not expect. It's also good practice to utilize a test driven methodology to ensure your current modifications work... |
I have multiple tables in my database. Some tables have relationship to others and some don't have. My friend told me that it is not advisable to have a table that is not related to others. Is it substandard if I have multiple tables in my database yet there's no relationship at all? Are there guidelines concerning to ... |
I find myself reworking my code quite a bit, especially when learning to write algorithms that involve keeping track of multiple attributes and labels.
I feel that having the pseudo-code written up, having a small numerical example worked out, and a few test cases is usually a good approach. Yet, I find myself making m... |
I am about to start building a mobile (iOS/Android) app that uses a local database (probably SQLite). Since this is my first "real" mobile app, I am wondering what the standard approaches are to version management of the DB.
My thinking is I would do this:
include a base creation SQL script in the resources of the app... |
When developing a new RESTful application, I generally:
Define tests
Define routes [ e.g.: RESTful CRUD; namespaced on /api/users ]
Define models [ e.g.: "Users" ]
Define forms [ e.g.: in JavaScript (AngularJS), HTML5 and CSS ]
Currently thinking about throwing an API explorer into the mix… which would be another b... |
I came across a snippet like this, and find it's over engineering. Is it a good practice?
public class SchoolList extends ArrayList<School> {
}
public class School extends ArrayList<StudentList> {
}
public class StudentList extends ArrayList<Student> {
}
public class Student {
}
Actually I prefer a straightforward ... |
In the basic COCOMO Model which is used to estimate the development time of software
Effort : a * KLOC^b = X person months
Development time : c * Effort^d = Y months
where a , b , c , d are constants derived from the table below depending on the type of your software project
Question 1
Assuming X = 10 , Effort wi... |
I know of Interfaces, Abstract classes that serve as Base class, I've been reading up on loose coupling, ... But I can't come up with a decent solution when a property of a class changes, and the new type needs to be implemented in other classes using this updated class.
Example
Below is a simplified representation of ... |
Say I have a class with a single constructor that accepts 2 parameters and initialises itself using those parameters. I have written tests for this and they are all passing.
I later realise I need to make an addition to the constructor to accept three parameters. Should I
a) Add in the new parameter, watch my tests bre... |
I'm a fan of Dependency Injection, however I don't know how much both public and private methods inside a class should be loosely-coupled.
Just to picture it better, when I have both projectId and userId as private properties in my class, and both of them have their own decent setter methods which will do the input val... |
I know what node.js is & what it does.
What I really want to know is how does it work as an http server?
A server like apache gets a request, fork a process, allocate memory to process, handle the request & release the process after it is completed. If we get thousands of http requests at a time, then apache waits for ... |
Whenever I'm doing web development, and a page takes longer than half a second to be generated, I know that somewhere my code is hitting the DB too many times. The normal way to fix this situation is to ask the DB for all the information all at once instead, by doing JOINs and the like.
My question is: Why do many data... |
I am going to develop a simple Point of Sales system. Mainly all the data will be stored in a central db (mysql server). All the application are going to be winforms. Together each local client will have its db copy stored locally and all the operation will be based on the local db except for one operation that the tra... |
What kind of data cannot be compressed by using the huffman codes and why?
I tried looking for the answer, but I only came across loss-less and lossy compression. I don't really understand what types of data cannot be compressed by huffman and why they can't be compressed using it.
|
In a hypothetical economy there are currency units that can represent thousands of different values. So, for example there might be coins worth 1c, 3c, 5c, 7c, 7.5c, 80c, 8001.5c etc.
Given a list of all of the possible denominations and an arbitrary value how would one return a list of coins representing the smallest ... |
We need to support 5 languages for our product. This means that in order to have a potentially shippable product we need to translate all text new to the Sprint to all these languages. It doesn't make sense to me because the text might change after a few Sprints during which the users will use the application and give... |
When I run ffmpeg on an mp4 file, it says the duration is:
00:03:57.54
What is the unit that 54 represents ? I am interpreting it as 0.0054 seconds (54 milliseconds).
|
Based on this book , refering to pages 156 to 159 , it talks about the two different types of software architecture model : MVC & Layered .
There are distributed system architecture patterns such as : Master-Slave , 2 tier client-server , multi-tier client server , P2P
These are my questions :
1) In MVC , there is th... |
I would like to hear advice from the more experienced developers. The project is now in the design stage. It's mobile application and a simple web application. Content is pictures, comments, personal correspondence.
Pictures can be quite personal. Need a very serious attitude to security.
The question is simple: wh... |
I have recently switched to TSimpleRWSync from TRTLCriticalSection. The methods BeginRead and BeginWrite confuse me as wherever I read help, they seemingly do the same thing i.e. acquire the critical section whenever it gets relinquished. As the TSimpleRWSync doesn't allow multiple read threads, there is seemingly no p... |
I think I generally know what the Garbage Collector in Java does, but It's praised a lot, so I thought maybe I'm missing something about it's functionality.
What I know is, that the GC takes care of erasing from the memory objects that have no reference to them, and thus are unreachable by the programmer.
For example, ... |
I'm in the early design phase of a project to provide an e-commerce platform that will require several entities to be modelled, products, customers, orders, CMS pages, etc. They will all have a few things in common (ID, creation timestamp, last modified timestamp, etc).
My first thought was the usual one of giving t... |
How does the pattern of using command handlers to deal with persistence fit into a purely functional language, where we want to make IO-related code as thin as possible?
When implementing Domain-Driven Design in an object-oriented language, it's common to use the Command/Handler pattern to execute state changes. In th... |
I'm in the early stages of my programming career and I've been working with MVC for just about a year now. I've spent much time learning about the pattern and the concepts behind it, but as the projects I'm working with get larger I'm starting to think that maybe I don't have the best understanding of how the model lay... |
Consider what it takes to completely finish a story in our organization.
Demo requirements were met
UI design finalized (layout, styles, fonts, controls, colors, etc...)
User text finalized and mistake-proofed
All text translated to Spanish, Germal, Italian and French.
User manual updated
All bugs deemed by PO as need... |
I have encountered two ways of doing it:
void foo(int from, int to); /* 'from' inclusive, 'to' exclusive */
void foo(int startIndex, int rangelength);
Has one style historically been preferred over the other? If so, was it just a matter of convention or was it due to some deeper underlying reason?
I'm currently progr... |
We have a "typical" SCRUM team and we commit to work for a sprint, and also maintain a backlog. Recently we have run into a problem of trying to integrate/handle the work of an overachieving developer doing out of band work (choosing to work outside of the normal working hours/sprint).
To give an example, if the team t... |
In the page at http://pear.php.net/manual/en/standards.indenting.php, it is advised to use space instead of tab as it causes issue with diff, patches. Here is the excerpt from the page.
Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, SVN history and annotations.
So, my quest... |
We recently added a relatively large feature to our product that involved the entire R&D department (with all the different teams within it).
This feature included UI development, server side development, and huge migrations of SQL schemes (and other stuff that I myself was not involved in at all).
The development proc... |
I'm working on an event processor framework for a simple game I'm writing, in which multiple types of events are handled in a loop. Since these events carry distinct pieces of data (i.e. one carries a player and position, another carries a message and timestamp), I ended up creating different classes for them (though t... |
Why does the operator -- not exist for bool whereas it does for operator ++?
I tried in C++, and I do not know if my question apply to another language. I will be glad to know also.
I know, I can use the operator ++ with a bool. It makes any bool equal to true.
bool b = false;
b++;
// Now b == true.
Why can't we use t... |
I'm currently programming Java, I have played around with C++ before, but I have never touched GUI as I feel "cheat-like" when using its drag and drop system. I feel good and enjoy programming my own GUI like I do in Java, it feels much more rewarding.
Is there any way I can program the GUI for C#/C++ like in Java, wit... |
Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main uses (main has no access to node or binary tree classes). My code seems to work fine inserting/rearranging nodes as nece... |
Say your company has some closely-guarded internal software that happens to have an MIT License. Maybe it was based on MIT Licensed software but has been heavily modified over the years. Your company does not want to share it with the outside world. However, one day an employee decides to post the software up on GitHub... |
So, the last 2 weeks I have been fighting with indexedDB and one of two recurring questions that keep popping up is why indexedDB has to use/present it's entire versioning system? I do understand that in certain very specific cases it's a nice thing to have, but in those cases an if(localstorage.dbversion <= ...) would... |
I've been a front-end developer for about two years now, and I'm attempting to break into the server side of things. Ideally I'd like to work for a startup social network on the back-end side so I want to try and be as marketable as possible.
In my quest to learn a new scripting language I've dug myself into the PHP vs... |
Hello some programmers might know about the lean philosophy,
building a minimal viable product Lean Startup MVP.
I ask myself (when building Webapps):
"Should I put effort into writing good reusable code, testing etc."
or
"Write quick and dirty code. It just works. The customer does not care
what kind of progra... |
I'm programming in Java, in a very OO style, by myself. Never had the chance to work with other programmers (I'm not a professional, at least yet).
Out of curiosity, I wanted to ask: How does working with a team on a project work, especially when working on an OO project?
How does splitting tasks work? How do you devel... |
I got a java-ee application, where I collect informations about movies. Im my backend I provide data like the name, description, genre and a random uuid.
I also got lots of related files, which are stored on a file server. Including some screenshots, the dvd or bluRay cover and video trailers.
My current approach is:
W... |
I have implemented a LL1 parser in a non recursive approach with a explicit stack.
The following algorithm is from the Dragon Book:
set zp to point to the first symbol of w;
set X to the top stack symbol;
while ( X != $ ) { /* stack is not empty */
if ( X is a )
pop the stack and advance zp;
else if ( X... |
I have a service that needs information implemented by another service in the same layer. Is it good practice for one service to take a dependency on another service in the same layer?
|
I am currently working on a project that is fairly small for the time being. There was a recent change to implement 3-tier architecture, such that the code is now split up appropriately to data access, business logic and user interface tiers. However, there is no use of objects outside of creating them to ultimately ... |
Clarification: the rule is meant to prevent accessing variables that are not declared yet.
Clarification 2: the rule mandates that the compiler follows calls to functions which are defined in the same scope as the call and happen before the actual definition (forward referencing) - making the compiler much alike an in... |
I would like to write a web system that can capture and parse incoming emails, traditionally the web system I write are asp.net-mvc, running in a cloud hosted environment like AppHarbour or Azure.
How can I leverage those (and potentially my DNS) to acheive this?
|
I recently took a software processes course and this is my first time attempting OO design on my own. I am trying to follow OO design principles and C++ conventions. I attempted and gave up on MVC for this application, but I am trying to "decouple" my classes such that they can be easily unit-tested and so that I can e... |
My application has a few high level configuration options such as directories which will be used for various things, database connection information and a few other settings which are required for the application to run.
I'm debating with myself whether or not constants are better than variables for this purpose and wo... |
Say you are developing a desktop application that extensively uses a database, should you have one handle for the database that the entire app references? Or should you open a connection when you need data, get the data, and then close the connection when data isn't necessary.
|
I am trying to determine an objective way for a self-interested agent to calculate the optimal buying/selling price for goods in a multi-agent simulation not dissimilar to Sugarscape (http://en.wikipedia.org/wiki/Sugarscape). The simulation is as follows:
Each agent has a stock of food F, a stock of money G, a certain ... |
For decimal numbers, obviously I want to localise everything. Whatever programming language I'm working in, there will tend to be tools for this, so it's also easy to do.
In my application, I happen to be formatting numbers as hexadecimal quite often. This leads me to wonder:
Are there locales which group hexadecimal ... |
I've already read this question on CodeReview. I was hoping for general advice.
I'm writing a service which will go to numerous data sources. Each source requires getting copious amounts of data and changing it to a single format. What is the best pattern for a task like this?
I currently have a "base" class which e... |
I am working on a Chat Server Application in Asp.Net with C#.
Suppose there are 5 users online say User A,B,C,D,E. Suppose A sends a message in chatbox to user B, so how the chatbox (Textbox/Textarea of chat) of User B will load the new content?
One Option is to refresh the chatbox every 10Seconds or 15 seconds but it'... |
I'm developing a CMS, inside it I use many various plugins/addons wich licenses mostly like MIT, GNU, GPL (such as jQuery, nivoSlider, DataTables and so on..). After reading those licenses I believe I can use them inside my CMS and charge users for my CMS.
In my project I have a specific folder where I store all these... |
During Sprint Planning there are a lot of decisions to be made:
How many PBIs should the team commit to?
Which tasks should constitute each PBI?
How much time should each task take?
With no team leader it is not always easy to make all these decisions, since there will be some decision points (sometimes more than a f... |
I want to try and create my own very basic language, with it's very basic compiler. All using Java.
For now, it will only need to enable to 'programmer' to print things to the screen.
I had an idea for how to do this, and what I wanted to know is: Will this be considered an actual 'compiler', an actual 'language', and ... |
I want to work on a very simple compiler for a very simple language. The compiler will compile the code to some basic bytecode. Later, a virtual machine program will run the bytecode, and execute the program.
I have several questions about what bytecode actually is:
Does bytecode have to be of binary form, aka compose... |
There are many well-known best practices about exception handling in isolation. I know the "do's and don'ts" well enough, but things get complicated when it comes to best practices or patterns in larger environments. "Throw early, catch late" - I've heard many times and it still confuses me.
Why should I throw early an... |
Delphi RAD libraries implement many thread friendly objects in a way which forces one to declare another object for storing the reference returned by that object's locking method. The object thus essentially encapsulates the prime object which is returned on locking. For example;
List := ThreadList.Unlocklist;
// do so... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.