instruction stringlengths 34 36.1k |
|---|
I understand the concept of RAII:
Use the destructor as a means to free resources, such as memory, or closing file handles/database connections. Coming from a Java background this was actually rather easy to understand because of the similarities to finally.
However, I do not quite understand when you actually should ... |
I work for a franchise and am beginning the complete redesign of the application that each franchise uses to manage its daily operations. It functions as a point of sale and scheduling application. Currently, each franchise has its own local SQL Express database. The desktop application runs in their facility and reads... |
I tried to be as clear as possibile in the title, but I'll be more specific to my situation.
Problem 1:
I have a Player with some slots which can hold items. Each slot is a Slot<Equippable> where Equippable is an interface just to group different items together: Armor, Weapon, etc. Now I come to face a problem: the P... |
COCOMO II expresses programmer capability as a different factor than technology experience. How does it measure programmer capability while abstracting his language and tools experience?
|
It is easy to eliminate tail recursion.
There are few curious cases where the not-tail recursion can also be eliminated.
Exhibit 1: Fibonacci numbers.
A naive recursive solution
fib(n)
if (n < 2)
return n
return fib(n-1) + fib(n-2)
leads to exponential complexity. An iterative solution
fib(n)
f_0 =... |
My experience has been using the hybrid approach per use case demand:
Where content on same page needs to be updated, we used AJAX/SPA approach
But when the page has a completely different layout/look and feel then we would always submit the page and a new HTML response was loaded from server
My question is on poin... |
Let's say we have 5 functional software requirements (R1-R5). Our software design results in 6 modules (M1-M6) or classes to be implemented. I am assuming that the design is more or less optimal, each module having a well-defined purpose and the dependencies between the modules have been minimized.
In one case the rela... |
I'm trying to reconcile my object-oriented/functional mind with programming in a language with C. Let's say I want to achieve dynamic dispatch in C, say I want to have a collection of tasks to execute. I could make a pointer to a collection of functions I want to execute, simple enough. However, let's say that the task... |
My Java application uses Hibernate as an ORM framework. I find myself often writing code like this:
Session session = HibernateUtil.getSessionFactory().openSession();
try {
session.beginTransaction();
// do some work, which might or might not yield a result which will be returned
doWork(session);
// it... |
Basically, I've been tasked to work on a Xamarin.iOS app (predominantly for tablets only) that would display a long scrollable form that contains ~200 controls (buttons, switches, text fields, etc...).
Normally, I would create an instance of the control, assign values to it's properties and then add the control to the ... |
The functional interfaces in java.util.function cover the vast majority of common strategies one might want to apply, but it's also possible to define your own @FunctionalInterface instead. In cases where your desired interface coincides with an existing interface in java.util.function should you prefer defining a cust... |
I have an application which takes an integer as input and based on the input calls static methods of different classes. Every time a new number is added, we need to add another case and call a different static method of a different class. There are now 50 cases in the switch and every time I need to add another case, I... |
I hope this question isn't considered to "open-ended"...
The company that I work for is concerned about their image and they would like to have more control about the publications into their official social medias. Two major drivers to achieve: gain control over the passwords and inspect texts that are being posted.
My... |
I have the problem statement to make an Object Model for.
Problem Statement: Every vehicle has an engine and a gearbox. A gearbox is composed of pulleys working according to predefined gear ratios. Cars have smaller engines with 4-6 gears while Sports Utility Vehicles (SUVs) have bigger engines with 4-8 gears. Heavy Du... |
I have a some domain modeling case: There is two domain concepts Worksite and Contract. Every Contract belongs to some Worksite. I've already found out that both concepts are own aggregates but there is still business rule that the validity period of Contract must always be inside the duration period of Worksite. So ho... |
Let's say I have a Person class:
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string IdCard { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string Email { get; set; }
public string Credit { get; se... |
I noticed something strange when I tried to use public method of A class in generic class B of A but it seems I can't. Is it relate to restrictions on generics. I mean Cannot Create Instances of Type Parameters rule.
public class A{
public void a(){System.out.println("Hello!");}
}
public class B<A>{
public voi... |
I am a new to in programming, especially to C++.
At first I learned how I make functions (it was amazing).
But now that I've learned about classes (and objects) I am so confused... when I should use them? What makes them more efficient than functions?
Most example problems I try to solve using functions, not classes.
... |
I'm trying to apply some good practices from Clean Code in my code, but I'm stuck trying to figure out if my code has a [G34] code smell, which tells that functions should descend only one level of abstraction.
var tryToMakeAMove = function(line, column) {
if( board[line][column] === EMPTY) {
makeMoveInPosition(l... |
So I am new to design patterns and C++11, but I have been studying both quite a bit. I am working on developing a C++ application to process some data, and I was hoping that someone with more experience could tell me if I am on the right track.
So the application will take in a large 2-D array of data. Then there is s... |
Current project that i'm working has a requirement to capture data relevant to a session and store. Purpose of this is to use these data for the analytics. Clients would use these data to generate graphs, chart and etc.
For each client, 10 data points are captured within a minute(10 rows within a minute). As per the pr... |
I am familiar with the Traveling Salesman Problem, and many of the various approaches to solving it.
But is there a name for the following problem:
Given an existing (solved) tour and a new city, insert the new city
into the tour (at the start, between any two existing cities, or at
the end), such that the total i... |
I have a method that I want to write unit tests for. I'm going to keep it fairly generic as I don't want to discuss the implementation of the method, just the testing of it. The method is:
public void HandleItem(item a)
{
CreateNewItem();
UpdateStatusOnPreviousItem();
SetNextRunDate();
}
So thi... |
In Clean Code:
public class Point {
public double x;
public double y;
}
The author wrote about the above Point() class:
This exposes implementation. Indeed, it would expose implementation
even if the variables were private and we were using single variable
getters and setters.
This means I must burn my sch... |
I'm writing a library which will be a base for a turn-based battle system but i don't know what are the best practices for exception handling, has anybody some advice for me?
Should I catch every generic exceptions/ exceptions thrown by standard components (like lists,dictionaries,etc...) and then throw a contextualize... |
Sometimes in interviews, I may use recursion to solve a problem (such as adding 1 to an infinite precision integer), or when the problem presents itself suitable to use recursion. Sometimes, it might just be due to using recursion a lot for problem-solving, so without thinking much, recursion is used to solve the probl... |
I am developing Angular 2 payroll application intended for serveral user groups/roles - e.g. for accountants, for employee self-service, for managers. Each user group should have completely different page layout and menus. So - there should be separate *.html pages and - I guess - separate @NgModules for each *.html pa... |
I am experimenting with complex FSM frameworks. For one of the approaches I am considering I would like to have two types of function: plain function and special function. The exact meaning does not matter. I want to have compile-time enforcement that there is no more than one special function per block. I can play wit... |
I've a base class named API which is used by three objects(Server, VPS, SharedHosting).
Code:
class API:
def get(endpoint, params):
def post(endpoint, params):
def parse_response(response):
Server class:
class Server:
def __init__(self, name, ip):
self.name = name
self.ip = ip
@clas... |
Our software has several classes that should be dynamically found via reflection. The classes all have a constructor with a specific signature via which the reflection code instantiates objects.
However, when someone checks whether the method is referenced (for example via Visual studio Code Lens), the reference via r... |
Let's say there are classes D1, D2, etc. describing different types of an abstract class D.
Let's say there are SenderReceiver classes describing different ways of communicating for each D1, D2, etc.:
abstract class SenderReceiver {
abstract void Setup();
abstract void SendA();
public void M1() { /* Common ... |
Does / why does Java need to have void methods? Reference:
Any method declared void doesn't return a value.
As far as I can think, every use of void would be better served by returning a status flag, the object being invoked, or null.
This would make every call a statement that is assignable, and would facilitate bui... |
I am working on a project in C++, and I have a big CPP file with several functions in it. I am actually working on splitting all these functions into smaller cpp files to make it more readable. I was wondering if this process had actually a name? I was thinking about calling it "Refactoring", but this process seems mor... |
I have an app that collects data points throughout the day.
Each data point is stored in a DataPoint object (that is persisted in the DATA_POINTS) table.
I also have a DataPointRepository with basic CRUD operations, but also methods to get average, min & max datapoints.
At the end of each day I want to compress the dat... |
I'm working on windows forms application. Recently, I get new requirements that I don't know how to approach.
Users of the application will have one of two roles: Admin or User.
Admin can set a list of instructions to do when encountering different situations.
Normal users (User role), will get a pop-up window with th... |
For decades it's been the case that interfaces were only only (only) for specifying method signatures. We were told that this was the "right way to do things™".
Then Java 8 came out and said:
Well, er, uh, now you can define default methods. Gotta run, bye.
I'm curious as to how this is being digested by both experi... |
I'm making an application that collects timestamp and GPS data from a user's phone in intervals along with some other information.
Currently, every tuple generated is sent via TCP to my application server as soon as the tuple is generated.
Is this an unconventional way of transmitting data considering it could transmit... |
I'd like to measure, how well unit-testable is my code. I don't have a concrete idea, how it should look like, but my logic is:
There are a lot of formally checkable and quantifiable criteria for well testable code:
usage of global/static functions/variables,
cyclomatic complexity,
DI vs. wild direct instantiating of ... |
Background:
I run a two-sided platform with small businesses on one side, and users on another. As a part of our product I plan to introduce "websites" as part of the product.
Idea is: a local business has a domain, and then I want to "turn that into a website" based on one of our templates.
My setup:
Today we have a .... |
Selection Sort(A[1,2..n]:array of integers)
1.for i=1 to n-1
2.for j=i+1 to n
3.if A[j]<A[i]
4 swap(A[i],A[j])
I am trying to prove the correctness of this algorithm,I read from my book and here is what is written:We must have 2 invariants for the inner and outer loop
The inner states:Every time we reach li... |
I'm working on a problem that requires a "sub-linear" solution.
A quick search for sub-linear will return a lot of this...
... where the sub-linear line is modelled as logarithmic/asymptotic.
But I had come to understanding that sub-linear was anything that remained below the linear baseline, as the both tended toward... |
Looking at the two data structures and algorithms to handle them, a hashmap is not really any more complicated than a binary search tree and possibly less complicated. And the hashmap has the advantage of constant time access of a key. So why did we get a std::map very early on in the history of the standard library ... |
The design of SLF4J really excited me. I mean the way it introduces the implementing component. In the LoggerFactory, it imports org.slf4j.impl.StaticLoggerBinder, a class in its namespace but that doesn't exist in its jar file. The implementation (like logback) jar just includes the class and it's done. The classloade... |
For some time I used PUT or PATCH in order to update a REST API resource. After using a lot of PUT/PATCH calls I noticed that "update" could be also done with POST.
Here is an example which is oversimplified that will hopefully explain the situation. There is an endpoint /api/cars/dealers/1 with a resource
{
"id": 1... |
I have large list of strings. Each string is of different length, just like sentence in text. Average length is below 255 chars.
Please, propose file structure on disk to enable fast picking of random sentence. This means I need fast:
* read total count
* read N-th string.
There's no requirements of writing time. It's ... |
I am an amateur developer and all my programs up to now were simple enough to be documented within the code. While reading the code it was clear what I was doing such and such action (my standard test was to look at the code 6 months later and understand everything at first read - and I have short memory span).
I am no... |
I have a pretty simple bash script which consists of a bunch of one liners and some simple logic.
Its been recommended that I rip the bash script apart and rewrite it all in python using subprocess. The argument was that we are building a python project, and that this way is more pythonic.
The only advantage that I se... |
I'm writing a function in the node.js-style asynchronous way, but how do I know if these functions are truly asynchronous, i.e., that they run in parallel and not sequentially?
Here is my code (modified to remove details):
// write the async function
function compileData(data, callback) {
try {
// ... do all the ... |
I'm developing an experimental application for work that requires fully persistent undos and redos. I decided to use react/redux/immutable JS tech stack to solve this problem because I saw it worked out nicely.
I'm actually really happy with the simplicity of the solution but my issue with this decision is that this ar... |
Many moons ago I built a utility library that wraps the JDBC libraries with classes that allowed for functional-style approaches. I've used this library for my own purposes for many years. I've long wanted to make this into a proper open-source project. I started at one point and then got busy with life. With the n... |
How do package managers deal with packages that use a package name but then abandon it or from rogue package names that are similar that host malware in the hope that an unsuspecting developer will install it? For example:
> gem list -r viewport
*** REMOTE GEMS ***
viewport_units_buggyfill (0.1.0)
This package hasn't ... |
only one thing after discuss my doubt i am a mobile developer and i am trying to adapt DDD, and i say adapt because a lot of information is related to backend applications
My doubt start because i have a User class that is part of my model (im using MVP), and also in terms of DDD it´s a domain object, i know business l... |
This is a design question where I am trying to accommodate a business need.
I have two entities - Item and Job.
Original Situation
Item represents a line item on a ledger, and Job is created only for those Item objects that need it (i.e. a Job to track the line item going through the status change process as it went fr... |
I have a set of machines that I'm going to setup to push data to my web server over HTTPS at regular intervals. These units will automatically send requests using a script, so I plan on giving them configuration files with a username and long password for authenticating with my server.
Is there anything I should do in ... |
How do we manage dependency injection in class libraries? Given the following class structure, we would like to inject an instance of Bar into Foo, and we would rather not make this the client's responsibility.
namespace MyLibrary {
export class Foo {
private readonly bar: Internal.Bar;
construct... |
I am writing a ticket system in PHP(with Laravel) for about 350 users and around 200 machines. I know that already are good solid solutions available, but I'm doing some very useful projects to learn, projects that I can implement in my company, with a good number of users to test it.
So, I want to know if it is possib... |
I'm working on a project for a course in college where we plan to build a mobile app for students, professors and administrative so that they can reserve an order in our local restaurant at a given time and then pick it up.
Currently, we have identified 4 roles and these are the restaurant manager, the cashier, the co... |
I've browsed around about Quasar fiber yesterday and it seems that it's more lightweight than Java thread based on the following demo. My questions would be:
Are there any scenarios that thread is more appropriate than fiber?
On what scenarios should I avoid using Fiber?
|
So, reading golang blog on slices there is a snippet by Rob Pike
A weakness of Go is that any generic-type operations must be provided by the run-time.
which I don't quite understand.
Can one rephrase same sentence?
Considering the context before and after this sentence I assume we can not program generic-type method... |
In general, how do websites handle file uploads when they scale horizontally? Obviously if you have a load balancer going to 10 application servers, and each application server just saves an upload to it's file system, certain files will end up returning a 404 depending on which application server the load balancer pa... |
I was wondering how the Thread identification works in .NET. Does it always +1 the last number and never look back? or if thread 5 stops and a new thread is created will it use 5 as it is now free to use?
|
I am creating a REST API for a weigher (to be run on a Raspberry Pi, integrated into the weigher), and I was wondering if my ideas are RESTful and correct.
I have the resource "measurement" that you can use to fetch previously stored measurements, using an ID to get a specific one:
GET http://1.2.3.4/measurement/<id>
... |
I'm working on a PostScript interpreter in C#.
PostScript has memory management. It has virtual memory (VM).
It also has objects.
Two types of objects: simple and composite objects.
Composite objects consist of other objects itself.
VM is the storage in which the values of composite objects reside.
They can either ... |
I am trying to model a data flow diagram in accordance with a requirement document. The document calls for a system with many roles that users can play, where it needs constant information exchange between different roles.
Here is an example of its functions, where 'Role A' is a reviewer or judge of some elements, and ... |
I used to code in Python a lot. Now, for work reasons, I code in Java. The projects I do are rather small, and possibly Python would work better, but there are valid non-engineering reasons to use Java (I can't go into details).
Java syntax is no issue; it is just another language. But apart from the syntax, Java has a... |
for our project, we are using micro services with API gateway pattern. One of the features that the client do is to generate a report. Client, fills a form and uploads a file and our system will generate a report. We want to process the file and the form data, store the data in the database, then send all this data to ... |
I have two types of resources: Query and User.
I am POSTing to /queries to create a new query.
and POSTing to /users to create a new user.
Which path should I post to , to create a new Query collection and a new User collection ?
As per my understanding, we POST to a resource/collection parent , to create that resource... |
I have some code in my project I personally call tests that are not unit tests. They are meant to be run and the result has to be evaluated by a human. I did this because I'm making a physics engine and during development, I needed to see what I'm doing. So I made a simulation package in my test module. It is technica... |
I have situation like this:
if (FLAG && number_of_kittens > FLAG_VALUE) {
}
The general logic of the application is that the FLAG_VALUE does not make sense to be negative.
My suggestion was to use -1 to indicate is as disabled. My main motivation was to avoid confusion... But I have no data or empiral evidence to sup... |
I have a piece of code.
struct HasName {
name: &'static str
}
trait CanGreet {
fn greet(&self);
}
impl CanGreet for HasName {
fn greet(&self) {
println!("Hello {}", self.name);
}
}
struct Person {
has_name: HasName
}
fn main() {
let person = Person {
has_name: HasName {
... |
Currently we have an application that doesn't scale well because of multiple concurrent updates to a table which gets locked. The tech stack is ASP.NET and backend is in SQL Server.
To avoid database access I am considering using NoSQL as a message queue where a producer service allocates tasks based on business logic ... |
I have an application that works with products from various external data sources (in DataSourceProduct) and it also maintains its own version of the product (in MasterProduct). Here's the DB schema:
Note: DataSourceProduct has ten other columns not shown in the diagram. The MasterProduct has ten other columns not sho... |
I read this article where it describes making a flash message in a react app:
https://medium.com/@veelenga/displaying-rails-flash-messages-with-react-5f82982f241c
They mention adding a reference in the window object to the FlashMessages object. In this way you can access the FlashMessages object from anywhere in the ap... |
What's a good robust way to query processes for their help or framework origin, especially in Windows?
I've got an automated testing module that queries binaries that fit a special name pattern with --help to see what test framework, if any, was used to compile that test binary, so it can give it special command treatm... |
I have a replicated database (not SQL, a triple store, but specifics should not matter too much) running on several hosts. Each of them holds a copy of the database which is updated by feeding from certain outside source, and the copies should be identical. However, turns out they are not exactly identical - there is a... |
Today, talking with some colleagues of mine, we were discussing the usage of tuples. The specific problem was: we have an API returning a list of some kind of objects (let's say POJO instances)
public List<Pojo> getPojos()
we decided to use pagination in order to prevent enormous responses
public List<Pojo> getPojos(i... |
Modern Javascript implementations like V8 (Chrome), SpiderMonkey (Firefox), and Chakra (IE/Edge) all have JIT compilation, and a number of other optimizations to improve performance.
Why doesn't Python have these?
I have been looking at PyPy and IronPython, which both claim speed gains. PyPy I don't understand how a P... |
I am writing a software documentation and I need a antonym to "legacy code". Is there any established word for the antonym to "legacy code"? I'll need this antonym to describe that code which was written by myself.
Example: The main focus is to replace legacy code by [antonym] code.
|
I have an application that measures that continuously. (About every second - it depends on the device)
For example sake, let's say that data is CPUTemp (as used as an example in an answer to a related question: Clean Architecure: Creating an entity from a set of other entities)
Each measurement's data is written to the... |
I am using a class (let us call it ClientImpl) which listens to a socket for messages and then updates a listener to let ClientImpl know that a message have arrived to the socket. The listener is not implemented inside ClientImpl, but is passed from the classes using ClientImpl. Let us call my class ClientUser to make ... |
On Azure, Session Management can be done using Redis Cache. But this is not truly stateless.
Is there a way to make a Web App in general, truly stateless?
If yes, what pattern to follow specific to Azure cloud?
|
At the beginning of a project, writing things up as user stories is a great way of getting a handle on the functionality of a project. Stories at this stage tend be conceived and written relatively broadly, to cover a bucket of functionality. A couple of examples from my current project:
As a sales person, I want to b... |
I decided to take the plunge and add the first set of integration and units tests to the projects I work on (yes, we have dozens of internal applications with no automated testing whatsoever...).
I really like the so-called behaviour driven conventions for naming: Given-When-Then, although the resources online are quit... |
I am reading on Coding Complete book the following statement:
To name a procedure, use a strong verb followed by an object A
procedure with functional cohesion usually performs an operation on an
object. The name should reflect what the procedure does, and an
operation on an object implies a verb-plusobject name... |
I'm working on code which will provide a generic C++ interface to relational datasets. Some of the data will be in tables in memory (e.g. std::set or std::vector), but some of it will be computed - either produced by a function computing results of a logic program, or by joining memory tables. Other datasets will be ... |
The problem is a kind of scheduling problem, I would like to identify what kind of problem this is or, at least, what kind of problems it relates to?
Let's say we have n sets of events S1,S2,...,Sn, where an event has the duration of one day.
Each event set has only one repetition per week.
Each event set has an event ... |
There are a couple of examples from a simple game based on two players putting X and O on 2d array
First method should return true if element filed[y][x] is ok;
public boolean yxInField(int y, int x, char[][] field) {
return field != null
&& y >= 0
&& x >= 0
&& y < field.length
... |
IN scrum , everything is written in terms of user , They are called user stories. For starting new projects in scrum , should one write SRS document ? Or just go directly for user stories . I did not find any relevant source that points SRS in scrum environment ? Am I missing something ?
|
A little background on the system I’m dealing with:
analytics platform --comprised of--> OSGi plugins --comprised of--> Java package(s) --containing--> unit(s) of functionality each with independent MVCs (called “nodes”)
The plugin I would like to augment is called “base”, and all of the analytics platform end-users us... |
I'm not sure what SE site to ask this on, but I figure this is something somebody in the SE community has the answer. Feel free to move this question if this is the wrong place.
Recently I launched the game Vainglory on my iPhone for the first time in a while. The first thing I noticed was the pop-up saying that the ap... |
I want to use a gitflow-like workflow, but with two servers. That is, regular work happens on server A and the release branch is hosted on server B, from where the release tags are created. Commits to server B should only happen when a new version is ready.
So, the question is: how can this be done, preferably with the... |
I have an application built in C# using the MVVM pattern that will have 40-50 different tests that need to be run. I want to show each test as a list item with a progress bar of how far each test has progressed. I want to run multiple tests at one time and at some point in the future there may be dependencies where c... |
I am currently developing an HTML5/C# web app to replace an older ASP.NET forms app and after reading many blogs and posts I still do not understand the objectives, purposes, and weaknesses of the built in authentication schemes in ASP.NET. So if I implemented my own authentication/security in the following way, what w... |
I came across an architecture for a .net application where there are 3 layers
Repository layer (edmx and their classes)
^
|
V
Domain layer (Model -> Interfaces and their implementation)
^
|
V
Web layer (Model -> View models)
Communication between the web and the data layer takes pla... |
Recently I learned that standard Fortran does not support unsigned integers. Fortran is a language with a very long history. I suppose that when Fortran was first designed, there simply wasn't any notion of unsigned integers, and they have never been introduced after that.
Do signed integers predate unsigned integers... |
I have an application built on ASP Classic & Microsoft Access (for the Database) which I have been maintining for a long time, but now I want to upgrade it to PHP for the betterment.
Maintainence Procedure (3/4 times a day)
I download the live Access file from the server.
I run the UPDATE queries that update records ... |
We have a transaction database for our application. We are designing a solution for budget automation. Budget are heterogeneous in nature. As Sales budget have different attributes and expense budget have different attributes but ultimately figures will map to accounts in our accounting system. budget consumption will... |
Java artifacts are often staged through different "quality levels", named like alpha, beta, releaseCandidate, release etc. They enter the next stage if they have passed tests (automatic or manual ones).
We have an old, primitive staging software in our company. This should be replaced. Before we opt for getting some ex... |
Models for the database (using EF6) have certain attributes like Key, NotMapped, or Required (which will set the column in SQL Server to not null) while models which interact with the MVC portion of the website have their own attributes. An example of that is also Required which I use for data validation when a user is... |
From man 3 assert_perror:
The purpose of the assert macros is to help programmers find bugs in their programs, things that cannot happen unless there was a coding mistake. However, with system or library calls the situation is rather different, and error returns can happen, and will happen, and should be tested for. ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.