instruction stringlengths 34 19.9k |
|---|
Sorry in advance if this question is so trivial.
The situation
There is a Customer entity whose ID is limited to two letters (A to Z) in the database.
Also, a user can enter the ID value from a Windows form. I think that the best option is that this form will validate (using the controller) with a regular expression l... |
I'm implementing a quadtree. For those who don't know this data structure, I am including the following small description:
A Quadtree is a data structure and is in the Euclidean plane
what an Octree is in a 3-dimensional space. A common use of quadtrees
is spatial indexing.
To summarize how they work, a quadtree i... |
Applications can always throw errors. If such an error occurs, the user should be notified, because what he asked the application to do has not succeeded.
However, how much information should the user be given? I think most of us agree on not showing a stack trace (Should a stack trace be in the error message presented... |
Is it possible to have a constructor in a class, that you can ignore certain arguments/parameters?
For example, I have this constructor
Car(color, make, model, wheels, type, doors)
Could I call this constructor and not include the type parameter?
|
My question is about a special case of the super class Animal.
My Animal can moveForward() and eat().
Seal extends Animal.
Dog extends Animal.
And there's a special creature that also extends Animal called Human.
Human implements also a method speak() (not implemented by Animal).
In an implementation of an abstract... |
I would like to define several names for the same type and have the compiler distinguish between them.
My motivation is that different int variables could represent very different units, and I would like the compiler to catch errors in units.
typedef int Speed does not generate any warnings, when assigning to Speed fro... |
A common pattern I come across is a backbone collection which is initially seeded from a database.
However, the user can also add to the collection. When the user does add to the collection, these should be reflected in the db.
Usually I would bind some kind of server call to the collection add event. However if I do t... |
I'm trying really hard to refactor some of my legacy code in the project using best practices and design patterns + DDD so I'd love some feedback on an issue I'm currently having.
Let's assume that I have two entity classes:
class Dog
{
protected $name;
function __construct($name)
{
$this->name = $... |
As the title states; what are the advantages and disadvantages of splitting teams by architecture tier rather than by product?
For example:
Organization A has three teams:
Team Web and Front End
Team APIs, Web-Services and Data Stuffs
Team Embedded Stuffs
Organization A teams, over time, have become more specialized ... |
My function takes an optional parameter, type, which is used to filter through a collection. However, the filter should only apply if the parameter is passed in (in other words, non-null). If the filter is not passed in, it should not be applied. How can I write my logic to reflect this? What I have now is -
if( other... |
I am about to start a Tetris clone using Java as my programming language. While I was designing how it'd be done, I've stumbled upon this question:
What would be better, if any difference at all, regarding performance 1, to draw my game?
For a matter of simplicity, I will use a background grid as an example. The follo... |
I've been a computer enthusiast my entire life, but didn't first start programming (web development) until I began College. It is now four years later - I am about to graduate, have had a handful of full-time internships and part-time work, all revolving around web dev... But I still find myself more often than not see... |
As a university project, I have to replicate Raptor. A flowchart interpreter. The interface looks like this
But as I am not a experienced swing developer, I don't have much idea about which swing components to use for which part.
I know:
The whole thing is a JFrame.
There is MenuBar on the top.
ToolBar exactly beneat... |
I need help in identifying a better algorithm.
I have developed a script using pythons scipy package to analyse a rather large model that I wish to solve. The model contains over 12GB of data including over 500 parameters.
The problem is that when I run small simulations of about 0.5GB of data with 20 parameters it c... |
I am trying to make a flexible particle system for my XNA game, and I've got these interfaces:
public interface IParticle : IUpdateable
{
bool Alive { get; }
float Percent { get; }
}
public interface IParticleEffect<T>
where T : IParticle
{
void Apply(GameTime time, ref T particle);
}
public interface... |
So I started thinking, what is the best practice for publishing generated documentation (e.g. Doxygen, NaturalDocs, etc.) in terms of infrastructure?
I would be generating it through continuous integration:
Should it be put in a regular web server?, or should I use something like Sharepoint or some other content publi... |
I am working with quite large files (pytables) and I am having problems with the Memory Error when I try to load the data for processing.
I would like some tips about how to avoid this in my python 32bits, since I am new working with pandas and pytables, and I do not know how to work splitting the data in small pieces.... |
I'm using a large interface with about 50 methods to access a database. The interface has been written by a colleague of mine. We discussed this:
Me: 50 methods is too much. It's a code smell.
Colleague: What shall I do about it? You want the DB access - you have it.
Me: Yeah, but it's unclear and hardly maintainable... |
I have a WCF service which will get an object with huge data from database in the form of collection.
I have a UI which has get and cancel buttons .
Get button : make service request and continue with data population with the returned data from service.I start it as below
Thread _workerThread = new Thread(DoExportTreeL... |
Can someone please explain to me the difference or benefits rather to using the rectangle class
ex. Rectangle r1 = new Rectangle(x,y,w,h);
versus the graphics class drawRec method?
g.drawRec(x,y,w,h);
I'm thinking that you can create a new object outside of paint() or paintcomponent() which gives creating an object... |
I have an ArrayList<LinkedHashSet<String>> setOfStrings for example this arraylist internally is composed like:
positionX[hello,car,three,hotel,beach]
positionY[.....]
...
I want to find car inside this data-structure, so I did it
for (Iterator<LinkedHashSet<String>> iterator = setOfStrings.iterator(); iterator.hasNex... |
I'm building a unittest system. At some point I want to bind two users together in order to make an assignment for those two.
So when the admin chooses to link two students together the system should figure out how to, maybe using the ID numbers of the both users. I have an idea on how implement this, but not very cle... |
It might be related to the Yeoman project, or they might have adopted this from somewhere else, but it seems to be the default for all of their generators. Aside from Yeoman generators I've also noticed it in other projects that have nothing to do with Yeoman (this one for example).
Where did this convention come from,... |
I had a loop through object Process, each process instance can be of a different type, derived from Process base class (e.g.: Process1, Process2,...). Each derived type of Process has different properties. For instance: some Processes are indexable, this is notified by IsIndexable flag. When a Process is indexable has ... |
Does anyone have a good mental model or metaphor for functional programming which references something in the real world?
Object Oriented programing intuitively makes sense to me. There are things that have properties and sometimes they also can do stuff or perform calculations on their properties (methods). (Ex: Car, ... |
When certain parts of code are unusual or unclear, common practice is to leave a comment explaining why it is so. However, sometimes a filesystem may have unusual configuration, such as a directory with 0477 privileges. Is there any convention for leaving comments about this?
I am writing a 'Developers Wiki' for the co... |
Here is a little background of my problem: I implemented a singleton logger class which is being called from several projects.
I want to log the name of the class as well as the name of the method asked for logging.
So far, I thought about two ways to get the name of the method and the class - either by reflection or... |
I have a rails app where my users can buddy up with other users. Since that relationship can have a status (approved/rejected/pending), I decided to go with a join model (UserRelationship) so now I have the attribute.
To handle state for that join model, I have a controller (UserRelationshipsController) with actions/R... |
In Java there are no virtual, new, override keywords for method definition. So the working of a method is easy to understand. Cause if DerivedClass extends BaseClass and has a method with same name and same signature of BaseClass then the overriding will take place at run-time polymorphism (provided the method is not s... |
I am reviewing an approach I see commonly used in storing objects (e.g. a socket client object). Namely, usage of a static container to hold the objects. Said objects are created by some helper function as follows:
create_client(params) {
...
client* cl = new client(...);
return cl;
}
The thing that confused me ... |
this question in my opinion straightforward.
How can I catch an DllNotFoundException in C# as it is just an attribute to some methods use like this:
[DllImport("NativeLib.dll")]
private static extern void print_line(string str);
When are these functions being invoked ? As I instance the class containing the method... |
I have been handed a very cluttered, "One Ring" object (one object to rule them all). The OR class has 40 fields. These fields map to 16 different objects (the OR has all the fields from the 16 objects concatenated together. Some of the fields are common to all objects, some are unique to individual objects [all of the... |
I'll be receiving tens of thousands of XML files, which will continue to grow with new files over time. I need to be able to query these files as a whole (like SQL querying all the records in a database). What technologies and/or approaches should I be looking at for this problem?
I feel like I should be looking into X... |
Can someone please explain to me how to detect collision with another image? The tutorial I was watching explained how to detect if a collision occurs between two rectangles but I would like to use two images instead. Please see the code below.
public void paintComponent(Graphics g){
//g.drawImage(yellowBall, xCoor,... |
I've been building some classes and functions in a static library which has the familiar printing of text messages to stdout:
cout << "Hello World!" << endl;
I've been developing this library for use in a console application but I'm considering also trying to make a GUI version, because it will be both useful and hig... |
As part of a service orientated architecture (SOA) I've been asked to create a
web service which itself acquires data from a third party web service. I'm to hide any implementation specific details of the third party web service and map the data returned so as to avoid leaking any implementation details of the third ... |
I would like to know what, why or when it is better to choose a queuing tool and what, why or when it is better to choose database task table? I don't understand the difference of sending my tasks in a queuing tool or in a database table that will be read and act as a queue. Is there some properties that queuing tools ... |
I'm an Italian developer, but I have a good understanding of English.
Sometimes, when developing an application targeted for an Italian audience, I wonder whether it is correct to use the Italian language in my code or not.
By "Italian language in my code" I mean the names of methods, classes, comments, variables and s... |
We all know sometimes a e.g. merge can go wrong.
If our [unit / integration] tests are in the same repository as the merge, is there then a weakness there that if the tests have merged incorrectly and do not appear in the final code then "we don't know what we don't know".
Should the unit test project then instead be a... |
Organizations, especially organizations with a recognized brand, have various standards for software. This includes things like security, usability, code quality and readability, UI design, test automation and so forth. In our organization we have a lead for each of these areas. Each lead is a very experienced individu... |
I am currently Front End Dev for a large ecommerce store and I'm wanting to switch the entire site to a Version Control System (Git) and Deployment service (Beanstalk). I'm having trouble understanding a couple of things though.
Firstly, my only experiance with version control has been my personal Wordpress Site, where... |
i have this function on which i have to calculate the time complexity with the Big O notation:
public void print(ArrayList<String> operations, ArrayList<LinkedHashSet<String>> setOfStrings) {
int numberOfStrings = 0;
int numberOfLetters = 0;
String toPrint = operations.get(1);
for (Iterator<LinkedHashSe... |
I am releasing software developed in a university under the Apache 2.0 license. I would like advice on who to list as the license owner. Would I list only my boss who co-authored the software and maintains the code base, or both my boss and the institution, or just the institution?
I'm inclined to put my bosses nam... |
Please keep in mind this is not another 'How much [insert programming language here] should I know before moving onto [insert framework here]?' What I'd like to know is how beneficial is it to learn the those advanced concepts of a programming language when your intention is to heavily rely on its framework the majorit... |
I get input strings from the console like this:
while ((currentLine = bufferedReader.readLine()) != null ) {
StringTokenizer string = new StringTokenizer(currentLine, " ");
while (string.hasMoreTokens()) {
// Create a new LinkedHashSet for every token and then add it to the ArrayList.
LinkedHash... |
Program derivation is defined as the derivation of a program from it's specifications. Usually this specification language is some form of propositional logic, but from what I understand, it need not be. For the sake of specificity, I'm only dealing with purely functional languages like Haskell here.
When you write a ... |
I have written my version of strstr function in c. I am using a temporary array of size 26. Then is the space complexity O(1) or O(n)?
This is my code :
void strcheck(char t[], int n, char p[], int m)
{
int i, j, k;
int temp[26];
for (i = 0; i < 25; ++i)
temp[i] = 0;
for (i = 0; i < n; ++i)
... |
A website I'm creating is going to have three breakpoints: desktop, tablet landscape, mobile. Should I write a test for each resolution?
|
I've recently worked on a project where the Team lead was commenting he needed to figure out which stories we are going to be working on in a scrum. It was my understanding that stories are prioritized and perhaps a number of stories are added to a sprint from that list. At this stage during our scrum the developers ... |
My Sprite class has a method:
private void updateWithBitmap(Bitmap b, int x, int y)
This will 'lay on top' the bitmap that's passed in, the top left corner of the passed in bitmap being at the x,y position of the parent bitmap.
Now I want write unit tests to check that this method is working correctly.
For example, w... |
How is coded UI testing technique more favorable than any other testing technique? What is the main advantage of using a coded UI test?
|
I want to develop a product comparison page, where a user can compare 2 or 3 products. I was thinking about a 3 column list displaying every specification. But I want to highlight the differences.
I could use a list and sort them alphabetically. And then if element x of list 1 is not equal to element x of list 2 then ... |
Having spent quite a lot of time working in software companies that deal in medium to large data sets, I've seen that a choke point in their processes is often prepping data files for loading into databases. For example, searching for formatting errors, peculiar whitespace or line-end characters, wrangling with Unicode... |
We use JS by the way, but I think it's language agnostic. I'm open to ideas.
We have this "pub-sub" framework that we use at work to fix the problem of tightly-coupled code. Works fine. Modules listen to events, things run, broadcasts events, more things run. It's amazing. However...
For instance I wanted to click on ... |
As an exercise for myself to practice my JavaScript "skills" I'm trying to write a client-side filter. It should be able to filter "content blocks" as the user types.
By "content block", I mean a list of DomElements that each contain at least one text node - it is possible that they contain more, and even a different a... |
I have quit a lot of javascript widget and I would like to have a good decoupled way to communicate between them. Something like signals and slots in QT probably? Most of my widgets are written in JQuery using widget factory.
What is the correct way to achieve that, without ending with a spaghetti code?
|
Is it necessary to call free function every time we use malloc in C.
I am asking this because I have seen many times that it is not called .
Thank you
|
It feels right to put format validation inside the domain objects (VOs or entities) because it is the natural place for high cohesion and the domain knows best what every domain description/attribute/property means. Many DDD practitioners and books authors (Vaugh Vernon, Dan Bergh - and even Eric Evans suggest , but on... |
I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS and at the client we have Javascript widgets. The client x server requests are done through ajax calls.
I have lots (100+)... |
I am creating an "Alarm Clock" app in Android. I learned that we can implement OnReciever() method and write those things which we want the alarm to do after an intent is fired.
But I have now come across the "Services" of android which is (might) be useful in the app.
Which one should I prefer, keeping in mind the sim... |
Example:
int c = 4;
int p = 5;
if (p & (1 << c))
printf("ok\n");
else
printf("nop\n");
gcc -S:
movl -4(%rbp), %eax /* eax holds the variable c */
movl -8(%rbp), %edx /* and edx holds p */
movl %eax, %ecx /* tmp(ecx) = c */
sarl %cl, %edx /* edx(p) >>= c */
movl %edx, %eax ... |
GNU General Public License is a ‘Viral License”. If an organisation is using Linux and MySQL which come under this license, is it dangerous to the organisation in terms of exposure of its intellectual property? As this license will demand the software that is linked to or that incorporates a GPL program to also be ma... |
Following this comment, I've tried to google why, but my google-fu failed.
Comment from link:
[...] But the important thing is that arrays and pointers are different things in C.
Assuming you're not using any compiler extensions, you can't generally pass an array itself to a function, but you can pass a pointer, and i... |
Imagine the following scenario:
Codebase of 600,000 lines of code (C#)
All in a single desktop application
All written by a single developer (myself) over 8 years (3 years worth of actual coding time).
The software is powerful and flexible (obviously vague), thus there is inherent complexity in the code, even if it is... |
I'm working towards implementing Gitlab at my company with a workflow strategy. My idea is that developers will be given access to repositories but, anytime they try to commit, their code must be reviewed.
I know I can have them create a branch before committing, and then create a Merge Request after it's been pushed t... |
Is there a specific reason that this would break the language conceptually or a specific reason that this is technically infeasible in some cases?
The usage would be with new operator.
Edit: I'm going to give up hope on getting my "new operator" and "operator new" straight and be direct.
The point of the question is: w... |
I am writing an interpreter for a functional programming language that is going to run in the browser. Needless to say, performance is the one and only concern in this application. Emscripten is an LLVM→JavaScript compiler which claims to produce programs that run only 2~3 times slower than native. It is really surpris... |
I'm looking for a little guidance. Until this morning, this was all over my head. After spending today researching Wikipedia, StackOverflow, etc., I'd say I've got my nose above the water. I'm tasked with researching a project that, as I understand it, would involve reverse-engineering a domain-specific language that i... |
I can't attain the primary used of Static Visibility. My question is why they used static method & properties in this code?
class PassHash {
// blowfish
private static $algo = '$2a';
// cost parameter
private static $cost = '$10';
// mainly for internal use
public static function unique_salt()... |
I am modelling a programming language for fun, and the syntax is heavily influenced by Scala - specifically function definitions.
I have encountered a design problem because my language does not differentiate between functions defined via the def syntax (class methods) and anonymous functions assigned to values (create... |
I'm trying to understand the flow of Android apps. I come from a RoR background, so I try and use that background to understand new concepts in Android.
Here's my question:
How can I think about fragments? Are they like partials in Rails? If so, how? If not, why?
|
How do you handle the following scenario without null?
You have this problem (In Java):
BigDecimal sales = ...;
BigDecimal cost = ...;
BigDecimal profit = sales.subtract(cost);
// Profit Margin = profit / sales
BigDecimal profitMargin = profit.divide(sales, 20, RoundingMode.HALF_UP);
Because sales is sometimes zero, w... |
I have an embarrassingly simple question, but I need to make sure I understand this correctly. I have a *.c file with the following line:
CSRConstant = 2*macroParticleCharge*particleCharge/pow(3*rho0*rho0, 1./3.)/(4*PI*epsilon_o*particleMass*sqr(c_mks));
Is this interpreted as:
|
When I started learning C programming a few years ago, my tutor taught me similar to most of the tutors around the world. She said me the very basic things like any int datatype is of 2 bytes memory. If the following is my code,
#include"stdio.h"
#include"conio.h"
void main()
{
clrscr();
int i,n;
n = 0;
... |
So I understand that thiscall doesn't really exist in x64 programming. However, I can't really find any definitive explanation as to where the this pointer is put to be passed to the callee.
Is a x64 thiscall like a true cdecl call, where this is put on to the 'stack' last (on both GCC and MSVC compilers)?
EDIT: Runnin... |
I am writing a game in Java and it can be likened to the recently popular game "Flappy Bird" in the sense that the character moves up and down and the users touch and must avoid the obstacles.
The obstacles are going to be asteroids of varying sizes. I want to spawn these in at a random y co-odinate and with a random s... |
After learning, coding, and coding even more than ever now, I have noticed a trend in a lot of programming which I do. The trend is that the majority of my functions are if{} or if{} else{} statements when it comes to performing the functions in my code.
I narrowed out the option of it just being the project which I am... |
Consider I have a service called FileSystem, and that this FileSystem is used by various classes throughout the application. Typically, the service is acquired via some static class method ServiceLocator.getService(FileSystem.class)
Now consider I have a class Game, that depends on the FileSystem object to open up some... |
I'm currently working on a certain problem for my company (i.e. where I work for hire and don't own the code I produce in any way). It appears, that in one of my past (or, who knows, maybe still present) personal projects there are a few useful source code files that should help with the problem I'm working on. Neither... |
I have a problem visualising how the gap is closed between coarse-grained, n-tier boundary, high level, automated acceptance testing and lower level, task/sub-task scope Unit Testing.
My motivation is to be able to take any unit test in my system and be able to follow backwards, through coverage, which scenario(s) make... |
I learned Java and I'm pretty competent programming in it. I also learned C recently.
I looked at a comparison between Java and C++ and I like C++'s features like operator overloading and its speed.
So, C++ is an OOP language, but it also has all the things java doesn't have and C does, like pointers and memory allocat... |
I'm using Yii for a few years and only right now I realized, that their demo application (empowered by CRUD auto-generation tool -- Gii) seems to be breaking key MVC architecture pattern. I'd like to discuss this here.
As long as I've been using MVC (about four years), I was always told, that view should not acquire da... |
I'm designing my first real database and I'm weighing the pros and cons of how to enforce uniformity in my data. My first option is to create a custom domain and program my UI to only allow certain options. My second option is to create an "attribute reference table" that would store allowed values. My UI could query t... |
Background
As part of a broader application that allows users to search thousands of MS Office documents on a private network, I need to index and make searchable Microsoft Excel files.
My basic approach for all document types is this:
Loop through the raw directories I have been given,
Upload the document to a networ... |
I'm designing a payroll system I have designed a database with several tables and this question is related to following tables
EMPLOYEE (Employee_ID [pk], Name,... etc)
LOCATION (Location_ID [pk], Name, Address, ...etc)
These two tables have many to many relationship as one employee can work in several locations and in... |
One of the best-known examples of a full-fledged object pool is the JDBC connection pool. Main reasons:
objects in the pool are expensive to create and relate with external resources
each object in the pool is served to at most one client a time
objects in the pool need to be brought back to a clean state before being... |
I'm wondering how better to perform this operation for a large amount of files. The bit I'd like some thoughts on whether this copy/paste is acceptable enough of a tradeoff.
try to write a file
if the target dir doesn't exist, create it
try again to write the file. If something else throws and exception, let it raise.... |
I'm developing web application using PHP with CodeIgniter MVC framework with a huge real time client-side functionality needs. This is my first time to build large scale of client-side app. So I combine the PHP with a large scale of Javascript modules in one project.
As you already know, MVC framework seperate applicat... |
I was researching on statically typed and dynamically typed concepts and found out there is another type system called gradually typed.
From wikipedia
Gradual typing is a type system in which variables may be typed either at compile-time (static typing) or at run-time (dynamic typing), allowing software developers to ... |
The required user interface is fairly simple; basically, two tables that "interact with each other", e.g. certain rows in one table get highlighted when a row in the other is clicked, plus maybe a panel with charts.
Is it possible to have a (largely) single code base for a desktop app and a web app implementing this in... |
I recently had a job interview in which they gave me an hour to write some real code. It wasn't a huge amount, probably less than 100 lines. After about 45 minutes, I compiled, ran it, and got it to work. I may have spent 5-10 minutes working out compile errors and a couple minor bugs, but overall it was very smooth... |
I am programming in Java, and I always make converters sort of like this:
public OtherObject MyObject2OtherObject(MyObject mo){
... Do the conversion
return otherObject;
}
At the new workplace the pattern is:
public void MyObject2OtherObject(MyObject mo, OtherObject oo){
... Do the conversion
}
For me it ... |
I'm working on a messaging application, based on a server/client architecture.
Now I am thinking about the way how to store the user credentials.
It's not a huge number, just about 20 entries with their User-IDs, Usernames and hashed passwords.
Storing it with a SQL Server in my opinion is overkill.
Is it better to sto... |
I am developing a web application. The frontend is a mix between JavaScript and server-side generated html. The backend is written in Golang. Might not be very important, but if somebody made a similar experience with that language, it could be of help.
As of now, everything was written in vim, and "debugged" in the br... |
So imagine this scenario:
There is only 1 developer, who also is the bottleneck (testers, etc are busy on other contracts).
There is a nontrivial backlog of tickets, most of which are blocked for not being reproducible, unintelligible requirements, unsolvable (with current ideas, staff and technologies).
Is there any p... |
I am trying to write a web application that interacts with a service that would run scripts at the system level. Something like a website that you can schedule a job, the service will run the job with the given inputs, write the outputs to a database, and inform the website of its status.
A few questions:
How is this t... |
I bet I could answer that myself if I knew more about tools to analyze how C#/JIT behaves but since I don't, please bear with me asking.
I have simple code like this :
private SqlMetaData[] meta;
private SqlMetaData[] Meta
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
... |
The following declaration gives an error:
type Vec2d = (Float, Float)
type Vec3d = (Float, Float, Float)
-- Rect x y defines a rectangle spanning from (0,0) to (x,y)
data Obj2d = Rect Float Float
| Translate Vec2d Obj2d
-- Cuboid x y z defines a cuboid spanning from (0,0,0) to (x,y,z)
data Obj3d = Cuboid Flo... |
Say we have a GPL library (CGAL for example). We have a big tasks chain like pipes modeling and testing. We would love to use library for our indoors application yet we must open sources... so we make a minimal application that takes arguments and files in, and returns files and data out. And is being used like closedS... |
I have a program that I run repeatedly with various parameter sets. Different parameters are used in different parts of the program (including different source files). The same parameter may also be used in different places. However, all parameters are constant during run-time after they have been set.
I discovered ver... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.