instruction stringlengths 34 36.1k |
|---|
I need few related variables (for example I have the lengths of 3 lines given. I have to say whether they form a triangle).
Which variable naming convention is preferable in Java?
len0, len1, len2 or
lenZero, lenOne, lenTwo or
lens is declared as an array. Then lens[0], lens[1], lens[2].
Maybe if there are many vari... |
I need to design a program in Java which calculates arithmetic expressions (only addition or subtraction).
Requirements:
1) abstract class Expression which contains abstract method calculate() and method equals() which overrides Object.
2) concrete class AtomicExpression which inherits from Expression and must have ... |
I'm wondering the best approach to designing a database for storing crossword json data. As the website is at the moment, the frontend view just needs to be passed the whole object to render the crossword:
{
grid: [15][15], // 2D array of letters
clues: {
across: {
clue_id: "here's an acros... |
I have several Django services which all have their own login portal, and colleagues have a user/pass for each portal (if we've given them permission). We'd like to unite all of these portals and there are a couple different options:
1) Just create a new service that is one giant consolidated tool, and get rid of the o... |
Would appreciate any recommendations regarding design a high-load image processing service.
There are lots (tens of hundreds of relatively large images (~10...20 Mb each)) that to be processed using command line utils when requested.
Generally: request->image processing->result. Obviously, the system must be able to sc... |
Imagine there is an endpoint GET /v1/status which returns one of predefined statuses that are documented. For example one of [disabled, enabled]. The endpoint can be used by other third party services.
The problem that I see with just adding a blocked status as is, is that
third party clients will not be able to proces... |
So our team has products that currently runs on Visual Studio 2013. Now we want to move to Visual Studio 2017. So I've been assigned the task to make the transition to Visual Studio 2017 as painless as possible.
Here is the list of challenges that this task presents
We use git as our versioning system and we have all ... |
I am trying to make a simple expression parser, in which users type an expression in infix notation (for example ln((1+2)(3-4))) to apply some calculations. To make this possible I need to tokenize the expression as a expression tree. I've read in blogs and forum that I need first to convert the expression to postfix (... |
I have to refactor a "for" loop which iterates over an array and does two independent things with the array element. For example:
doThisOrOtherStuff(array) {
for(int i=0; i<array.length; i++) {
element = array[i];
id = element.getId();
if(id < 0) {
doThisStuff(element);
} else {
doOtherStuff(element);
... |
I am looking for optimal for maintenance/easy of programming and elegant patterns to parse delimited network streams, e.g. protocols like SMTP. Some of the concerns I've always had are:
how to react when a recv(2) call returns 0 - the need to track state to determine if no data has arrived or no more data will arrive
... |
I have been working on a project with multiple microservices whose communication happens through API calls. Lets say microservice A calls a service provided by microservice B. According to the current implementation, we don't have multiple APIs for the different services provided by Microservice B; instead what we have... |
My manager has asked me to "just wrap the stored procedure".
The requirements are to create a microservice that will do the following:
Accept parameters from the user.
Pass those parameters to the stored procedure.
Return to the client the resultset of the stored procedure.
In the beginning of my career this was d... |
I'm just working on a set of MATLAB files right now that I'm using for my thesis. I want to be better organized and figure out the best way to keep track of changes. I have read that GIT is a good tool, although I'm not sure whether this is still good for a solo worker (I don't collaborate on any code).
My current met... |
I am currently studying on multiple inheriting operation.What ihave learnt is we can't inherit multiple class but we can inherit a class and an interface so i just need to switch a class to an interface. Like below
class a{}
class b{}
interface d{}
//class c:a,b{} That does not work
//class c:a,d{} or class c:b,d{} but... |
I am designing communication system that will be sending targeted based SMS (ads/offers) to its customer. The basic system with low load scenario works well, and the SMS sent are based on an event like a person visiting a place, he should get all the promotions done by that store or stores near him based on his interes... |
I recently stumbled upon some code which looked wrong.
I edited it only to see that my changes broke the code.
I tried to structure the code in different other ways to make the code both look and be right, but I wasn't satisfied with any alternative I could come up with.
The logic of the code is as follows:
A Path i... |
I have the following methods:
SingleUserMode() - turns the single user mode on in the database
BeginEdit() - starts the edit of items in the context, locks them in the database
SaveChanges() - saves the changes to the database
ReleaseSingleUserMode() - turns the single user mode off in the database
Each method return... |
I want ask experienced software developers and architects about this domain class which I found one day in some code.
public class User : Entity
{
public virtual string Firstname { get; set; }
public virtual string Lastname { get; set; }
public User(string firstName, string lastName, IUserRepository userRep... |
We are redesigning one of our API projects from an n-layered architecture into onion architecture. In the previous design, we had configuration classes in a common library project being referenced across all the layers (UI, Logic and Data Access layers). How should these configuration classes be fit into an onion archi... |
What is a good term to use for when I want to describe changes to the codebase that does not involve changing or adding functionality. This would include bug fixes, security patching -- including library upgrades, and perhaps refactoring as well.
The term would replace the incorrect sounding "non-functional changes" in... |
I am working on figuring out the architecture for putting together a complex modular system that has Orders, Customers, Projects and Quotes.
The customer can have multiple projects. For each project there will be at least one order or quote associated but there is the possibility of having multiple quotes and orders on... |
This question is generally regarding when it is a good idea to store quantities derived from member data in, say, std::vectors that will be repeatedly computed/accessed in various methods, but I will attempt to illustrate it within a specific context.
Suppose that I have two classes as minimally defined below. The Conf... |
I am in the process of migrating the way an app makes persistence of its settings.
It wrote and read data from registry;
now it is desired it load/save XML files on the C:\AppData\MyApp\Version folder
for several reasons.
It had lots of folders on the registry.
1st question: Whats is the best approach: A mega file hav... |
If I have a complex unit tested function:
def do_everything():
# turn twizzles
# push buttons
# move mountain
And I re-factor it into some smaller units:
def do_everything():
turn_twizzles()
push_buttons()
move_mountain()
def turn_twizzles():
# turn twizzles
def push_buttons():
# push... |
The Foreword
Hi! I'm just your average, fairly beginner, computer science student doing personal programming side projects, and who is probably out of his depth and has no clue what he's doing. So, I might need some extra help/explanation to understand things.
The Context
Games and Branching Narratives
It's very frustr... |
I have ASP.NET MVC application with the following controller and action:
public class AccountsController
{
public ActionResult Index()
{
var accounts = _accountsManager.GetAccounts();
return View(accounts);
}
}
and AccountsManager class like this:
public class AccountsManager
{
privat... |
I understand the difference between ordered and unordered sets, and I understand why for many purposes, we don't need ordered sets. But all set operations are still possible on ordered sets, and sets have to be stored internally with some order anyway, so why aren't sets ordered by default? Is the performance impact of... |
I got into a conversation with a coworker and we talked about reflection in PHP language. I insisted that instantiating instances of class using variable variables syntax like following is a reflective technique.
<?php
$className = 'Animal';
$animal = new $className;
My coworker differed in opinion. I did extensive ... |
I'm starting to wrap my head around PHPunit.
My questions is the following.
Whenever I use variables that do not change within my range of test methods I can initialize them within my setUp() method. Otherwise, if they do change, I should rather put them directly in my test methods.
Is my assumption more or less righ... |
Considering a solution that has some manual DI going on such as the below class, is there a better way of managing the concrete implementations without adding a container. This is theoretical, there is no real test case but something I was thinking of earlier.
The below DI example is fine, however it's preferred that c... |
My new team where I work are currently discussing how we go about changing our current old monolithic applications to go down the route of microservices. We are still at the early discussion and proof of concept phase.
The first proof of concept we are trying out, at a high level, is to mimik a customer adding somethin... |
I understand classic branching and deployment model as saying (in some small variant of the below):
makes the changes on dev branch
merge dev > staging branch, deploy to staging server, test it out
merge dev > production branch, deploy production server.
dont make commits directly on staging or production branches. On... |
This is the scenario in which I have to apply some creational pattern.
Build a fleet of 10 cars with the following features. Five cars should have all the features and five should be built without the lidar and ultrasonic sensors:
Radar sensors dotted around the car monitor the position of vehicles nearby.
Video came... |
What is the correct term(s) for different types that contain exactly the same information? For example (F#):
type Type1 = (int * string)
type Type2 = (string * int)
When describing that these types can contain exactly the same information, I could say that Type1 and Type2 are ______. Which word(s) could I use?
And is ... |
So i have a modified knight's tour problem. The problem is the following , is there an algorithm that can give you the route(if possible the shortest) from (1,1) to (n,m) in a chessboard of the knight piece? And also if some blocks are blocked
Eg. i have 3x5 chessboard and the blocks (2,3) and (2,5) are blocked. Is the... |
If I want to calculate the movements of each moving objects driven by regular algorithm, then how can I measure required computing power? Is required computing power proportional to the quantity of the objects?
|
I have interesting situation here, which I'd like to draw your opinions upon. I'm designing a REST API and here are the Resources pertaining to this question.
I have an User Entity, which I create through POST /users/ and Read-Update-Delete(RUD) by /users/:user-id
I have an Event Entity which I create through POST /ev... |
I'm just a junior developer but in about half a dozen projects I worked on there's always this situation:
Service methods that take big objects as parameters, but often use just a little portion of them. Let me try to clarify with a little bit of code:
class WorkforceService {
public void assignEmployeeToWorkplace(... |
How are variables abstractions for the memory cells of the machine? Is it because you can change the value stored in the memory cell by assigning a different value to the variable associated with the said memory cell?
|
I have a Django project. All the apps are separated nicely. Each apps often have functions that are used across the apps. Currently I place them in module named wrappers (for wrapping django/built-in/3rd party functions) and shortcuts (for wrapping django/built-in/3rd party functions with hardcoded arguments).
For pure... |
We are receiving realtime data from over a 1000 sensors, each of which sends a data point every 10 seconds in average, which is amounting to about 1 million rows of data every day. Our system gives users the ability to select any sensor and a date range and download the data points as an Excel file.
We have seen that o... |
How should necessary data that is stored in the database be referenced throughout code? Is it better to reference a numeric, auto-incrementing ID, or a unique alphanumeric key/name, etc.? For example:
Determining page display based upon a specific setting/value from, say, a Settings database table
Retrieving a maximum... |
I'm currently getting into BDD/Cucumber and I ask myself: On which levels is it good to use?
There are the test levels (from the testing pyramid):
User Interface
Integration
Unit
You can apply tests on various levels and fields in the application architecture:
Presentation layer
Rules (how are business rules refle... |
This often happens in my projects. Sometime I have this part of code that is very similar to this other part, yet a few lines makes it complicated to keep the code clean and without duplication. Here is an example of a recent project.
I am working on a program which can do 2 things : A will generate an image projected ... |
The specific example in mind is a list of filenames and their sizes. I can't decide whether each item in the list should be of the form {"filename": "blabla", "size": 123}, or just ("blabla", 123). A dictionary seems more logical to me because to access the size, for example, file["size"] is more explanatory than file[... |
I had an unusual, brief conversation with a very senior architect about dynamic and static languages. He said that company data shows that there is evidence for higher productivity when static languages are used. Note, it's a large company with long history. To my (and others) surprise, the metric he used was lines of ... |
I'd like to make my logs more useful. Currently they mostly contain such common columns as: timestamp, logger-name, log-level, message, exception.
They are unsearchable and unparsable and writing messages and adding some data to them is not actually helping. Consequently when something goes wrong I'm not able to easily... |
I have been reading about consumer-driven contract testing with frameworks such as Pact. The concepts are clear when talking about testing between two services that communication via HTTP.
We have Service A (our consumer):
Write a test that states when we POST {'foo': 'bar'} to Service B, Service B responds with a 2... |
I use Memcache to store content lists with very key combinations, when user edited the content, I must refresh the cache, but it is hard to say what particular list to refresh, it is not either a good idea to flush the entire Memcache server, so my question is: Can I group the Memcache keys so that I can flush a group ... |
I have a web application (laravel) with a page which presents a large number of rows (financial transactions) in a HTML table. On each row I want to have a drop-down (select input) allowing the user to assign a category to the transaction.
What is the best approach for allowing the user to select/assign these categorie... |
I have an odd, intermittent bug that is happening on a web server.
One of the methods triggers the creation of a small file (3kb), in a folder. The folder is based on the current year, month and location id.
The file is created by a 3rd party component that I have no control over, other than by calling its CreateImage(... |
Say I have a database structure like this:
CREATE table Customer (id identity, name varchar(30), dateofbirth datetime, Photo varbinary, primary key (id))
CREATE table Order (id int, Date datetime, Primary Key (id))
create table CustomerOrder (CustomerID, OrderID)
Say I wanted to copy the database into DynamoDB for C... |
Every description I have read about god classes considers them to be an anti-pattern and a bad practice. Most descriptions I have read about mixins considers them to be acceptable in some cases. If the functionality of a god class is broken up into several mixins, each mixin can be separately unit tested and separation... |
I'm watching a talk on Vert.x (not in English) and they say that "the whole architecture needs to be asynchronous from beginning to end", and cites as an example of what not to do putting an Apache httpd server in front of the Vert.x application, then explains that using Nginx would be a better idea.
I understand that ... |
I asked this question recently: Using Aggregation and Association
I accepted the answer, however I am confused by the answers response. The answerer talks about deleting database records. However, I am talking about the domain model, not the database.
Say I have a many to many relationship in the database like this:
... |
I am designing some software that will be delivered to a customer with some limited areas that they can customize using the same platform and compiler (Windows 10, Visual Studio 2017). My goal is to allow them to inherit from a class and generate data from their own proprietary source and pass it to the main system.
I... |
Background:
I was working on a personal project to create an Task Checklist Web App. I worked on the code with vanilla golang and javascript. It is a very simple app with limited capability. I've used a json-rpc like endpoints for the application.
Code and Implementations:
Endpoints:
/getTsk GET
/addTsk POST
/delTsk ... |
Say I have a many to many relationship in the database like this:
CREATE TABLE Person (ID int, name varchar(100), dateofbirth datetime, Gender char(1), primary key (ID))
CREATE TABLE Sport (ID int, description varchar(30), primary key (ID))
CREATE TABLE PersonCanPlaySport (Person ID int references Person(ID), SportID i... |
We have multiple layered architecture
UI --> Application Layer --> Business Layer --> DB
There is a third party services that we are communicating with. If Business layer communicates to Third party service, then it has the advantage of making our Application layer light weight and at the same time there is data passi... |
Even though I could write something like this (In C#. There are, of course, equivalents in other languages):
public int SomeNumber { private get; set; }
I have never encountered something like this. Is there any particular reason?
Edit:
The question has been suggested as duplicated of Private setters and getters. The... |
I've inherited an application that has a suite of tests that drive me batty. But one of the design decisions that this test suite takes that completely leaves me scratching my head is the separation of tests and their expectations into separate files.
To explain, there are functional tests that have test methods with d... |
I’m working on a system where several resources are scheduled (users, rooms, and equipment). Each appointment is scheduled for a user, and may also take a room and/or equipment. Appointments are scheduled over time, slowly filling up the calendar. It’s thus not a classic scheduling problem where everything can be sched... |
I work on two code bases that are related, but independent. One is written in PHP, the other is Node JS. Currently, they are in a single repository. The repo is deployed to Heroku for the Node code, and a different hosting provider for the PHP code. I didn't set up the repo, but I now maintain the applications.
Is ther... |
I have a new-employee form.
When the "Save" button is pressed, a SavingRequested event is raised. The Presenter gets an Employee object from the View and passes it to the Model for further processing.
Should the Employee object created by the View be passed to the Presenter via the event arguments:
public event EventHa... |
Scenario.
ViewModel has a property State.
View has a ComboBox that allows to change value of State.
ViewModel needs to run some validation (call bool ValidateState(State value) method) before setting value of State property.
Question.
How would you implement it?
My concerns.
I want my solution to be generic so I cou... |
I have written a class to represent 'Treeview-like' data, which can be simplified as:
public class Item
{
public string Name { get; set; }
public KPI AssociatedKPI { get; set; }
public List<Item> Children { get; set; }
}
To each 'branch' of the Tree, can be associated a KPI, which can be simplified as:
pub... |
I am using C# on a pretty huge solution that user a Static Class to manage the Session on the database.
The performance are not so good because of the number of call to the database.
The company decide to introduce Redis as a very fast alternative. Of course it is so fast! But now I have to design a service that will r... |
Let's say I have a form for representing a user.
When pressing the "Save" button, should a User object be:
constructed by the View based on the input, then passed to the Model via the Presenter and then inserted into the database by the Model,
constructed by the Model by using the View data (via the Presenter) and the... |
I am building a webapp (Angular frontend, Groovy/Spring/Hibernate/MySQL backend) that will allow users to compete against each other over certain activities. Each activity will have 1 winner and 1 loser. I want a live user ranking system that ranks users (1st to last place) depending on their win/loss record/history. T... |
I'm currently working on a project in which we're required to define a Entity Relationship Diagram and a UML Class Diagram from a set system.
I've successfully managed to define the ERD. It required me to break down information from a specification and form them into entities and then define a relationship between the ... |
I'm developing an Android application where they want to have track multiple patient's vitals (current HR, SPO2, Respiration, etc.) in real-time with each patient having a large form that represents their documentation. They want this to be sent over a peer-to-peer UDP network, so that other people can edit the same do... |
The GNU Assembler as uses different characters depending on the architecture to specify single-line comments, such as # on x86, ; on 29k, or @ on ARM. Moreover, regardless of platform, C-style comments are also supported (/* */).
Is there a technical reason for different comment styles on different architecture? The ... |
I would like to write an application something like ecommerce.
And you know that in similar applications products could have different properties and features. To simulate such an opportunity I've created the following domain model entities:
Category - this is something like "electronics > сomputers" i.e types of produ... |
I need to make a time profiling for several modules in Fortran, which means, that I'm supposed to write the same code in every beginning and every end of every function.
Really, it looks like this:
#ifdef TIME_PROFILING
real :: t1, t2 !< Variables used for time storage
call cpu_time(t1)
#endif
... |
Gnuplot seems to be one of the rare applications with the level of perfection in rendering graphics (will be glad to know if any competitor exists to this level).
My question is related to the license restrictions of this dependency if I want to use it in my computational applications.
I am not well-versed with license... |
I was tasked to automate reports used by multiple teams. Each team have their own procedure on how to generate the report that they need to deliver.
I can automate the reports but it takes so much time since I need to study each of their procedures and then test them.
The issue occurs when a team needs to update a pro... |
I have a microservice(Microservice A) which connects to a Client MQ and recieves messages and persists into the database.(Synchronous type MessageA after Message B for the same order).
Internally i have n microservices each handling a particular type of message based on some message parameters.
All the microservices ar... |
Problem Statement
I'm writing a C# console program that takes binary data coming in through Serial COM1, converting each byte into ASCII hex, and then outputting those HEX characters out through Serial COM2.
I would like this program to run in the command shell continuously but also exit gracefully (so that system reso... |
I am a bit confused by the MSDN C# documentation which states that & and | are logical operators and that && and || are conditional operators.
I keep calling &&, || and ! logical operators, so I am wrong?
|
I'm building a ASP.NET MVC Core App. I would like to add 2 new features:
A new area for Admins and
An Web-API for restful services.
I was wondering if the Web-API and the Admin area should be new "ASP.NET MVC Areas" in the same project or should I create a new project for the API and the Admin.
What criteria shoul... |
I have an interesting problem that I'd like to solve. Let's say I have 2 deployments, US Data Center and Europe Data Center each containing Web Servers and a Redis Instance (replicated, but could eventually grow into its own cluster using TWEMPROXY).
We have a Load balancer that identifies the closest available Data Ce... |
I constantly struggling to solve data duplication problems
efficiently (storing data from any source to RDBMSes). My main concern is speeding up inserts/batch processing.
Scenario: I read data from different sources, mainly in json
format and I need to process them in way (input: nosql documents),
where I only store di... |
I wrote some code in the past for 8bit MCUs, realizing that every time I gained experience, the next iteration will be with a wrapper API or something more distant from the "bare metal" register access. I also end up a bit in working environments, learning the company philosophy behind a certain code style.
But I saw w... |
In this series of blog posts, Eric Lippert describes a problem in object-oriented design using wizards and warriors as examples, where:
abstract class Weapon { }
sealed class Staff : Weapon { }
sealed class Sword : Weapon { }
abstract class Player
{
public Weapon Weapon { get; set; }
}
sealed class Wizard : Player... |
According to Jez Humble, Continuous Delivery involves "ensuring our code is always in a deployable state" [1], and according to Humble's Thoughtworks colleage Martin Fowler "the key test is that a business sponsor could request that the current development version of the software can be deployed into production at a mo... |
I am trying to search for a framework or library or even techniques for handling N-Tier Client/Server communications.
I am scaling my application software and I am seeing this communication becoming more and more cumbersome. I have an application server, but I also have middle servers for scaling the capacity of connec... |
I am building a simple master-details GUI using WPF/MVVM/Prism for some data coming from a Restful service.
I have the main window as my main view with a corresponding view model.
I have a user control to show the master data and it's got its own view model as well.
I have added an instance of the master data view mode... |
We have a background job(java batch) which listens/reads from an MQ and persists a message onto the database(local table).
Then a trigger sends this message into a queuing table in WAITING status.
My polling program (multithreaded in java) continuous polls for WAITING records, picks them up and sends them to the prope... |
Background information
I am building a program that plays checkers as good as possible. It already plays pretty well but the goal is to improve it even more.
This can be done by adding new methods to evaluate how "good" a certain board-state is. I've already implemented these methods but each of the methods has a param... |
In the last few months I spent a lot of time arguing about the role of technical considerations when developing user stories. In my point of view, a lot of stories are not really debatable without understanding and respecting the technical boundaries the solutions is developed in. Other people point out, that we should... |
I'm developing a REST Api using Node.js & Express.js. Recently I've started looking towards best practices for REST Api design but it's bit confusing so please bear with me.
For Example:
Lets say I have the following API Collections:
Users
Tasks (every task must belong to a User)
And Have these resources:
GET /api/u... |
Given this abstract class:
public abstract class File
{
public abstract string Name { get; set; }
public abstract void Add(File newFile);
}
The basis of a composite can be generated:
public class LogFile : File
{
private string _name;
public override string Name
{
g... |
Let's say we have a web application where the users can login and have a status (available, not available).
There is server application that has to know the users status. This can be synchronised by sending a message from the webapp when the user status changes.
The question is how to get efficiently all the users (a ... |
I'm facing some issues related to code duplication when following MVP architectural pattern in an Android project that I'm working with.
My project structure is separated by packages: data, domain, infra, ui.
Inside ui package there are another packages for each screen of the app. Most of them contains this structure:
... |
REST APIs can be exposed using an API Gateway and is considered to be a good practice. (at least when they are exposed to internet)
However there are a lot of microservices inside an enterprise which are not exposed outside and they are used to communicate with each other.
Wonder what are your experiences in terms of m... |
A user uploads a CSV to the server to be inserted into the database and I would like to return a meaningful response to this user.
My thoughts :
{
inserted : x records
discarded : y records
}
I believe also that I should specify what records were discarded because of the inconsistent format / missing values. Pro... |
I am trying to find an efficient technique to differentiate between seen and unseen content per user. I have a table of specific files, but need to keep track of the user who accessed them and then display a notification if new files or content has been added.
I have considered creating a table that just keeps a membe... |
What is a good diagrammatic way to represent asynchronous event communication between two systems (the pub sub model)? I am not looking for tools but more of a representation. Is it a sequence diagram, a swim lane diagram or some other?
|
Consider a distributed system S that consists of several processing nodes (N1, N2, N3, ...) and spans the geographical boundaries.
S -> {N1, N2, N3, N4 ...} N is more than 1000.
now consider that each node maintains its own cache for storage. Whatever enters system is processed and output is returned while any infor... |
Recently, I asked about my difficulties in finding the boundaries of aggregates
here
and I recently reinterpreted it and rid it of business features and now it sounds like this:
In many sources, examples are given of the allocation of aggregates. Most often in these examples of one aggregate one or more important behav... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.