instruction stringlengths 34 36.1k |
|---|
When creating a Set in Java, what's the difference between the following? Which one should I use, and why?
Set< T > set = new HashSet<>();
HashSet< T > set = new HashSet<>();
|
Our application allows users to read/add/edit/delete table records through the UI. To prevent concurrent users from editing the same table row (stale record scenarios) we use a row identifier and row version field in the table. These operations are now exposed through web services too. In order to reuse code the read a... |
I am working micro service architecture and figuring out what is the best way to get complex data from a micro service.
So for example : Let's say micro service A is owning data based on any CRUD operations, there are X,Y,Z services which requires some sort of aggregated info and conditional info from micro service A,... |
I just wondered if this would be a good practice:
Imagine a Model for example a User, which is read from a Webservice or an Database.
Of course the user-implementation must not have any knowledge about the datasource.
I wondered if it is an good idea to add those knowledge by an Extension method, so I could do somethin... |
In the following code, int() is an explicit type conversion.
#include <iostream>
int main()
{
void* ptr = int();
return 0;
}
Clang Compiler:
source_file.cpp:5:11: error: cannot initialize a variable of type 'void *' with an rvalue of type 'int'
void* ptr = int();
^ ~~~~~
GCC Compiler:
Workin... |
I work on an online game server. For regeneration of player's hitpoints, I consider using timers. That is, if the player is online and his HPs or mana is lower than maximum, every minute these stats are incremented.
Normally, there is no more than 50-80 players online at the same time. Is a wise approach to create a t... |
Background to avoid the X-Y problem: I'm building a database migration system that needs to resolve foreign key constraints (see here for full background). I need to determine what order I can execute create table/modify table operations so as to not violate any foreign key constraints. A topological sort is a natura... |
To extend a bit on the title, I'm trying to get to some conclusion about whether it is necessary or not to explicitly declare (i.e. inject) pure functions on which some other function or class depends.
Is it any given piece of code less testable or worse designed if it uses pure functions without asking for them? I wou... |
Question
So, is using Cucumber to (near)exhaustively define complex interactions of requirements by example an abuse of the tool?
Question Setup
Is it appropriate use of Cucumber (or any other specification by example tool) for documenting the complex interactions of rules? Global rules in written requirements can leav... |
I just learned about the MVC architecture. I was going back and working on a command line file transfer application I wrote, and I was curious, to what degree should command line interfaces follow the MVC pattern?
|
Like the title asks, for what reasons would you use the ampersand binding in AngularJS instead of utilizing an event system--especially in a case where your application already uses events for some things? Either AngularJS's own $broadcast and $emit system or a third party library like Postal.
It seems like both paradi... |
There is an application which serves a huge list of resources and in the UI the users are able to filter the resources by type and other properties.
The resources are of different types but they have few properties common in them. For example there are resources of type Car, Book and Pet each has colour, price, owner a... |
Let's say I have a Matrix class I've already implemented.
Matrix<float> mat(30, 30);
for(size_t row = 0; row < mat.rows(); row++) {//Assume Row-Major ordering for performance reasons
for(size_t column = 0; column < mat.columns(); column++) {
mat(row, column) = float(row+1) / float(column+1);
}
}
I'd li... |
I recently asked this question.
I am trying to decide where to put the validation in a DDD app. I believe it should be done at every layer.
I am now concentrating on the Domain model. I was expecting validation to go in the Setter methods like this.
What is the "best" way to do validation. I am talking from the pers... |
I am looking at writing test cases (something I haven't done/been taught before). I am creating a web app which has a Java based REST Api backend which uses Spring Boot.
Regarding various types of tests(unit tests, integration tests etc), I am confused about what to apply where.
The code of my application is divided in... |
Let's say that I have a Person class. The person can eat, swim, and sleep. Basically, I do Person:Eat() and he eats and so on. Now what if he has a set of martial arts he can use? How would I do that?
Would it be like Person.martialArts.Karate:Kick() to perform a karate kick?
Or would it be better to have martialArts a... |
I have a NoSQL repository with two tables, Foo and Bar. Each Foo has some metadata and a list of Bar ids. Each Bar has some metadata.
I'm writing the API for retrieving a Foo and would like to provide the ability to specify whether the returned Foo contains either the related Bar ids or the related Bar objects.
For e... |
I knew that by using De-duplication procedure we can save storage costs.
1) I know what is de-duplication but I don't know how it works. Can someone clearly explain how de-duplication procedure works?
2) Can de-duplication be applied across all users? (does any Cloud Service Provider like Google, Azure, AWS and Dropbox... |
While studying the book of Software Engineering by author Roger Pressman I came across this point about software reengineering , where it is written in the book that if creating documentation is time consuming then it is skipped. Roger Pressman says if there are no significant changes after reengineering then documenta... |
Hi there i've been into MvvM and modular design the last few days, i find it really nice design principle that be scaled and maintained really well.
But here is the thing, i see there are multiple platforms like Prism that make the whole process automated, they have their own templates, their own observable objects, th... |
For my software engineering project I will be creating software to automate tasks.
In my project management module I have been asked to describe and evaluate how I can met all the specific goals for Verification in CMMI Version 1.3.
By looking at Wikipedia I can see what is outlined for Verification as:
Purpose
The pur... |
I recently asked a question about validation here: What is the "best" way to apprach validation from the perspective of a DDD purist?
Please see the code below, which I borrowed from here:
if (string.IsNullOrWhiteSpace(email) || email.Length > 100)
throw new ArgumentException(“E-mail is invalid”);
i... |
I have an abstract class with one or two protected methods needed for the subclasses.
abstract class TransformRouteProcessor {
protected String doX(String arg1){
//doX code
}
protected int doY(String arg1) {
//doY code
}
}
The subclasses will need to implement the processor interface... |
I come from many years working with SQL Server. I am working now on a mobile game using GameSparks as the back-end which only supports NoSQL run on Mongo.
I am creating a Computer Card Game and am trying to get my head around the best-practice for creating documents in collections which relate to other documents in a d... |
I need to design an Restful API resource and it's quite a complicated resource in that i need details about other resource to define my property.
Currently I have 3 solution.
Creating the related resource as a property until I have the
granular detail I need.
Pros: Efficient
Cons: breaking open / closed principle ... |
I would like to understand why is redis called an in memory database when it provides persistence similar to databases like MySQL or Postgres:
http://oldblog.antirez.com/post/redis-persistence-demystified.html
https://redis.io/topics/persistence
|
I've decided to implement a database wrapper to provide data operations of a web service using postgresql dbms.
Models in my database are somelike complex and frameworks like slick do provide more problems and need of workarounds due to type complexity than time or effort saving.
Following this Programming in Scala 2 q... |
I need to create a web application that will use MVC. The application is small, and will only use one web page. It will retrieve information from a database, as well as add and update entries onto it. The page will most probably be accessed by only one person at a time. It will not be using Entity Framework.
I'm new to... |
I am working on a program that has several frontends. The main application has a GUI that allows a lot of manual user interaction. The second one is more like a script that just runs a default work flow.
At some point questions to the user may appear. These are most often related to ambiguous input data, where the user... |
I have a class that has loads of functions, and I can't divide it in multiple class :
Class A {
// attributes
/**
* Descriptive of foo
*
* @param i ...
* @param j ...
*/
public void foo(int i, double j) {
....
}
// doc for foo2
public void foo2() {
....
... |
There is a website driven by Django where the user logs in and can answer thousands of questions. I want to persistently save whether a given user has answered a given question or not.
My approach so far is for the User table to have thousands of columns in the PostgreSQL database - a column for each question containin... |
In C# you can use a for-loop without declaring the body, what is the benefit of using this in production-code versus using a foreach loop?
Example
My Examples below use reflection to get the property value of an object based on the p_strPropertyPath parameter. The method can also look at the property of a property, for... |
I have been reading a lot about different design patterns, their pros, cons, main usage etc. However, I like to experiment and try to invent my own ways of the implementations (even if they are not the best). Now I am facing a problem with my Entity component system implementation.
Despite of the pros of this pattern I... |
I am currently working on project which requires parsing different types of files. The content of the files will populate the classes.
eg: file1 populate content of class1, file2 populate content of class2, etc.
My question is where should the parsing logic of the file go?
1st option : If I place the parsing logic ... |
I'm interested in how companies cost in the maintenance of software and or improvement of code quality over time.
The context I would like to add, is not that of a company who have a single product where all their resource is devoted to this one area, more a company who develop many smaller projects per year for a rang... |
In Clean Code, Robert C. Martin states that no parameter methods are better than those with very few parameters. I'm kind of confused as no parameter methods are usually harder to unit test and tend to be more coupled.
I think his rational is that since a class should only fulfill one very specific task the coupling i... |
According to Vernon Vaughn's - Implementing Domain Driven design:
...Events are used to rebuild the state of the Aggregate by replaying
them in the same order in which they occurred. The premise is that
this approach simplifies persistence..
My question is... In a DDD system where your domain is publishing events... |
I'm working on a legacy warehouse system. There is one Aggregate root, Product which has its correspondent ProductRepository.
Right now I have a new requirement that says the following:
Some Products are Purchasable and need to keep track of the datetime they have become purchasable.
So, in order to implement this re... |
I've been through a few iterations of DDD with a few different projects, yet I still struggle with properly defining bounded contexts. I continually find myself wanting to create very granular aggregates. This has become even more true once I've introduced event sourcing into the mix.
Here's a concrete example. Let'... |
I'm writing a C# style guide for my team and I'm trying to describe the benefits of side-effect-free functional-style methods. I want to include online references to back up the suggestions, but I can't seem to Google the kind of functional method chaining I have in mind.
When I think "method chain", I imagine somethin... |
I am writing some test units using googletest and googlemock and I am stuck in a problem related to C++11 smart pointers and polymorphism.
Suppose you have those classes:
class A {
public:
virtual void doThings() {...};
};
class B {
private:
B(std::unique_ptr<A> a): a_(std::move(a)) {}
std::unique_ptr<A> a... |
I'll pick one of the most popular react boilerplates as an example here.
Assume, i've forked it (commits history till fork date remains intact).
According to the text of MIT license, the only thing that I have to keep is the license itself. So, does it mean i can change whatever i want in this repo and remove/replace w... |
I'll break this post into two parts, because I'm trying to abstract the concept, but will explain my implementation at the end.
I have two workflows, Workflow A and Workflow B. Part of Workflow B relies on the results of Workflow A. They can be executed sequentially and work as intended, but I want to pipeline them. I ... |
Would it be correct to assume that in general, I would need as many controller classes as classes that can be accessed/modified by a user?
For example, If a logged-in user can add/modify to a class clients, addresses and stores, I would need a controller for each class?
thanks
|
The project that raised this question is in C#, but it could apply to most languages that use namespaces.
I've read many things on good naming practices:
"Don't prefix your class names with their namespace name. That's just creating unnecessary duplication." (Smurf naming)
"One of the uses for namespaces is separatin... |
Lets say I am creating an API for class University to create a Class.
(This Class has Class name, Teacher and students).
eg:
class Class{
..
private:
std::string class_name_;
Teacher teacher_;
std::vector<Student> students_;
};
class University{
public:
... |
The following quote is from this page:
While some CPU manufacturers implement a single address space in their
chips, others decided that peripheral devices are different from
memory and, therefore, deserve a separate address space. Some
processors (most notably the x86 family) have separate read and write
elec... |
I'm writing a program with the following conceptual mode.
A User can apply to become an employee, which places their account in a Pending state. They can then be Approved or Rejected. The only person who can put an account in the Pending state is the user themselves.
An Administrator can move users to and between the ... |
Say you start a web site on shared hosting and it increases in popularity which might cause it to become unavailable as the number of accesses increases.
So as a developer how do I figure out when the limits are being reached and what can I do about it in terms of the architecture with the suitable hosting solution to ... |
I am trying to adhere to the Single Responsibility Principle (SRP) as much as possible and got used to a certain pattern (for the SRP on methods) heavily relying on delegates. I'd like to know if this approach is sound or if there are any severe issues with it.
For example, to check input to a constructor, I could int... |
I'm aware of software development principles and best practices. However, in most cases I entered a project that was already on its phase 2, and that already had a significant amount of code written. In addition, in some cases the code and architecture of the project was causing several problems to the application (per... |
A Drupal website is using external Rest API service.
The problem is that in a rare occasion when the Rest API service loses database or crashes for whatever reason, that causes the Drupal website to slow down.
Drupal uses many API endpoints frequently so when those are unavailable, the website becomes useless.
What wo... |
Please see the code below:
public interface IUnitOfWorkWrite <TSession> : IDisposable
{
TSession Session { get; }
void Commit();
void Rollback();
ITransaction BeginTransaction();
}
}
This interface is contained in the domain layer. The service layer provides an implementation. ... |
I have a code base consisting of multiple scripts and many functions. Everything is controlled from one master script (master.txt, let's say).
I have a lot of "global" configuration files, for example the URL, login, and password of the webservice I'm communicating with (this changes between test and production), and s... |
Our company still uses a lot of manual testing of software (and this will not change in the coming years). We try to improve our build and deployment process by using a deployment pipeline which handles both the automatic and the manual tests.
The idea is to present the user a list of tests for which he approves that t... |
Wiki says:
Substitutability is a principle in object-oriented programming stating that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e. an object of type T may be substituted with any object of a subtype S) without altering any of the desirable propert... |
I have been given a project recently where REST API have been implemented in the most basic way possible i.e. request comes to app, app hits controller, queries db, returns response.
So this mechanism, as its quite obvious, has started to create issues in terms of response times as data has grown a lot. Plus this appr... |
Suppose I have a compiled dynamic library: .dll, .lib, .so etc. Is it (theoretically) possible to automatically create C header file for such a library? Is there an existing tool that does that?
Intuitively it looks to me like it should be possible. After all, the linker is able to find the necessary symbols inside the... |
We have the following scenario in our company:
There are some business objects which have business rules associated with them. One of these objects, Person, has the following rules:
A Person must have a name (that is in coding terms not null, nor empty)
A Person's name mustn't consist solely of spaces and/or tabs
The... |
Suppose that I have multiple instances I1, I2, I3, etc. of a set of classes C1, C2, etc. Suppose that these classes are all inheriting from a super-class S.
Suppose that there is an operation O(a, b) that takes two instances of S and see if they are compatible (compatible in some since.) In order to check for compatibi... |
I have recently started working on a complex project and recently had a team meeting where a new feature was discussed. I am not happy with the current architecture, because the system is undocumented. However, I have to prove myself in coming months and, hence, continue delivering.
To prove my point that documenting h... |
I have an XML file that contains configuration information for a system. I can serialize/deserialize the XML into a hierarchy of objects that describe the configuration (and no more) and then pass those objects to a task which performs work based on the data in the objects.
What I want to do is to build a specializ... |
I am given a project where the previous developer used <? and <?= whereas I am using <?php and <?php echo.
My questions:
- should I rewrite all files
_ or just when i need to tweak the code
- with new files/code should i use my pratice or copy the existing pratice
I am hoping this is the right subdivision of stackexch... |
I have developed a login system using OAuth2.0 that is currently working within one tab in one browser. Without diving into the code, the system works by having the user enter their credentials to login, the credentials are sent up to the API (WebAPI2 .Net) from the client (Angular), the user is logged in via Active Di... |
I'm developing an APP that has a API and a database that holds user permissions and user projects, among other things.
Certain stored procedures must be protected, and for that I have to check the scopes available for the user.
Should I check the user permissions inside the stored procedures (calling a second proc or f... |
I'm involved in the development of an enterprise web application whose functionality is separated into microservices deployed in a Docker Swarm.
In order to expose these microservices to the Internet (for example for our client side front ends), one of our microservices is an NGINX web server, which listens to web requ... |
I recently asked this question: Should the domain layer be dependent on NHibernate?
I have read a lot of questions today, where answerers state that the Domain Layer should only contain Business Logic. This confuses me when I read about the Onion architecture, which states that the domain layer should contain all inte... |
We have an old database which is used to hold supporting information about the financial system. Most of the actual code in are in Views which consolidate the supporting data with the financial data (held in a different system) into a single table. Some of this View code is very large.
Due to a change in the way financ... |
What is the advantage of returning a pointer to a structure as opposed to returning the whole structure in the return statement of the function?
I am talking about functions like fopen and other low level functions but probably there are higher level functions that return pointers to structures as well.
I believe that ... |
One of the proposed features for Java 7's "Project Coin" was the "Elvis operator". A report of a 2009 JavaOne presentation on Project Coin described it as such:
One of the "small features" covered in this presentation is the so-called "Elvis operator," a more concise version of the ternary operator. I find myself miss... |
I'm having trouble planning the structure of my server side workflow and the technologies I should use.
The basic structure and tasks are:
Now, things to consider:
1.the server listens to multiple "folders" in the DB at once.
the server need to process many changes to the db - about 1000 per sec for all folders in th... |
I am making a game with Unity, and am having problems attempting network synchronisation. Deterministic simulation is impossible because Unity's internal logic is float based. I am trying to make a solution which works on an authoritative client-server model, in which the position of every soldier is corrected by the... |
If You are Unfamiliar with OOP Matlab
For those not familiar with matlab, matlab provides a variety of access attributes when creating member variables. All member variables are essentially C# properties in their own right, who's get and set values default to normal access and assignment. Any (and I mean any) member ... |
In class, we are asked to draw a finite state machine with the following instructions:
Design a finite state machine to model a vending machine that accepts
only quarters and gives a container of juice when 75 cents have been
deposited, followed by a button being pushed. If a fourth quarter is
deposited before t... |
I am not grasping the idea from this quote by Stroustrup on page 862 of "The C++ Programming Language" 4th edition at the end of the first paragraph (I've highlighted the relevant portion):
Building the comparison criteria into a sort function is unacceptable because the same
data can be sorted according to differen... |
We have a chain of service A -> B -> C -> D.
A defines format of certain parameters say ParamA
B defines format of certain parameters say ParamB
D is the one which actually uses these parameters and C pass them to D. The role of C is to get data from D and do bit of business logic on top of that and return that to B an... |
I only know about cloud application "in theory"; I've read some material related to cloud computing but never had access to cloud computing from the point of view of their developer (not of the sysadmin!).
What is specific in developing (not deploying) cloud software in compiled languages (precisely those accepted by r... |
When working in NodeJS and requiring custom modules. Is it best practice to require one file that itself requires dependencies, or is it best to explicitly require only the files that are needed?
An example might be having a database class that returns a connection pool.
db_conn.js
Then there might be separate file... |
I use dependency injection with Guice and most of the time, I'm rather happy with it. But sometimes, it's difficult to get the dependencies to where they're needed and sometimes, it's plain impossible.
An extreme example is making MyResponse.toString() return some JSON, where MyResponse contains either a list of DTOs o... |
If I have a blog system, there is now a query that is given a range and then gets the number of new blogs in that range. The range may be:
one day
one week
a month
six months
a year
How do I design the backend API? Is the design of five independent API, or the design of an API to pass five different enum values on be... |
I can't figure out a barcode that would support ~3500 chars.
The barcode should contain 40 strings with caret return, each 76 chars long. Each string will look like this:
16N00001CGTXH60G2YE1NKL20518048000183150155491553423519964186228580116N00000
Each string has different numbers and letters.
I tried to generate a Q... |
Long story short, let's assume I want to create a webpage that would enable the users to sell used cars.
I am a beginner to webdev, so pardon my ignorance. Fun fact: two months ago I knew literally nothing, I considered HTML as a relic of 90s, not in use anymore LOL.
I've been told I need something for the BACKEND and... |
Please see the question here, which I asked yesterday: Domain Driven Design in an Onion Architecture
As stated I understand that DDD is an approach that targets the domain layer only and Onion is an architecture for the entire system i.e. core, infrastructure etc.
Onion suggests that all interfaces in the application s... |
In J.B. Rainsberger's discussion of collaboration tests he describes how tests for "clients" (users of a particular interface) should have two parts to their test.
Does the client ask the right questions of the interface? Checked through mocking and verification.
Does the client react properly when it receives the an... |
I'm new in software engineering and I recently read Philippe Kruchten's famous paper 'Architectural Blueprints—The “4+1” View Model of Software Architecture'.
He defined 4+1 views includeing Logical View, Process View, Development view the Physical view, and use-case.
But I also find some people call them Design View,... |
Imagine you have a user object that holds the following data: id, name, email, telephone, address, created date, last update date.
To create the user you only need a subset of these properties: name, email, telephone and address.
The number of properties can go out of hand and it is easier to group them in a dictionary... |
I've been modifying some code written by a previous employee and came across a function with the following signature:
BOOL WINAPI PrependPadding(
_In_ SIZE_T cbPadding,
_In_ SIZE_T cbRow,
_Out_writes_bytes_(cbPadding) _On_failure_(_Post_null_) BYTE *bRow
)
For those of you unfamiliar with Microsoft's SAL a... |
I need to create a login page for a basic accountancy-related application. Login action should be two-step one:
User enters their username and password and hits "Authorize" button,
After successful authorization user should set the initial parameters for the current session (i.e. the month and year, the unit for whic... |
I'm trying to set up a database, to run a small pig farm. The idea is the following:
I have a table called BELLIES, where I codify the sows along with relevant information about them (weight, id, birth date, purchase value, etc).
I want to manage on the basis of events the different processes involved, that is, the sow... |
I often find that I need to add new conditional feature to code that already exists. This requires me to keep the existing functionality while tacking on something new. I've tried each of the following methods but neither of them seems as elegant as I would like.
Option 1:
bar_1():
baz()
frobnicate()
bar_2(... |
I am working on a ticketing system. The user in system are organised in one level hierarchical way. There are many teams and each team has one manager and each user in the team has one and only one manager. A ticket can be created by any user in team. I have the following use case:
A user can see only the tickets crea... |
I am currently writing a class that performs a rather complex computation that should be triggered by one function call.
The steps of using the class would be:
Construction including the initialization of the basic parameters
Initialization with some more case specific settings
The actual computation
Now, the user of ... |
I want to create an app using MongoDB (NoSQL database) that allows people to vote on posts (simillar to Reddit). What's the recommended way to store votes for the users?
Probably the database structure will have to quickly respond to queries like:
Write:
User X votes (up or down) post A.
Read:
Has user X already vot... |
I am working on a set of .NET Core 2.0 Microservices together with some other developers. I wrote some code to add my own custom logging as described here. My logger sends the logging messages to an external cloud based log system (so not the command line). I am now trying to find out where my code should be placed. Th... |
Imagine that I am writing a game where tanks fight with each other.
A generic Tank class is created and has the method fire() which fires a cannon, looks like this Tank::fire() { /* fires a cannon */ }
And then there is a class for BossTank which fire() fires a cannon and also a missile.
A senior advised me to do som... |
I haven't been able to find a question (or set of questions quite like I am looking for)...apologies if there are.
I am basically trying to figure out how to create an algorithm to "split" muscles between workouts. Here is the main idea:
1) Muscles have "pairs". These are other muscles that work well with another muscl... |
This applies to to both Java SE & Android, as the contracts are identical.
CharSequence documentation for Java SE
CharSequence documentation for Android
CharSequence does not define a contains(CharSequence) method. I can't seem to find a reason why, and including it would be quite useful, preventing the need to call... |
I am striving to have the most maintainable architecture possible in my application, but I cannot decide on a proper domain model design.
Here is an example domain model for a user:
public class User // Referred to as the domain model
{
// A model whose properties map exactly to a database table schema
private... |
I'm following up on this question, but I'm switching my focus from code to a principle.
From my understanding of the Liskov substitution principle (LSP), whatever methods are in my base class, they must be implemented in my subclass, and according to this page, if you override a method in the base class and it does not... |
At the moment on my blog I have articles only one language. Now I want to write posts in other languages as well. The new posts will not be a translation of existing posts – I'll sometimes write articles in one language, sometimes in the other. The topics might well be different.
What's the best strategy to manage such... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.