instruction stringlengths 34 36.1k |
|---|
So I have to create an object design for this application, it is just problem for practicing.
You are building application that will load data from several
different advertising systems and then store the data into database,
so it will be possible to analyze them.
You need to take in mind that every advertising s... |
I am storing numbers in my database without formatting (e.g., 1434587). But I need a formatted string in the UX (e.g., $1,434,587).
Is it better to store the raw number AND the formatted value in the database? And simply retrieve it to show to the user? Or is it more efficient to only store the unformatted raw number o... |
One of the main reasons for writing unit tests is to make sure that code still behaves the same way after refactoring. However, if interfaces change during refactoring, the tests need to be updated as well. Changing tests and production code at the same time introduces risk. How do you avoid it?
As an example, say you ... |
This is an interview question that I've run across a few times, and I'm really not sure how to solve it given that four numbers are missing. I'm familiar with algorithms for finding one or two numbers are missing, but I don't see a way to generalize either of them to four.
|
I need to be able to support clients on both MySQL and PostGres databases in a legacy application that does not use any ORM. Say, I have the following interface to query a list of users.
public interface IUsers
{
...
}
I have two implementations for the above interface. One for MySQL
public class MySQLUsers : IUsers... |
Let's say that I'm running Nginx as my webserver. I know that Nginx handles the -s reload command which will reload the configuration when it's changed, but waits around for current requests to finish before it cycles the worker processes to use the new config, so hooray, no downtime!
But what about changing actual fil... |
Imagine you are creating a video player in JavaScript. This video player loops the user's video repeatedly. Each time a new loop begins the player runs a recursive function that calls itself N times, N being the number of times the video has looped, and because of that the browser will trigger a too much recursion Rang... |
I'm exploring the relationship between decentralization and distribution, and I've come to a question for which I've found no real explanation. Does the qualification of a system as "decentralized" infer that the system is distributed?
Using the practical example of a star topology in which the central node sends dire... |
I have a string series[Episode 37]-03th_July_2010-YouTube and I want to extract the number which comes directly after Episode (eg: 37 from Episode 37)the position ofEpisode 37` may not be fixed in the string.
I tried:
def extract_episode_num(self,epiname):
self.epiname = epiname
try:
self.temp = ((self... |
I want to split a C++/CLI application on two parts :
1. Communication Part, with I/O + logging on text file :
3 COM Ports, 2 sockets and 1 log file
2. UI Part, to handle the data received from COM Ports, sockets etc...
For the moment, my application is constantly reading from all COM Ports (with some writing when neede... |
Just for the sake of discussion below, when I refer to mocking, I mean mocking/stubbing/faking, as contrast to use real implementation in testing
I just had some discussion with my colleague during a pair programming session regarding whether we should use mocking in unit tests for our own written code. (Not sure wheth... |
As I am learning DDD to help build an app idea the proper way ;) I have come across a confusing aspect that I am trying to find a solution for.
I understand the need for Uuids in an app the size of which I am creating, but I am a little lost as to what method I should use to create Uuids for user-generated objects.
I h... |
I am building a SPA that basically incorporates multiple video streams (using WebRTC) and various other components such as a text 'chat' feature.
I have spent a couple of weeks building a proof of concept prototype using vanilla javascript, jQuery, HTML 5 and Node.js. I was considering using a framework like Angular, o... |
Windows Console App vs Service
I would like to extend the question at the above post, as the previous answers did a great job of helping me understand the difference between a service and not a service.
The question I have now, is with applications that require to be up 24/7, what security concerns there are with a use... |
I am writing a class which periodically has to check, if the data it manages is too old, if so it should delete it.
I am new to the C++11 multithreading library and I have the following questions:
Is such a periodic task better suited for std::thread or std::async?
If we use std::async how long is the cleanUp functio... |
In building my classes, I have noticed that I have not been very consistent about naming my boolean returns. In Qt; I notice that many of their classes use the is prefix, but checking their coding style and conventions, there is no explicit mention that I have seen thus far.
Does the Qt project use a standard or metric... |
After some serious quality problems in the last year, my company has recently introduced code reviews. The code review process was quickly introduced, without guidelines or any kind of checklist.
Another developer and I where chosen to review all changes made to the systems, before they are merged into the trunk.
We w... |
Say I have a function that takes some arguments that fall under a bunch of constraints, e.g. one of them has to be an integer, another has to be a string of length at least 10, et cetera. In general, is it the function writer's (i.e. my) responsibility to have a bunch of asserts or whatever to enforce these preconditio... |
I have two applications. The client application is written in .NET and the server application is written in native C++. I am using TCP sockets for data communication between the two applications.
However, this data is sent over plain text and therefore can be intercepted. What is the best way to protect this informati... |
I know in lua you can do something along the lines of
print=System.out.println
print("Hello")
But is there something similar in java?
|
I understand the concept behind Composition ('has a') where the contained class is destroyed upon termination of the container class. Likewise, I get Aggregation which is a 'looser' relationship between two classes, and termination of one object doesn't dispose of the other entirely.
The hard bit, for me, is to actual... |
I've been trying to get a clear understanding of what the end of the follwing code outputs:
class C {
public int foo(C p) { return 1; }
}
class D extends C {
public int foo(C p) { return 2; }
public int foo(D p) { return 3; }
}
C p = new C();
C q = new D();
D r = new D();
int i = p.foo(r);
int j = q.foo(q);
int ... |
I do a lot of programming in my class. It's just my first semester, and most of my stuff is review. I've taken to using a verifyInput function to ensure that user inputs match certain criteria. Since I end up using verifyInput so much, I keep coming up with more ways to enhance and expand it. At the moment, my code loo... |
Hi I have a data structures programming project involving creating my own array based list and then efficiently storing String read from a file but in reverse.
So that arr[0] = the last line of the file
Initially I just thought to have two for loops:
First to store the data by its order in my list
Second to create a ne... |
I want to develop application using java frameworks(spring,hibernate,strut). This application has large complex operations.I want to know what is the best between JSF and angular? As well as i want reference for compare those technology
|
Take C++ constructors for example, we know they don't return values. Why did Bjarne Stroustrup in the beginning decide not to allow constructor returning 'false' to indicate it fails, so that the run time system can destruct its constructed members just like throwing an exception? What are the concerns that make OO lan... |
I have a git repo on the internet and two workstations. Other developers have access to the git repo.
Workstation A is at the office and is not accessible from the internet, but can push/pull the git repo. Workstation B is at home.
I'm working on a private local branch on Workstation A and have to leave for home when i... |
My current workplace has several disconnected teams that depend on each other.
There are several legacy prjects with project files.
I want to find a way to find a way to visualize our architecture so we can identify "upward" references and nail down where we need to add additional testing.
Is there an automated or semi... |
I'm having a hard time trying to figure out why the two methods declarations have different results.
On the first method signature its obvious you can't compare Apples with Apples and Oranges with Orange, because none of them implement Comparable<>.
But on the second method I was surprised that you could actually compa... |
I want to design and implement a mobile application in which:
Every user who have already registered is able to add new news
(including title: text plus a picture, and content: long text,
pictures or even videos).
Users can scroll hot news (from the News Page) and make decision to
read one. They might press the like b... |
I'm beginning using AngularJS (v1) framework, and after browsing good practices I found those examples (from this page https://github.com/johnpapa/angular-styleguide/tree/master/a1), like :
/* recommended */
function SessionsController() {
var vm = this;
vm.gotoSession = gotoSession;
vm.refresh = refresh;
... |
With pre-built CMS usually comes a lot of features that you do not need in your typical smaller project for small businesses and in the end you have to write a lot of your own functionality for said project anyways that is missing. So basically CMS in that scenario saves you initial time overhead of not having to desig... |
In object oriented design, we define solution domain with classes. We give a particular role to each class such as factory, data transfer object, serializer, validator, service, proxy, adapter, etc.
Do you know a common name for this concept rather than role?
|
I'm currently working on a computational physics code in Fortran. In summary, the code performs the following operations:
Initialize
Loop until done
Advance solution over time
Possibly write output
We want to support different physics modules, which solve different equations. I am thinking about the following desi... |
We have a database backing an iOS and Android app whose primary data is a simple text field. We have a build tool which builds the database - taking a raw txt file which is a custom data format, which looks like:
---
.id SOME_ID
.author AUTHOR_NAME
.field MORE_DATA
.data_title TITLE
Data data data [#tag, #tag, ...]: s... |
Suppose I eat five meals a day, and since there are seven days in a week, I have recipes for seven of each meal, for 35 recipes in total. Each recipe has a calorie count. Each day must contain one recipe per meal, and each recipe is fixed to a particular meal (e.g. you can't have pancakes for dinner). All 35 recipes mu... |
TL;DR: I have noted that some tutorials are using an extra method call to retrieve a variable, in my case EntityManager of Doctrine. Is it generally a good idea to use such extra method call, when it seemingly adds overhead, even if this overhead is "just a little bit" of overhead? In my case I am talking about the c... |
I'm new to compiled languages. I'm learning C. I'm used to coding in python.
I was wondering if there was any equivalent, or replacement method in compiled langues for functions able to create a function, and to return it.
In python one can write:
def genAdder (p):
def adder (n):
return n + p
return add... |
I've setup a Gitlab server to manage several different Laravel Apps. I'm also able to configure the Gitlab CI to deploy the code to the development and production sites. Everything is kind of streamlined.
The problem is Clients want to make many small text changes in the view files. Most of them are fixing the grammati... |
I recently upgraded some tests that unearthed a lot of previously hidden bugs. The bugs are rare and low priority, but they are still bugs and will eventually need to be fixed.
How should I handle the changes to the tests?
If I check-in my changes, many existing validations will fail, and given that these bugs are rel... |
Is it correct that hashtables assume no key is shared between more
than one records?
In other words, can hashtables be used for implementing multimaps?
When using a hashtable, can't multiple records with the same key
value be dealt with in the same way as dealing with hash
collision?
Specifically, can the following op... |
I want to try a whole bunch of azure services in my project. Now I facing a design problem for the development cycle. I want to test everything local and only it works I want to push it do azure. My OS is manly linux and osx, but there is e.g. no azure storage emulator? Is there a workaround?
|
Suppose I took the libstc++ implementation of a C++ standard class, and modified it (so now I have, say, a magic_vector based off of the code for std::vector).
What licensing restrictions does that imply for that file specifically and for projects using it? I'm asking about libstdc++ specifically because
I read here t... |
I am interested what would be the ideal way to scale Microservices in DDD world?
In case of the following scenario, where Sales context is hosted as a microservice on a different host then Support context, if sales context exceeds hardware limitations, would you:
a) scale vertically (increase the resources of the serve... |
Just to re-cape cache-aside pattern it defines following steps when fetching and updating data.
Fetching Item
Return the item from cache if found in it.
If not found in cache, read from data store.
Put the read item in cache and return it.
Updating Item
Write the item in data store.
Remove the corresponding entry fr... |
A faster prime number generator with hyperthreading and L1 cache
About five years ago I wrote a simple VB widget to generate the first one million prime numbers and then port them to into its single VB listBox. It took about four hours on a 1.4 GHz Athlon with 1GB of PC-3200 DDR. I was wondering about some possible tip... |
I have a file parser and my manager told me that I need to create unit tests for it. Here is my code:
public class ParsedDetails
{
public int Id { get; set; }
public Guid Guid { get; set; }
public bool IsValid { get; set; }
}
public class CsvParser : IParser
{
private const int CsvColumns = 2;
priv... |
In my computer science capstone project, we have a team of 5 working on various things for an Android app for Pokemon as a multiplayer game (Github). One or two people are working on implementing the "battle engine" for the Pokemon games (Generation I only). This feature has a lot going on. Initially we had a single is... |
I have been having quite a time getting this to work reliably for 100s of thousands of terms and potentially millions of pages per source and ETL the resulting data into a database in an automated fashion. I need to run the tasks in Mesos on a repeating schedule. The required languages are Scala/Java.
For acquisition... |
So for my newest hobby project, I want to create a simple chat application where users can just log in with a nickname (no passwords) and talk to anybody on the network.
Off the top of my head, I'm thinking about this design where a frontend Client acquires a User object by registering with a nickname.
A Message objec... |
I know several frameworks have this functionality built in where you can use their special methods to make DB queries. I also know this is (partially) to ensure that everything is handled correctly to avoid breaking things. So here is the question, if one not using a framework, is there sufficient benefit to using a cl... |
Here's the problem:
Given an m x n array, get the number of different paths from the top left corner to the bottom right corner, if you can only move down, right, and diagonally down & right.
Here's my memoized recursive solution, which is relatively straightforward. It works because the number of paths from position (... |
We have a small team currently working on numerous projects. We originally started out as a two person team and jumped in head first without any kind of source control. We currently break numerous best practices and do development on live sites (yuck, I know).
We're in the process of fixing this issue incrementally. Th... |
In HTTP 1.1, a web server could return a 304 Unmodified response when a If-None-Match header is included in the GET request.
For REST API, I've only seen implementations involving server-side caching of the entire response contents where the cache is typically invalidated on subsequent requests to modify the same resou... |
I'd like to know or have other ideas --other than my solution-- about how to check if a car on a given position (lat, lng) is getting away (let's say a distance D away) from the path where the car should go over. Another condition for my problem is that there will be queries with different points (positions of the car)... |
The question is long, so I will paraphrase it briefly
Q: There are n people voting to choose the chair of the committee. Each person can vote for one person that has unique id (it is positive integer and vote will be stored in array). Chair will be the one with the most vote. Design algorithm to determine who is the ch... |
I am currently trying to write a unit test of my own. The unit test I am writing is mainly for linear algebra (I know there are great package out there but I want to use my own for my project). My current linear algebra consist of my_vector.hpp/cpp (3d) and my_matrix.h/cpp.
So I am currently writing a test_vector.cpp ... |
I'm currently working as a senior dev with 3 juniors below me and have introduced a code review process to help manage the quality of code going into production.
I feel its very beneficial for all of us to review each others work, however after about 5 weeks of the process I am the only one to make any comments in the ... |
I am looking for an efficient algorithm to get unique (non repeated) x amount of integer random numbers that are within the y and z limits.
e.g. I want x random integer numbers that are bigger or equal to y, smaller or equal to z and each random number is not repeated.
I came up with two solutions but none of them see... |
I am reading through Wikipedia's page on UML state machines. I don't understand where it says:
A nested state is called a direct substate when it is not contained by
any other state; otherwise, it is referred to as a transitively nested
substate.
I want to understand the difference between a "direct substate" and... |
Our current project consists of multiple modules in /modules/. When I work on my current module and i.e. update its README how should I write a commit message for this?
Update README
Update README in module_XYZ
Update README [module_XYZ]
module_XYZ | Update README
Something else?
I think 1. has too less information ... |
The title pretty much speaks for itself, but I'll provide the current decision I am facing.
I am migrating python code towards the use of generators. The current code looks like this:
...
l = returns_a_list(args)
log.debug('examining {} entries', len(l))
for e in l:
do_stuff(e)
...
Outside of the debug log, l fits... |
I want my Wire objects to be in connection with Port objects. That is Port has a list of connected wires and method Port.add(wire). Similarly, Wire has list of ports it is connected to and Wire.add(port).
class Port
Set[Wire] connections
method add(wire)joined)
class Wire
Set[Port] ports
method add(port)
Sup... |
I have tried to implement the Passive View MVP in my WinForms application as much as possible. The Presenter is the only one who uses the Model and the Presenter responds to events that are generated in the View. The View in fact is very 'dumb' as it only fires events and deals with the form controls.
Now my question, ... |
assume Service S want send data to mobile App in device A in arbitrary time without client interaction.
what is best way to keep track of A IP?
the only way i can think of is to run a service for keeping track of A public IP (locally on A) if changed -> update S database with new IP.
It there better idea?
|
I'm trying to code a dice game where users log in and then challenge each other. I already made a version of this game without login but only one game could be played at a time.
So now, there will be the possibility of several games going on simultaneously between users.
In the non-login version I needed 4 tables for e... |
In my application I fetch files from the user and process it.
Im to limit to a certain scope of file types and each one of these has a different processing approach.
How can I design the application in order that when a new type of file is added, I have to change few to no lines in the controller classes.
Should I be u... |
I have been looking at VC++'s C4267:
Compiler Warning (level 3) C4267
'var' : conversion from 'size_t' to 'type', possible loss of data
The compiler detected a conversion from size_t to a smaller type.
To fix this warning, use size_t instead of type. Alternatively, use an
integral type that is at least as large as s... |
I'm confused about choosing names for my functions in Python. Sometimes Python built-in functions are imperative such as: print function and string method find. Sometimes they aren't such as: len its name isn't imperative such as calculate_len, for instance, and type isn't find_type.
I can understand that print returns... |
I suppose that this is a common situation: I test some code, discover a bug, fix it and commit the bug-fix to the repository. Assuming that many people work on this project, should I first create a bug report, assign it to myself, and refer to it in the commit message (e.g. "Fix bug #XYZ. The bug was due to X and Y. Fi... |
How do you guys go about entrusting third party packages, libraries, etc. into your projects? In other words, what steps, if any, do you take before incorporating an outside component into your project? Does the sheer number of downloads satisfy your assurance that it is safe? Is it considered safe if you downloaded... |
I have read this and this and this: if my question misses the point in those answers, please point it out and we'll get this one deleted. These questions indicate that this may actually be a bad thing under certain circumstances, but I think I understand that difference.
QUESTION: If I am using a function from another ... |
we have started with microservices recently, but we have some problems with implementing the Security layer.
The idea is that the request comes to Gateway, the Gateway looks to authorization header, it validates user, create JWT token and then sends request with info about user to another microservice internally. The m... |
Suppose I have some Modules that each are their own component
I would now have different Testprojects spanning different modules.
UnitB_UnitTest, UnitC_UnitTest, GUI_UnitB_ComponentTest, GUI_UnitB_UnitC_HDD_SystemTest
If I concatenate every Modulename involved in a Test with underscore the names will get huge and diff... |
The internal framework my company uses has a pretty pivotal Object that has a pattern of being instantiated as a member of a class with a no argument constructor but to be usable you have to call a start method. I understand that constructors are generally minimalist but at the same time why be able to construct an unu... |
this question is actually about a complex java project I am doing at university, but it is possible to find a simple case which is really similar to the problem I am facing.
In this scenario, we have an app with free version and premium version. A user registers the app for the first time and uses the free version by d... |
What I mean here is how do we go from some template T add(T a, T b) ... into the generated code? I've thought of a few ways to achieve this, we store the generic function in an AST as Function_Node and then each time we use it we store in the original function node a copy of itself with all of the types T substituted w... |
I have a system where the load is distributed across the nodes in the cluster and once an entity is assigned to particular node, it is taken to completion through that node only(distribution is saved in a table). If the owning node fails, the manager node can reassign it.
It is desired that once any node joins the clu... |
I'm creating a project which uses SystemJS/JSPM.
I'm also using TypeScript.
Now TypeScript has the option of compiling JS using SystemJS Modules - which I'm doing and all is good. I've created TS modules and then imported modules from JSPM - at which point TS uses SystemJS to import those modules in Javascript.
Where ... |
According to this
As opposed to the constraints in other kinds of engineering, where
the constraints of what you can build are the constraints of physical
systems, the constraints imposed in building large software systems
are the limitations of our own minds.
This sounds interesting on paper, but it also got ... |
I am looking for practical and non-synthetic use cases of Python class decorators. So far, the only case which made sense to me is registering a class in a publisher-subscriber system, e.g. plugins or events, something like:
@register
class MyPlugin(Plugin):
pass
or
@recieves_notifications
class Console:
def p... |
For a test suite I have, each test has a failure rate (from 0 to 1), where 1 means it fails every time and 0 means it never fails, and a duration in ms (this is unbounded). I want a metric (I think either multiplication or division) that will capture the knowledge that tests with a low duration have a high value, and t... |
Recently during a code review I came across code, written by a new colleague, which contains a pattern with a smell. I suspect that my colleague's decisions are based on rules proposed by the famous Clean Code book (and perhaps by other similar books as well).
It is my understanding that the class constructor is entire... |
I'm debating the merits (bikeshedding?) of two different approaches to a simple problem.
This setting is numeric, but may not exist, so the options are:
Does not exist
0
1
2
3
The programming language in use is C, so there are two obvious ways of encoding this into a byte. Option 1 is to use values 0, 1, 2, 3 and 0x... |
I have a doubt with threading data service calls within a foreach loop. Here it goes:
Say you need to request data from a service and then process that data, for this example, let's say data request takes 2 seconds and data processing takes another one. If you had to process a list of 10000 elements how would you do it... |
In the following c# code example, the instance field [name] is readonly, and therefore is immutable after class construction.
public sealed class Example
{
public readonly string name;
public Example(string name)
{
this.name = name;
}
public string AllUppercase()
{
return this.... |
In a Lisp dialect, I've implemented ANSI-CL-like support for printing objects such that their circular and shared structure is encoded. This is enabled by the special variable *print-circle*. Similarly to ANSI-CL, I have it working when it traverses objects that have custom print methods. But there are tricky corner ca... |
In laravel 5 I describe models without specifying fields in model class. Some magic identifies which fields exist in database for this model.
use Illuminate\Database\Eloquent\Model;
class MyModel extends Model {}
When I describe migration for model's table, I specify field type, length and so on. This info exists onl... |
I'm a solo hobbyist developer with some code hosted on Bitbucket. I use TortoiseHg client-side for managing my repo.
Back in 2013 I developed a feature on a branch but abandoned it before completion.
The default branch has seen many commits and structural improvements since that time.
Now I'm to a point where that aban... |
I am building a proof of concept for data processing web service, that allows users to get data cleaned, homogenized or otherwise manipulated.
Often users send different types of data in the same batch. After processing, the data must be distributed to different users individually or in pairs, based on the type of dat... |
I have a table Company and User like below...
Company Table:
CompanyID CompanyName etc...
User Table:
UserID Email UserType CompanyID etc...
First I must tell you that, currently I have two usertypes, Admins (who can do anything) and Users (with some basic privileges)
Now, I have a requirement to in... |
At the time I'm workin on a project with several Instances of an abstract class. Some functions in the subclasses are the same, some not. This would lead to code like the following. In the Code i use object as parameter, but in the real project it's a defined class and not object.
public abstract class BaseClass
{
... |
As far as I understand the concept, CC is determined by how many nested branched logic the given method have. It can be refactored to checking the opposite of original predicate and calling return. For example:
void Foo()
{
if (predicate0)
{
if (predicate1)
{
// some code
}
}
}
can be refactore... |
I'm interested in whether there is such a thing as a pseudo-compiler that can create a kind of binary or bytecode version of a plaintext script file, which can only be accessed by a proprietary piece of software?
I work with a proprietary software client in a Windows environment, and the software has its own script man... |
I'm doing use case where users can make reservation of different services such as hotel, car rental etc.
If I just want a simple use case, ignore the part that user has to log in and make payment etc. Technically is the answer below acceptable? If not, why?
A)
ACTOR USE CASE
Customer Make Reservation... |
First, I need to confess this question come mostly from the still expensive licensing model used by Microsoft for SQL Server Standard. Also because Web edition is now only available through Web Hosting provider. For information: it's 1 license per 2 CPU Core + CAL per user.
From a Microsoft sales contact I spoke with ... |
I've started down an Autofac rabbit hole that I think I need to pull myself out of. I have a .NET MVC site where a user can list their favorite players per sport (baseball, basketball, etc.) I have a Players controller, and I'm injecting IPlayerService. However, my problem is that the service needs to know which spo... |
I get why static local variables are called "static" -- we want them to be allocated in static memory! But what is the reason for calling functions and variables we want restricted to the current file "static"? I don't see the connection; either way, they're allocated in static memory, right?
|
I'm learning T-SQL.
Why the strings are prefixed with N in every example I've seen?
What are the pros or cons of using this prefix?
Please make it clear that if my column has datatype as nvarchar /vachar then is it mandatory to provide values using 'N' as prefix or it just a system that we are following.
|
Say we have N persons and M items (when a person has a certain item, she usually only has one piece). For example,
person 1 has item A, C, D, and wants item F
person 2 has item B, C, and wants E
person 3 has item E, and wants G
...
You get the idea. So it's basically a supply/demand matching problem, and if we rep... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.