instruction
stringlengths
34
19.9k
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...
In learning Python, I found that when two "names" (or "variables") are assigned to the same value, both of them point to the same memory address. For example >>> a = 10 >>> b = 10 >>> a is b True My question is, when assigning b, how does Python figure out that a 10 object already exists? One way might be to create th...
I have made a large number of modifications to some MIT-licensed source code to tailor it to the requirements of my project. Since this is JavaScript (for a website) the minified source code is naturally attainable by anyone viewing the site. Whilst I am happy for people to use the source code under the terms of the MI...
FlashPunk is a third-party graphics API for simple game development in AS3, and they take what are effectively sprites or display objects of some sort and refer to them as "Entities". Entity is the actual class name, and it's the predominant class to use to animate something such as a character moving on the screen. T...
I have written a python program to test a new network routing algorithm, that uses a Content Centric Network Approach for handling requests (CCN), where the CCN router keeps 3 data structures: A PIT or Pending Interest Table, that holds requests for which a router has not yet received a response. A FIB or Forwarding...
My project leader uses project based prefixes for class names, lets say projects name ABC, he create User class name as ABCUser. and he says he do this becasuse if he wants to make User.aspx Users get mixed. so I told him why not use namespace (Entity.User ie.) to make it specific but he against it. I would like to hea...
I am designing an API for a driver that manipulates HW. I have done the following: namespace HWRegister { //private: namespace Data { //accessible only within this namespace //Represents one of the four HW blocks. enum EHWUnit { Block0, Block1, ...
If I have server with 256 Gb of ram. I was wondering can I create a C# application which has a 100 GB of memory footprint? I want to create a dictionary like Dictionary<DateTime,Dictionary<string,Dictionary<string,DataClass>> Fist dictionary DateTime - Max 40 distinct values Second Dictionary string : 2000 distinct v...
I'm doing a research on PHP and wondering if there any other commonly used programming langues that use an associative array for both simple indexed element storage and key-value functionality. Does it make PHP unique in this sense? For example, a language like C# distinguishes clearly between a simple array and a map\...
Let's say I have a relational database application and a "user" object and a "message" object. Now I want to show the number of unread messages to this user. What's the best way to archive this? Do I introduce a field in the user and count it up if the user receives a message and decrease the count if he reads one? Or ...
So I am working with a customer who has an older application that has quite a few interesting quirks. Among other things, it has its own code version system for business functions, by storing the entire algorithm version in a database. The data is then retrieved and compiled on request (this is a web application, and y...
I am starting out in Java API design and in reading existing code bases, I have found that most APIs consist of interfaces only with their implementations bundled in a different package. Having read that interfaces are generally more problematic to use/maintain than abstract classes, why aren't abstract classes used i...
I have a REST API that looks something like the below where a person can belong to an organisation (but doesn't have to) and a person has many items. The items may also belong to the organisation instead of the person. /people/:personId /people/:personId/items /organisations/:orgId/items /organisations/:orgId/people/:p...
Everything I've read says to pass parameters to a REST service in the URI, whether by template, or query string: https://www.myapp/my/login/api/authenticate/ganders/mypassword or https://www.myapp/my/login/api/authenticate?user=ganders&password=mypassword But obviously those are exposing my username and password in c...
I've got trouble wrapping my head around a certain problem: In my data-flow app (a visual editor), I have both autonomous objects which communicate though ports via unordered simultaneous messages and thus represent an asynchronous system. Still, I also want to use functions which are synchronous, e.g they need input...
I am learning from Learn Python the hard way where I have come across a study drill where they want to know that whether a class can be used like an object. As I have experimented: class A(object): def __init__(self): print "in here" def cat(self,name): print "my cat ",name Here if I write A.ca...
I'm using OSGi for some time and I really like the ability to swap/replace components while my application is running. I simply have to build my module and push it to the OSGi container. Is there a similar concept/framework for clojure? I know about leiningen's dependency management which really helps modularity but I...
I wrote an application that tests the performance of evolutionary algorithms. This application performs a run of the algorithm which consists of several generations. The data which is produced by my application looks like this: run1.run // text file containing metadata run1_data // folder contain...
The .NET CLR is not an interpreter, since code gets compiled to native code by the JIT compiler. So I find the usual description of code "running on" the CLR confusing. How does the native code interact with the CLR? Does the compiler insert calls into CLR methods at the beginning and end of your methods, for example?...
There is a source file in a rather large project with several functions that are extremely performance-sensitive (called millions of times per second). In fact, the previous maintainer decided to write 12 copies of a function each differing very slightly, in order to save the time that would be spent checking the condi...
I'll change my personal code often and not worry about going back and changing the associated variable names. Should variable names be maintained in case of meaning changes? var accountCurrentValue = x; var accountYesterdayValue = y; var accountValueChange = accountCurrentValue - accountYesterdayValue; --> accountPast...
So, I work as a developer. We are a small team. The majority of the people (everyone except the project manager and the senior developer) are still in university. We have very flexible work hours, sometimes I don't see some of the people for 3-4 days. You can imagine that communication is key here. We write a lot of em...
I've built already a bug report system. It looks like this: It is accessed using a secret key combination detected by the JavaScript code. Not hard. It has everything - sends the standard emails to management and testers, logs the Javascript variables and current DOM HTML. We are also improving the backend of the syst...
Look at the following use case. I have a client (Java) application, which wants to get/set the state of another, remote application (C). The communication between them is done via SIP, which is run in another thread. The SIP interface can do the following: sendMessage onRequest I have two ideas for the architecture: RP...
I'm working on an Android social app which connects to a Postgresql database for up-to-date user data and is going to use lookups for dropdown menus, and these lookups will either have multiple options (e.g. for eye color, the menu would show 'blue', 'brown', 'green', 'hazel', 'red', 'white') or boolean options (e.g. f...
I have simple set of resources, not more than 10 types, with some one-to-many relationships. For example An order has many entries An entry has many comments A machine can have multiple entries associated A material can have multiple orders associated All the model objects are identified by a unique Primary Key I com...
Let's say Alice has a Git repository, and the version is kept track of inside the repository (e.g. package.json for npm). Bob sends a pull request to Alice which increments the version number from 0.1.0 to 0.1.1. Carol also sends a pull request to Alice (independently from Bob's request) which increments the version nu...
I use the Entity Framework often, but I have one area of confusion I would like to understand better. If I wanted to have a navigation property in an Entity such as public virtual ExampleObject Example {get;set;} it is also the done thing to have an Id property public int ExampleId {get;set;} My undertsanding is thi...
I am working in a team of 4 members. we have started reviewing code 2 months ago. we are using Gerrit as code review tool. while reviewing code initially we have found lot's of problem in the code i.e. no proper code comments. method are too big. no null pointer checking. no proper exception handling etc. but now a da...
I'm making an iOS game. All developers need to determine whether their app uses cryptography or not. My game saves files in the Documents folder. They are .plist files representing dictionaries. They are encoded in base 64. From what I gather, encoding is not encrypting. So we're fine there. However, the values inside ...
I'm looking for a reasonably(*) space-efficient way to encode arbitrary-precision decimals (e.g. BigDecimal), such that when sorting the bit-pattern of the encodings lexicographically, the numbers will be sorted numerically. This is related to this Stackoverflow question. One simple/naive approach to this would be to c...
Given a liked list, I'd like to swap every pair of nodes as follows: input: a-b-c-d-e-f-g output: b-a-d-c-f-e-g If there's an odd number of nodes then the last node is tacked on as-is. This should be done in-place. Implement the method: Node* SwapTo(Node* start) I'm using this Node definition: class Node { public: ...
We are currently designing an API that will hide different services (Product, Content, User etc) that will be used by our own website, our own apps etc. It is not a public API. We are looking into using ServiceStack as a foundation, and that might be right. However, the biggest concern is how to manage the users (each ...